I have a yaml pipeline that's simply used to run a script on a subscription. I use the AzurePowerShell@5
task for this.
The problem is I have 22 other subscriptions I need to run the same script on using the exact same script parameters. Only thing different will be the target azureSubscription field. Instead of having 22 blocks of the same task with different subscription names, is there a faster way? Can I throw the names of the 22 subscriptions in an array in the variables section and loop through them somehow? Please advise
stages:
- stage: Deploy
displayName: 'Deploy Pipeline - Access Worker'
jobs:
- job: AccessWorker
displayName: 'Access Worker'
steps:
- download: current
artifact: 'AccessWorker'
- task: AzurePowerShell@5
displayName: 'Access Worker'
inputs:
azurePowerShellVersion: LatestVersion
azureSubscription: 'My Azure Subscription 1'
scriptPath: '$(Pipeline.Workspace)/AccessWorker/.src/Access_Worker/access_worker.ps1'
scriptArguments: >
-RoleDefinitionName 'Reader'
-TagName 'Owner'
- task: AzurePowerShell@5
displayName: 'Access Worker'
inputs:
azurePowerShellVersion: LatestVersion
azureSubscription: 'My Azure Subscription 2'
scriptPath: '$(Pipeline.Workspace)/AccessWorker/.src/Access_Worker/access_worker.ps1'
scriptArguments: >
-RoleDefinitionName 'Reader'
-TagName 'Owner'
- task: AzurePowerShell@5
displayName: 'Access Worker'
inputs:
azurePowerShellVersion: LatestVersion
azureSubscription: 'My Azure Subscription 3'
scriptPath: '$(Pipeline.Workspace)/AccessWorker/.src/Access_Worker/access_worker.ps1'
scriptArguments: >
-RoleDefinitionName 'Reader'
-TagName 'Owner'