Reputation: 3433
Sometimes I have a problem with running various commands (I'm using Git Bash, if that matters). For example, when I try to execute:
az container exec --resource-group My-RG --name influxdb-container --exec-command "/bin/bash"
The command above should normally "SSH" me into the Azure Container Instance. However, instead, I'm getting:
'C:\Program' is not recognized as an internal or external command, operable program or batch file.
I found a lot of posts on SO with such error, however, the issue in those posts was about invoking commands without proper quoting of "C:\Program Files". In my case, however, there is no "Program Files" anywhere, so I have a hard time figuring out what is wrong.
az
command is recognized by the shell, when I invoke it alone, I'm getting proper response from Azure CLI.
I am also getting a similar error when running docker commands sometimes. Unfortunately, right now I do not know which command exactly would cause that.
This issue happens only on my Windows machine. When I run the command from Linux or macOS, it just works.
And the proof that az
works:
Upvotes: 3
Views: 2394
Reputation: 39454
I had a very similar issue but with AWS sam.cmd
command.
Ended up solving it by editing my environment variables -> editing the "Path" system variable and using the "short path" to this command (which doesn't have any spaces) instead of the "long path". (A nice utility called Path Copy Copy helped with doing this.)
Changed from: C:\Program Files\Amazon\AWSSAMCLI\bin
to: C:\PROGRA~1\Amazon\AWSSAM~1\bin
Would suspect doing something similar for the az
command would have solved your issue. Suspect it may be something to do with Git Bash automatically putting quotes around the whole command when the path to the executable has whitespace in it.
Upvotes: 0
Reputation: 31452
There are some things different between Linux and Windows for Azure CLI. But still, there is some configuration that is the same. You can also set the environment variable PATH
the same as in Linux.
In Linux, the az
command is in the path /usr/bin/
, and this path is also set the environment variable PATH
. Then the az
command can be recognized by the shell. So the same in Windows, you can also append the path of the Azure CLI in the environment variable PATH
. The screenshot shows the configuration on my side:
Then the az
command can also be recognized by the CMD:
But you can also use WSL in the Windows and the same experience of the Azure CLI as in Linux.
Upvotes: 1