diff --git a/templates/common/.azdo/pipelines/bicep/azure-dev.yml b/templates/common/.azdo/pipelines/bicep/azure-dev.yml index 8578d84de25..7ac0307a04a 100644 --- a/templates/common/.azdo/pipelines/bicep/azure-dev.yml +++ b/templates/common/.azdo/pipelines/bicep/azure-dev.yml @@ -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) \ No newline at end of file diff --git a/templates/common/.azdo/pipelines/java/azure-dev.yml b/templates/common/.azdo/pipelines/java/azure-dev.yml new file mode 100644 index 00000000000..e23fc1a037e --- /dev/null +++ b/templates/common/.azdo/pipelines/java/azure-dev.yml @@ -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) \ No newline at end of file diff --git a/templates/common/.azdo/pipelines/terraform/azure-dev.yml b/templates/common/.azdo/pipelines/terraform/azure-dev.yml index 74fa2273876..3efac1bf08a 100644 --- a/templates/common/.azdo/pipelines/terraform/azure-dev.yml +++ b/templates/common/.azdo/pipelines/terraform/azure-dev.yml @@ -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 @@ -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) + diff --git a/templates/common/.azdo/pipelines/terraform/java/azure-dev.yml b/templates/common/.azdo/pipelines/terraform/java/azure-dev.yml new file mode 100644 index 00000000000..bcb6b996486 --- /dev/null +++ b/templates/common/.azdo/pipelines/terraform/java/azure-dev.yml @@ -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) + diff --git a/templates/todo/projects/java-mongo-aca/.repo/bicep/repo.yaml b/templates/todo/projects/java-mongo-aca/.repo/bicep/repo.yaml index a714e482bf0..bc7e2e9e31f 100644 --- a/templates/todo/projects/java-mongo-aca/.repo/bicep/repo.yaml +++ b/templates/todo/projects/java-mongo-aca/.repo/bicep/repo.yaml @@ -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 diff --git a/templates/todo/projects/java-mongo/.repo/bicep/repo.yaml b/templates/todo/projects/java-mongo/.repo/bicep/repo.yaml index 43df1fa1889..181c9b4b1a3 100644 --- a/templates/todo/projects/java-mongo/.repo/bicep/repo.yaml +++ b/templates/todo/projects/java-mongo/.repo/bicep/repo.yaml @@ -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 diff --git a/templates/todo/projects/java-postgresql/.repo/terraform/repo.yaml b/templates/todo/projects/java-postgresql/.repo/terraform/repo.yaml index 5fd8cbb03e9..87a8cb0732b 100644 --- a/templates/todo/projects/java-postgresql/.repo/terraform/repo.yaml +++ b/templates/todo/projects/java-postgresql/.repo/terraform/repo.yaml @@ -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