is there any way to loop inside one object type Parameters again in Azuredevops
I am planning to automate tag create/update to resources using Azuredevops pipeline and I decided to use Azure CLI command for the same(not sure if this is the right choice)
So I created a template (template.yaml) file as below.
parameters:
- name: myEnvironments
type: object
- name: tagList
type: object
stages:
- ${{ each environment in parameters.myEnvironments }}:
- stage: Create_Tag_${{ environment }}
displayName: 'Create Tag in ${{ environment }}'
pool:
name: my-spoke
jobs:
- ${{ each tag in parameters.tagList }}:
- ${{ if eq(tag.todeploy, 'yes') }}:
- job: Create_Tag_For_${{ tag.resourcename }_${{ environment }}}
displayName: 'Tag the reource ${{ tag.resourcename }'
condition: eq('${{ tag.todeploy }}', 'yes')
workspace:
clean: all
pool:
name: myspoke
steps:
- task: AzureCLI@2
displayName: "Tag the resource"
inputs:
azureSubscription: ${{ variables.subscription }}
scriptType: 'bash'
scriptLocation: 'inlineScript'
inlineScript: az tag update --resource-id ${{ tag.resourceid }} --operation replace --tags key1=value1 key3=value3
and my pipeline input as below
stages:
- template: template.yaml
parameters:
myEnvironments:
- development
################################################################################################
# Tag List #
################################################################################################
tagList:
- resourcename: myaksservice
todeploy: yes
tagname1: tagvalue of 1
tagname2: tagvalue of 2
.
.
.
.
tagn : tagvalue of n
- resourcename: myappservice
todeploy: yes
tagname1: tagvalue of 1
tagname2: tagvalue of 2
.
.
.
.
tagn : tagvalue of n
- resourcename: mystorageaccount
todeploy: yes
tagname1: tagvalue of 1
tagname2: tagvalue of 2
.
.
.
.
tagn : tagvalue of n
But I was able to loop through the envlist , and the taglist elelments, but not able to loop through the tag values for each resources to crate them at a shot.