azureaz

az cli fails with 'appXXXdeploycr.azurecr.io' is not recognized as an internal or external command, operable program or batch file


All I am trying to do is to run the following command in PS

az webapp config set -g 'appXXX-dfpg-dev4-web-eastus2' -n 'appXXX-dfpg-dev4-web-eastus2-backoffice-apsvc'  --linux-fx-version 'DOCKER|appXXXdeploycr.azurecr.io/dfpg/backoffice:1.0.20184.1'

I am getting back

'appXXXdeploycr.azurecr.io' is not recognized as an internal or external command,
operable program or batch file.

Initialy I though that PS misinterprets | as a pipeline concatination so I escaped it with ` but it didn't help


Solution

  • I know that this answer is late, but for future references I will provide my input. What you are experiencing is pipe (|) being interpreted by PowerShell while parsing the arguments AZ cli. You can force PowerShell to do minimal parsing using the Stop-Parsing symbol --% (see https://learn.microsoft.com/en-us/cli/azure/use-cli-effectively#pass-arguments)

    az --% webapp config set -g 'appXXX-dfpg-dev4-web-eastus2' -n 'appXXX-dfpg-dev4-web-eastus2-backoffice-apsvc'  --linux-fx-version 'DOCKER|appXXXdeploycr.azurecr.io/dfpg/backoffice:1.0.20184.1'
    

    This will stop you from using variables in your statement. So another solution is to use escaped quotes around the value you are providing to AZ (see Azure CLI: Unable to escape pipe character (|) in Windows PowerShell)

    az webapp config set -g 'appXXX-dfpg-dev4-web-eastus2' -n 'appXXX-dfpg-dev4-web-eastus2-backoffice-apsvc'  --linux-fx-version '"DOCKER|appXXXdeploycr.azurecr.io/dfpg/backoffice:1.0.20184.1"'
    

    And you can even use variables inside your version

    $inc = "1"
    $version="`"DOCKER|appXXXdeploycr.azurecr.io/dfpg/backoffice:1.0.20184.$inc`""
    az webapp config set -g 'appXXX-dfpg-dev4-web-eastus2' -n 'appXXX-dfpg-dev4-web-eastus2-backoffice-apsvc'  --linux-fx-version $version