I want to deploy 3 Service Bus Resources using the azure pipeline.
test and dev don't need approval, but prd deployment needs approval.
my pipeline is able to deploy dev and test resource without any problem, It asks for approval when it comes to prd deployment, But then it stops with error message :
Creating deployment parameters.
##[error]Check out the troubleshooting guide to see if your issue is addressed: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
##[error]Error: Could not find any file matching the template file pattern
Finishing: AzureResourceManagerTemplateDeployment
Here is my pipeline code.
trigger:
branches:
include:
- main
- release/*
- feature/*
- bug-fix/*
pool:
vmImage: ubuntu-latest
stages:
- stage: 'DevDeployStage'
dependsOn: BuildStage
condition: and(succeeded('BuildStage'), contains(variables['Build.SourceBranch'],'refs/heads/main'))
variables:
- group: common-kv-dev
- group: common-dp-dev
displayName: 'DevDeployStage'
jobs:
- job: DevDeployStageJob
steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'conn-to-RG'
subscriptionId: '7777777-4444-4444-4444-222222222222'
action: 'Create Or Update Resource Group'
resourceGroupName: 'MY_RG'
location: 'East US'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/template.json'
csmParametersFile: '$(System.DefaultWorkingDirectory)/parameters.json'
overrideParameters: '-namespaces_amitbus_name amit-dev'
deploymentMode: 'Incremental'
- stage: 'tstDeployStage'
dependsOn: BuildStage
condition: and(succeeded('BuildStage'), contains(variables['Build.SourceBranch'],'refs/heads/main'))
variables:
- group: common-kv-dev
- group: common-dp-dev
displayName: 'tstDeployStage'
jobs:
- job: tstDeployStageJob
steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'conn-to-RG'
subscriptionId: '7777777-4444-4444-4444-222222222222'
action: 'Create Or Update Resource Group'
resourceGroupName: 'MY_RG'
location: 'East US'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/template.json'
csmParametersFile: '$(System.DefaultWorkingDirectory)/parameters.json'
overrideParameters: '-namespaces_amitbus_name amit-tst'
deploymentMode: 'Incremental'
- stage: 'PrdDeployStage'
dependsOn: BuildStage
condition: and(succeeded('BuildStage'), contains(variables['Build.SourceBranch'],'refs/heads/main'))
variables:
- group: common-kv-dev
- group: common-dp-dev
displayName: 'PrdDeployStage'
jobs:
- deployment: PrdDeployStageJobDeploment
displayName: 'PrdDeployStageJob'
pool:
vmImage: ubuntu-latest
environment: production
strategy:
runOnce:
deploy:
steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'conn-to-RG'
subscriptionId: '7777777-4444-4444-4444-222222222222'
action: 'Create Or Update Resource Group'
resourceGroupName: 'MY_RG'
location: 'East US'
templateLocation: 'Linked artifact'
csmFile: 'template.json'
csmParametersFile: 'parameters.json'
overrideParameters: '-namespaces_amitbus_name amit-prd'
deploymentMode: 'Incremental'
I fail to understand why prd deployment is giving errors, whereas the same lines of code work for test and dev environments without any issues.
Job and deployments are different in nature. By default, job will download the repo but deployment will not. Just mentioned checkout: self in deployment and it fixed my issue.