简体   繁体   中英

Azure DevOps (az apim nv create) cant able to create variable dynamically

I'm trying to create multiple values using "az apim nv create" command using loop, but its not working.

with the single command (without using variable in --value) we can able to create, but the same is not working when we use variable in --value.

demo="fromkey fromkey1"
for list in $demo
do
az apim nv create --service-name ABC -g XYZ --secret true --named-value-id $list --display-name $list --value $list
done

Can someone please help on this.

Azure DevOps (az apim nv create) cant able to create variable dynamically

You could try below scripts in the bash task:

- bash: |
    demo=( "fromkey" "fromkey1" )
    for list in ${demo[@]}; do
      az apim nv create --service-name ABC -g XYZ --secret true --named-value-id $list --display-name $list --value $list
    done
  displayName: 'az apim nv create'
  env:
    AZURE_DEVOPS_EXT_PAT: $(System.AccessToken)  

Update:

I this can be possible with Shell script? if Yes then can you please share shell script commands

declare -a demo=("fromkey1" "fromkey2" "fromkey3")

for list in "${demo[@]}"
do
   az apim nv create --service-name ABC -g XYZ --secret true --named-value-id $list --display-name $list --value $list
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM