Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Azure DevOps Task (setup-azd) to todo templates #2701

Merged
merged 2 commits into from
Sep 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
vhvb1989 marked this conversation as resolved.
Show resolved Hide resolved
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