Skip to content

az.cmd can't handle arguments with a @() #14783

Description

@mgrandi

Describe the bug

the az.cmd batch script that wraps python.exe and passes in the correct arguments to start azure.cli seemingly cannot handle arguments with a @() in them

my example is with az webapp config connection-string set because that is where I found it, but it most likely impacts every command

example:


PS C:\Users\mgrandi> # verify we have no existing connection strings in our web app
PS C:\Users\mgrandi> az webapp config connection-string list --resource-group "mgrandi-rg" --name "mgrandi-webapp"
[]

PS C:\Users\mgrandi> # try and set a connection string with a `@()` in it as the value
PS C:\Users\mgrandi> az webapp config connection-string set --connection-string-type custom --name mgrandi-webapp --settings "TestKey=@Microsoft.KeyVault(SecretUri=https://html5zombo.com)" --resource-group mgrandi-rg
--resource-group was unexpected at this time.
C:\Users\mgrandi>  "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\\..\python.exe" -IBm azure.cli webapp config connection-string set --connection-string-type custom --name mgrandi-webapp --settings TestKey=@Microsoft.KeyVault(SecretUri=https://html5zombo.com) --resource-group mgrandi-rg
PS C:\Users\mgrandi> # note, the above is the entire output, i did not type that python.exe command

PS C:\Users\mgrandi> # verify still no connection strings
PS C:\Users\mgrandi> az webapp config connection-string list --resource-group "mgrandi-rg" --name "mgrandi-webapp"
[]

PS C:\Users\mgrandi> # try and set it with calling python.exe manually
PS C:\Users\mgrandi> & 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe' -IBm azure.cli webapp config connection-string set --connection-string-type custom --name mgrandi-webapp --settings "TestKey=@Microsoft.KeyVault(SecretUri=https://html5zombo.com)" --resource-group mgrandi-rg
  "TestKey": {
    "type": "Custom",
    "value": "@Microsoft.KeyVault(SecretUri=https://html5zombo.com)"
  }
}

PS C:\Users\mgrandi> # verify we have one connection string now
PS C:\Users\mgrandi> az webapp config connection-string list --resource-group "mgrandi-rg" --name "mgrandi-webapp"
[
  {
    "name": "TestKey",
    "slotSetting": false,
    "type": "Custom",
    "value": "@Microsoft.KeyVault(SecretUri=https://html5zombo.com)"
  }
]


PS C:\Users\mgrandi> # if we get rid of the ending ')' , it works
PS C:\Users\mgrandi> az webapp config connection-string set --connection-string-type custom --name mgrandi-webapp --settings "TestKey2=@Microsoft.KeyVault(SecretUri=https://html5zombo.com" --resource-group mgrandi-rg
{
  "TestKey": {
    "type": "Custom",
    "value": "@Microsoft.KeyVault(SecretUri=https://html5zombo.com)"
  },
  "TestKey2": {
    "type": "Custom",
    "value": "@Microsoft.KeyVault(SecretUri=https://html5zombo.com"
  }
}


PS C:\Users\mgrandi> # should have 2 connection strings now
PS C:\Users\mgrandi> az webapp config connection-string list --resource-group "mgrandi-rg" --name "mgrandi-webapp"
[
  {
    "name": "TestKey2",
    "slotSetting": false,
    "type": "Custom",
    "value": "@Microsoft.KeyVault(SecretUri=https://html5zombo.com"
  },
  {
    "name": "TestKey",
    "slotSetting": false,
    "type": "Custom",
    "value": "@Microsoft.KeyVault(SecretUri=https://html5zombo.com)"
  }
]

Command Name
az webapp config connection-string set

Errors:

after running, you get this output to the powershell terminal

--resource-group was unexpected at this time.
C:\Users\mgrandi>  "C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\\..\python.exe" -IBm azure.cli webapp config connection-string set --connection-string-type custom --name mgrandi-webapp --settings TestKey=@Microsoft.KeyVault(SecretUri=https://html5zombo.com) --resource-group mgrandi-rg

To Reproduce:

Steps to reproduce the behavior. Note that argument values have been redacted, as they may contain sensitive information.

  • run a command with a @() in it

Expected Behavior

it should pass the arguments to the python process and either work or not, depending on the arguments

Environment Summary

Windows-10-10.0.18362-SP0
Python 3.6.6
Installer: MSI

azure-cli 2.9.1

Additional Context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions