Use Parameters With Azure Pipelines

This Azure Pipelines blog post will show how to use runtime parameters in Azure Pipelines YAML CI\CD pipelines.

Azure Pipelines are one of the core services in Azure DevOps, and it provide CI\CD automation runbooks for the build and deployment of applications and workloads.

Azure Pipelines are YAML-based configuration files that help us build and deploy applications like Docker images, .NET, and Azure infrastructure services.


Parameters allow us to pass and manage values during the pipeline runtime but also. Let the users select values using a checkbox or a drop-down list. In the following example, I use the Azure PowerShell task with parameters.

At the top of the pipeline, I defined two parameters: one for the Resource Group Name and the second for the VM name, which has multiple values.

- name: ResourceGroupName
  type: string
  default: CloudPC
- name: VMName
  type: string
  - win11-vm
  - win11-vm02

To use the parameters in the pipeline, I need to use the following syntax to access them: ${{ }}. In my case, the task with the parameters will look like.

- task: AzurePowerShell@5
    azureSubscription: 'Pay-As-You-Go'
    ScriptType: 'InlineScript'
    Inline: 'get-azvm -ResourceGroupName "${{parameters.ResourceGroupName}}" -name "${{parameters.VMName}}"'
    azurePowerShellVersion: 'LatestVersion'

When running the pipeline, the following options will appear and let us select the VNName value. The Resource Group can be changed but has a default value, which is needed when declaring a parameter.

2 thoughts on “Use Parameters With Azure Pipelines”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.