hex
1
An Azure administrator plans to run a PowerShell script that creates Azure resources.
You need to recommend which computer configuration to use to run the script.
Solution: Run the script from a computer that runs Linux and has the Azure CLI tools installed.
Does this meet the goal?
中文答案和解答
微软又开始夹自己的私货,让大家都用 PS。
hex
2
好的,我们来分析这个问题。
中文答案:
不,这个解决方案不符合目标。
解答 (Explanation):
这个解决方案是错误的,因为它混淆了两种不同的 Azure 命令行工具:Azure PowerShell 和 Azure CLI。
-
脚本语言不匹配:
- 问题中明确指出,管理员计划运行一个 PowerShell 脚本。
- PowerShell 脚本使用的是 Azure PowerShell 模块中的命令(称为 cmdlet),其语法通常是
动词-名词 的格式,例如 New-AzResourceGroup 或 Get-AzVM。
-
工具不匹配:
- 推荐的解决方案是在 Linux 计算机上安装 Azure CLI 工具。
- Azure CLI 是一个独立的命令行工具,它使用不同的命令语法,以
az 开头,例如 az group create 或 az vm show。
- 你不能直接使用 Azure CLI 的环境来运行一个为 Azure PowerShell 编写的脚本。这两种工具的命令和语法是完全不兼容的。
正确的解决方案应该是以下任意一种:
总结:
该解决方案的主要错误在于,它为 PowerShell 脚本推荐了 Azure CLI 工具,这是错误的。运行 PowerShell 脚本需要 PowerShell 环境以及相应的 Azure PowerShell 模块,而不是 Azure CLI。