0

I am very confused with how to pass arguments to inline script (Powershell task or Azure Cli task) in yaml pipeline. Can somebody explain in simple language with a simple example? I have seen so many articles about passing arguments to Powershell script (.ps1) but not to an inline script. My inline script below is disassociate and Associate a new NSG to an existing subnet:

     - task: AzureCLI@2
        inputs:
          azureSubscription: 'JMeterAzureConnection'
          scriptType: 'ps'
          scriptLocation: 'inlineScript'
          inlineScript: |
           $oldnsgid=az network nsg show -n armmc-nsg -g arm-armmcdemo-rg --query 'subnets[].id' -o tsv
           az network vnet subnet update --ids $oldnsgid --network-security-group "armmc-nsgv1"

When I run this, I get the below error during the pipeline run: ERROR: argument --ids: expected at least one argument

Can you please help me what I need to do with this above issue?

leeharvey1
  • 1,316
  • 9
  • 14
Anil
  • 1
  • 1
  • 6
  • Please [edit] your question to properly format your [mcve]. – JosefZ Aug 28 '21 at 13:59
  • 1
    I don't think output type `tsv` returns a comma-separated list of ids, required for the `--ids` argument. In fact, any newlines returned in `$oldnsgid` might also throw that error. Thus, ensure `$oldnsgid` is formatted correctly (and of the correct type) before using it in `az network vnet subnet update --ids`. I might also try piping the output from `az network nsg show` into the `$oldnsgid` variable. – leeharvey1 Aug 31 '21 at 13:06

0 Answers0