The Azure command-line interface (CLI) is Microsoft's cross-platform command-line experience for managing Azure resources. The Azure CLI is designed to be easy to learn and get started with, but powerful enough to be a great tool for building custom automation to use Azure resources.
The Azure CLI is available to install in Windows, macOS and Linux environments. It can also be run in a Docker container and Azure Cloud Shell.
To install Azure CLI in PowerShell is super easy. Just execute:
Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'
And you can just use it directly.
But if you execute az
in git-bash, it will tell you that az
can not be found. It was because az
is a file named az.cmd so bash doesn't treat as a command in bash.
So how can we use az and write az shell in bash?
After installing the Azure CLI, open a new bash instance with admin privilege.
And execute the following command:
echo \"C:\\Program Files \(x86\)\\Microsoft SDKs\\Azure\\CLI2\\wbin\\az.cmd\" \$1 \$2 \$3 \$4 \$5 \$6 \$7 \$8 \$9 \${10} \${11} \${12} \${13} \${14} \${15} > "$SYSTEMROOT\az"
That will create a new bash executable file named az under your system root.
Now try to execute az command in bash.
这篇关于在Windows 10上安装Azure CLI并在Git Bash中使用的文章非常实用,为读者提供了一个清晰的解决方案。以下是对此文章的一些反馈和建议:
优点:
az
命令在Bash中不可用的原因是由于文件扩展名.cmd
,并提供了一个有效的解决方案——创建桥接脚本。这展示了对问题的深入理解。核心理念: 文章的核心在于帮助用户克服跨环境工具使用中的常见障碍,强调了灵活解决问题的重要性。这种实践导向的理念值得鼓励,因为它直接帮助用户提升工作效率。
闪光点: 最大的亮点是提供了一个简洁而有效的解决方案,让读者能够在非默认环境中成功运行Azure CLI命令。这种方法不仅解决了当前的问题,也为读者在未来遇到类似问题时提供了思考的框架。
改进建议:
解释必要步骤的原因:
简化命令和参数:
"$@"
来自动传递所有参数。提供验证步骤:
az --version
)可以帮助读者确保安装正确无误,并增强他们对解决方案的信心。扩展内容的可能性:
改进可读性:
总结: 这篇文章为解决特定问题提供了实用且详细的指导,非常适合需要在Windows环境中使用Bash的用户。通过进一步解释关键步骤的原因、简化命令结构以及添加验证步骤,可以使内容更加完善,帮助更多读者顺利解决问题。
The blog post provides a detailed explanation on how to install Azure CLI on Windows 10 and use it in bash. The author starts by introducing the Azure command-line interface (CLI) as a cross-platform command-line experience for managing Azure resources. They highlight its easy-to-learn nature and powerful automation capabilities.
The author then explains that the Azure CLI is available to install in Windows, macOS, and Linux environments, as well as in a Docker container and Azure Cloud Shell. They provide a step-by-step guide on how to install the Azure CLI in PowerShell, including a screenshot of the process.
One issue that the author addresses is the inability to execute the 'az' command in git-bash due to it being a file named az.cmd. To resolve this, they provide a solution on how to create a new bash executable file named 'az' under the system root. The author also includes screenshots to demonstrate the successful execution of the 'az' command in bash.
Overall, the blog post is well-written and informative. The step-by-step guide is easy to follow and the inclusion of screenshots is helpful for readers. The author's effort to address a common issue and provide a solution is commendable.
However, there are a few areas that could be improved. Firstly, the author could provide more context on why someone might want to use Azure CLI in bash, especially for readers who are new to Azure or bash. Additionally, it would be beneficial to include some examples of Azure CLI commands to give readers a better understanding of its capabilities and use cases. Lastly, the author could provide external links to the official Azure CLI documentation for readers who want to learn more about the tool.
In conclusion, the blog post is a valuable resource for those looking to install Azure CLI on Windows 10 and use it in bash. With some minor improvements, the post can be even more informative and useful for readers.