|
| 1 | +# Run when commits are pushed to mainline branch (main or master) |
| 2 | +# Set this to the mainline branch you are using |
| 3 | +trigger: |
| 4 | + - main |
| 5 | + - master |
| 6 | + |
| 7 | +# Azure Pipelines workflow to deploy to Azure using azd |
| 8 | +# To configure required secrets and service connection for connecting to Azure, simply run `azd pipeline config --provider azdo` |
| 9 | +# Task "Install azd" needs to install setup-azd extension for azdo - https://marketplace.visualstudio.com/items?itemName=ms-azuretools.azd |
| 10 | +# See below for alternative task to install azd if you can't install above task in your organization |
| 11 | + |
| 12 | +pool: |
| 13 | + vmImage: ubuntu-latest |
| 14 | + |
| 15 | +steps: |
| 16 | + - task: setup-azd@0 |
| 17 | + displayName: Install azd |
| 18 | + |
| 19 | + # If you can't install above task in your organization, you can comment it and uncomment below task to install azd |
| 20 | + # - task: Bash@3 |
| 21 | + # displayName: Install azd |
| 22 | + # inputs: |
| 23 | + # targetType: 'inline' |
| 24 | + # script: | |
| 25 | + # curl -fsSL https://aka.ms/install-azd.sh | bash |
| 26 | + |
| 27 | + # azd delegate auth to az to use service connection with AzureCLI@2 |
| 28 | + - pwsh: | |
| 29 | + azd config set auth.useAzCliAuth "true" |
| 30 | + displayName: Configure AZD to Use AZ CLI Authentication. |
| 31 | +
|
| 32 | + - task: AzureCLI@2 |
| 33 | + displayName: Provision Infrastructure |
| 34 | + inputs: |
| 35 | + azureSubscription: azconnection |
| 36 | + scriptType: bash |
| 37 | + scriptLocation: inlineScript |
| 38 | + inlineScript: | |
| 39 | + azd provision --no-prompt |
| 40 | + env: |
| 41 | + AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID) |
| 42 | + AZURE_ENV_NAME: $(AZURE_ENV_NAME) |
| 43 | + AZURE_LOCATION: $(AZURE_LOCATION) |
| 44 | + |
| 45 | + - task: AzureCLI@2 |
| 46 | + displayName: Deploy Application |
| 47 | + inputs: |
| 48 | + azureSubscription: azconnection |
| 49 | + scriptType: bash |
| 50 | + scriptLocation: inlineScript |
| 51 | + inlineScript: | |
| 52 | + azd deploy --no-prompt |
| 53 | + env: |
| 54 | + AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID) |
| 55 | + AZURE_ENV_NAME: $(AZURE_ENV_NAME) |
| 56 | + AZURE_LOCATION: $(AZURE_LOCATION) |
0 commit comments