VenkatRam
VenkatRam

Reputation: 51

Azure DevOps Pipeline As Code - Validate ARM Template

I am exploring Azure Pipeline As Code and would like to understand how to make use of "deploymentMode" for validating and deploying ARM templates for each Azure environments.

I already have Release Pipelines created in Azure DevOps via Visual Builder for deployment tasks with one main ARM template and multiple paramater JSON files corresponding to each environment in Azure. Each of those pipeline has two stages. One for validation of ARM templates and Second for deployment.

I am now trying to converting those release pipelines to Azure Pipeline as Code in YAML format and would like to create one YAML file consolidating deployment validation tasks (deploymentMode: 'Validation') for each environment first followed by actual deployment (deploymentMode: 'Incremental').

1) Is it a right strategy for carrying out Azure DevOps Pipeline As code for a multi environment release cycle?

2) Will the YAML have two stages (one for validation and another one for deployment) and each stage having many tasks (each task for one environment)?

3) Do I need to create each Azure Environment first in 'Environments' section under Pipelines and configure the virtual machine for managing the deployment of various environments via YAML file?

Thanks.

Upvotes: 0

Views: 1420

Answers (1)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35099

According to your requirements, you could configure virtual machines for each azure environments in the Azure Pipeline -> Environments. Then you could reference the environments in Yaml code.

Here are the steps, you could refer to them.

Step1: Configure virtual machine for each Azure Environments.

Virtual Machines

Note: If the virtual machines are under the same environment, you need to add tags for each virtual machine. Tags can be used to distinguish virtual machines in the same environment.

Step2: You could create the Yaml file and add multiple stages (e.g. validation stage and deployment stage) in it. Each stage can use the environments and contain multiple tasks.

Here is an example:

trigger:
- master


stages:
  - stage: validation 
    jobs:
     - deployment: validation
       displayName: validation ARM
       environment:
        name: testmachine
        resourceType: VirtualMachine
        tags: tag
       strategy:
        runOnce:
          deploy:
            steps:
            - task: AzureResourceManagerTemplateDeployment@3
            ...
            - task: 
            ...
  - stage: deployment
    jobs:
     - deployment: deployment
       displayName: deploy 
       environment: 
        name: testmachine
        resourceType: VirtualMachine
        tags: tag
       strategy:
        runOnce:
          deploy:
            steps:
             - task: AzureResourceManagerTemplateDeployment@3
            ...
            - task: 
            ...

Here are the docs about using multiple stages and virtual machines.

Hope this helps.

Upvotes: 0

Related Questions