Skip to content

Simplify AZD experience #459

Simplify AZD experience

Simplify AZD experience #459

# This file is part of our engineering process to build and maintain this file.
# See the README markdown file for further details
on:
workflow_dispatch:
pull_request:
types: [opened, synchronize, ready_for_review, reopened]
schedule:
- cron: '0 12 1 * *' # Run at 12:00 on the 1st day of the month
# https://learn.microsoft.com/en-us/azure/developer/github/connect-from-azure?tabs=azure-portal%2Clinux#set-up-azure-login-with-openid-connect-authentication
permissions:
id-token: write
contents: read
concurrency: integration_testing
jobs:
build:
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/azure-dev-cli-apps:1.5.1
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }}
IS_RUN_AS_SERVICEPRINCIPAL: true
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
steps:
- name: Install jq tool
uses: dcarbone/install-jq-action@v2
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
# login to run ado commands such provision, deploy, and down
- name: Log in with Azure (Client Credentials) for AZD
if: ${{ env.AZURE_CREDENTIALS != '' }}
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
azd login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
shell: pwsh
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure Dev Provision
run: azd provision --no-prompt
env:
AZURE_PRINCIPAL_TYPE: ServicePrincipal
# re-login to run ado commands such provision, deploy, and down
- name: Log in with Azure (Client Credentials) for AZD
if: ${{ env.AZURE_CREDENTIALS != '' }}
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
azd login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
shell: pwsh
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
- name: Azure Dev Deploy
run: azd deploy --no-prompt
# login to run az cli commands such as validateDeployment.sh
- name: Log in with Azure CLI
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: QA - Validate Deployment
run: ./testscripts/call-validate-deployment.sh
teardown:
needs: [build]
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/azure-dev-cli-apps:1.5.1
env:
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
AZURE_ENV_NAME: ${{ secrets.AZURE_ENV_NAME }}
AZURE_LOCATION: ${{ secrets.AZURE_LOCATION }}
steps:
- name: Checkout
uses: actions/checkout@v2
# login to run ado commands such provision, deploy, and down
- name: Log in with Azure (Client Credentials) for AZD
if: ${{ env.AZURE_CREDENTIALS != '' }}
run: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
Write-Host "::add-mask::$($info.clientSecret)"
azd login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
shell: pwsh
env:
AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
- name: Create AZD environment
# Creating an azd environment so we can set the principal type
# https://github.com/Azure/reliable-web-app-pattern-dotnet/issues/241
run: azd env new ${{ secrets.AZURE_ENV_NAME }} --subscription ${{ secrets.AZURE_SUBSCRIPTION_ID }} --location ${{ secrets.AZURE_LOCATION }}
- name: Azure Dev Down
run: azd down --force --purge --no-prompt