Can you please help me with below.
I am building Azure Function app V3 and using Azure Devops YAML pipeline to build and deploy Azure function app and ARM infra to Dev environment. Now I want to deploy the same to UAT. I am not sure how to have different environment using YAML.
please find my azure-pipeline.yml file that I am using
name: $(Build.DefinitionName)-$(Date:yyyyMMdd)$(Rev:.r)
trigger:
- dev
resources:
repositories:
- repository: pipeline
name: Pipeline
type: git
pool:
vmImage: 'windows-latest'
variables:
- name: Folder.BaseRepo # Location in repo where the templates are stored
value: $(Build.SourcesDirectory)/Finance
- name: Folder.Templates # Location in repo where the templates are stored
value: infrastructure
stages:
- stage: Build
displayName: 'Build'
jobs:
- job: PublishTemplatesAndScripts
displayName: 'Publish Templates and Scripts'
steps:
- template: 'publish-templates.yml@pipeline'
parameters:
templateFolder: '$(Folder.Templates)'
artifactName: 'templates'
pipelineRepository: pipeline
pipelineRepositoryPath: pipeline
- task: DotNetCoreCLI@2
displayName: 'Restore dependencies'
inputs:
command: 'restore'
projects: '$(Folder.BaseRepo)/Finance.sln'
feedsToUse: 'select'
vstsFeed: 'ac1301c4-6618-4824-a09e-0042d9871fb5/58ed1ece-4d06-46f7-b947-XXXX36281c4'
enabled: true
- task: DotNetCoreCLI@2
displayName: 'Build function app'
inputs:
projects: '$(Folder.BaseRepo)/Finance.sln'
command: 'build'
arguments: '--configuration Release'
enabled: true
- task: DotNetCoreCLI@2
displayName: 'Test function app'
inputs:
projects: '$(Folder.BaseRepo)/Finance.sln'
command: 'test'
arguments: '--configuration Release'
enabled: false
- task: DotNetCoreCLI@2
displayName: 'Publish function app'
inputs:
command: 'publish'
publishWebProjects: false
projects: '$(Folder.BaseRepo)/src/Finance/Finance.csproj'
arguments: '--output $(Build.ArtifactStagingDirectory)/publish --configuration Release'
enabled: true
- task: PublishPipelineArtifact@1
displayName: 'Publish function app output'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)/publish'
artifact: 'drop'
publishLocation: 'pipeline'
enabled: true
- stage: Development
displayName: 'Development'
jobs:
- deployment: DevelopmentAzure
displayName: 'Development Azure'
environment: 'Development'
#uses runtime expression
strategy:
runOnce:
deploy:
steps:
- template: 'deploy-template.yml@pipeline'
parameters:
entryTemplateName: MyArm.json
templateParametersName: MyArm.dev.parameters.json
deploymentResourceManagerConnection: '$(Azure.NonProd.ResourceManagerConnection)'
deploymentSubscriptionIdentifier: '$(Azure.NonProd.SubscriptionId)'
resourceManagerConnection: '$(Azure.Dev.ResourceManagerConnection)'
subscriptionIdentifier: '$(Azure.Dev.SubscriptionId)'
resourceGroupName: '$(Resource_Group)'
outputVariablePrefix: AzureDeployment
- deployment: DevelopmentFunctions
displayName: 'DevelopmentFunctions'
environment: 'Development'
dependsOn: DevelopmentAzure
strategy:
runOnce:
deploy:
steps:
- task: AzureFunctionApp@1
inputs:
azureSubscription: 'ServiceConnection-XXXXX-DevTest'
appType: 'functionApp'
appName: 'XXX-xxx-dev-funcapp'
package: '$(Pipeline.Workspace)/drop/*.zip'
deploymentMethod: 'zipDeploy'
enabled: true
So what is the way to deploy it to Test environment. Do I need to create another yaml file with different trigger in same repo? or different stage in same yaml file and apply some condition on stages when UAT branch changes happen then deploy to only UAT stage only(not dev stage).
Any help is appreciated!! Thanks in advance