CLI

How to fix “is not recognized as an internal or external command” in the Azure CLI

If you try to create an Azure Web App using the Azure CLI and specify a runtime using the --runtime argument, you might receive an error message like below:

‘6.0’ is not recognized as an internal or external command,
operable program or batch file.

Your error message might differ slightly depending on which runtime version you specified. You can list all available values using the az webapp list-runtimes command:

[
  "aspnet|V4.8",
  "aspnet|V3.5",
  "DOTNETCORE|2.1",
  "DOTNETCORE|3.1",
  "DOTNET|5.0",
  "DOTNET|6.0",
  "node|10.6",
  "node|10.10",
  "node|10.14",
  "node|12-lts",
  "node|14-lts",
  "php|7.4",
  "java|1.8|Tomcat|7.0",
  "java|1.8|Tomcat|8.5",
  "java|1.8|Tomcat|9.0",
  "java|1.8|Java SE|8",
  "java|7|Tomcat|7.0",<
  "java|7|Tomcat|8.5",
  "java|7|Tomcat|9.0",
  "java|7|Java SE|8",
  "java|11|Tomcat|7.0",
  "java|11|Tomcat|8.5",
  "java|11|Tomcat|9.0",
  "java|11|Java SE|8"
]

I tried to figure out how PowerShell passes the following statement to the Azure CLI using Process Monitor:

az webapp create `
    --resource-group about-azure-aztest-rg `
    --plan about-azure-aztes-asp `
    --name about-azure-aztes-app `
    --runtime "DOTNET|6.0"

First, PowerShell performs a Process Create operation and passes our command to the az.cmd:

“08:32:02,6205944″,”powershell.exe”,”31532″,”Process Create”,”C:\WINDOWS\system32\cmd.exe”,”SUCCESS”,”PID: 11232, Command line: C:\WINDOWS\system32\cmd.exe /c “”””C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd”” webapp create –resource-group about-azure-aztest-rg –plan about-azure-aztes-asp –name about-azure-aztes-app –runtime DOTNET|6.0“””

Then cmd.exe performs a Process Start – we still have the expected runtime identifier:

“08:32:02,6206024″,”cmd.exe”,”11232″,”Process Start”,””,”SUCCESS”,”Parent PID: 31532, Command line: C:\WINDOWS\system32\cmd.exe /c “”””C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd”” webapp create –resource-group about-azure-aztest-rg –plan about-azure-aztes-asp –name about-azure-aztes-app –runtime DOTNET|6.0“”

In the third step, cmd.exe initiates a Process Create, but the |6.0 string in the identifier is now missing:

“08:32:02,6362157″,”cmd.exe”,”11232″,”Process Create”,”C:\WINDOWS\system32\cmd.exe”,”SUCCESS”,”PID: 35708, Command line: C:\WINDOWS\system32\cmd.exe /S /D /c”” “”C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd”” webapp create –resource-group about-azure-aztest-rg –plan about-azure-aztes-asp –name about-azure-aztes-app –runtime DOTNET“””

Solution

There are lots of potential workarounds out there including using the PowerShell stop-parsing symbol (–%), surrounding the string in single quotes, or using escaped double quotes. However, none of these solutions work on every platform for both bash and PowerShell.

The most reliable solution is to simply replace the pipe delimiter | with a colon :

node|14-lts => node:14-lts