Skip to content

Commit

Permalink
add Azure DevOps Task(setup-azd) to todo templates
Browse files Browse the repository at this point in the history
  • Loading branch information
v-jiaodi committed Sep 4, 2023
1 parent b8f37f7 commit f09afd1
Show file tree
Hide file tree
Showing 7 changed files with 148 additions and 36 deletions.
39 changes: 18 additions & 21 deletions templates/common/.azdo/pipelines/bicep/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,36 +10,33 @@ trigger:
pool:
vmImage: ubuntu-latest

# Use azd provided container image that has azd, infra, multi-language build tools pre-installed.
container: mcr.microsoft.com/azure-dev-cli-apps:latest

steps:
- task: setup-azd@0
displayName: Install azd

- pwsh: |
azd config set auth.useAzCliAuth "true"
displayName: Configure AZD to Use AZ CLI Authentication.
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
displayName: azd login
env:
AZURE_CREDENTIALS: $(AZURE_CREDENTIALS)
- task: AzureCLI@2
- pwsh: |
azd provision --no-prompt
displayName: Provision Infrastructure
inputs:
azureSubscription: azconnection
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
azd provision --no-prompt
env:
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
AZURE_LOCATION: $(AZURE_LOCATION)

- task: AzureCLI@2
- pwsh: |
azd deploy --no-prompt
displayName: Deploy Application
inputs:
azureSubscription: azconnection
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
azd deploy --no-prompt
env:
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
AZURE_LOCATION: $(AZURE_LOCATION)
AZURE_LOCATION: $(AZURE_LOCATION)
48 changes: 48 additions & 0 deletions templates/common/.azdo/pipelines/java/azure-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# Run when commits are pushed to mainline branch (main or master)
# Set this to the mainline branch you are using
trigger:
- main
- master

# Azure Pipelines workflow to deploy to Azure using azd
# To configure required secrets for connecting to Azure, simply run `azd pipeline config --provider azdo`

pool:
vmImage: ubuntu-latest

steps:
- task: setup-azd@0
displayName: Install azd

- task: JavaToolInstaller@0
inputs:
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'

- pwsh: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
displayName: azd login
env:
AZURE_CREDENTIALS: $(AZURE_CREDENTIALS)
- pwsh: |
azd provision --no-prompt
displayName: Provision Infrastructure
env:
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
AZURE_LOCATION: $(AZURE_LOCATION)
- pwsh: |
azd deploy --no-prompt
displayName: Deploy Application
env:
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
AZURE_LOCATION: $(AZURE_LOCATION)
27 changes: 15 additions & 12 deletions templates/common/.azdo/pipelines/terraform/azure-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,20 @@ trigger:
pool:
vmImage: ubuntu-latest

# Use azd provided container image that has azd, infra, multi-language build tools pre-installed.
container: mcr.microsoft.com/azure-dev-cli-apps:latest

steps:
- task: setup-azd@0
displayName: Install azd

- pwsh: |
azd config set auth.useAzCliAuth "true"
displayName: Configure AZD to Use AZ CLI Authentication.
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
displayName: azd login
env:
AZURE_CREDENTIALS: $(AZURE_CREDENTIALS)
- pwsh: |
azd config set alpha.terraform on
Expand All @@ -41,15 +48,11 @@ steps:
RS_STORAGE_ACCOUNT: $(RS_STORAGE_ACCOUNT)
RS_CONTAINER_NAME: $(RS_CONTAINER_NAME)

- task: AzureCLI@2
- pwsh: |
azd deploy --no-prompt
displayName: Deploy Application
inputs:
azureSubscription: azconnection
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
azd deploy --no-prompt
env:
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
AZURE_LOCATION: $(AZURE_LOCATION)
64 changes: 64 additions & 0 deletions templates/common/.azdo/pipelines/terraform/java/azure-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Run when commits are pushed to mainline branch (main or master)
# Set this to the mainline branch you are using
trigger:
- main
- master

# Azure Pipelines workflow to deploy to Azure using azd
# To configure required secrets for connecting to Azure, simply run `azd pipeline config --provider azdo`

pool:
vmImage: ubuntu-latest

steps:
- task: setup-azd@0
displayName: Install azd

- pwsh: |
$info = $Env:AZURE_CREDENTIALS | ConvertFrom-Json -AsHashtable;
azd auth login `
--client-id "$($info.clientId)" `
--client-secret "$($info.clientSecret)" `
--tenant-id "$($info.tenantId)"
displayName: azd login
env:
AZURE_CREDENTIALS: $(AZURE_CREDENTIALS)
- pwsh: |
azd config set alpha.terraform on
displayName: Enable terraform alpha feature from azd
- task: JavaToolInstaller@0
inputs:
versionSpec: '17'
jdkArchitectureOption: 'x64'
jdkSourceOption: 'PreInstalled'

- task: AzureCLI@2
displayName: Provision Infrastructure
inputs:
azureSubscription: azconnection
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
azd provision --no-prompt
env:
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
AZURE_LOCATION: $(AZURE_LOCATION)
ARM_TENANT_ID: $(ARM_TENANT_ID)
ARM_CLIENT_ID: $(ARM_CLIENT_ID)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
RS_RESOURCE_GROUP: $(RS_RESOURCE_GROUP)
RS_STORAGE_ACCOUNT: $(RS_STORAGE_ACCOUNT)
RS_CONTAINER_NAME: $(RS_CONTAINER_NAME)

- pwsh: |
azd deploy --no-prompt
displayName: Deploy Application
env:
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
AZURE_LOCATION: $(AZURE_LOCATION)
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ repo:
- .azdo/pipelines/*/azure-dev.yml

# AzDo workflows for bicep
- from: ../../../../../common/.azdo/pipelines/bicep/azure-dev.yml
- from: ../../../../../common/.azdo/pipelines/java/azure-dev.yml
to: ./.azdo/pipelines/azure-dev.yml

# Github workflows for bicep
Expand Down
2 changes: 1 addition & 1 deletion templates/todo/projects/java-mongo/.repo/bicep/repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ repo:
- .azdo/pipelines/*/azure-dev.yml

# AzDo workflows for bicep
- from: ../../../../../common/.azdo/pipelines/bicep/azure-dev.yml
- from: ../../../../../common/.azdo/pipelines/java/azure-dev.yml
to: ./.azdo/pipelines/azure-dev.yml

# Github workflows for bicep
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ repo:
- .azdo/pipelines/*/azure-dev.yml

# AzDo workflows for terraform
- from: ../../../../../common/.azdo/pipelines/terraform/azure-dev.yml
- from: ../../../../../common/.azdo/pipelines/terraform/java/azure-dev.yml
to: ./.azdo/pipelines/azure-dev.yml

# Github workflows for terraform
Expand Down

0 comments on commit f09afd1

Please sign in to comment.