azure - 运行命令脚本无法识别术语 'az'

标签 azure azure-vm

我尝试运行“az version”的简单命令,该命令将使用运行命令脚本在虚拟机上执行,但出现此错误:术语“az”未被识别为 cmdlet 的名称、函数、脚本文件或可运行程序。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。

但是当我从虚拟机运行此命令时,我将其与远程桌面连接连接,它可以工作,并且我获得包含所有详细信息的“az 版本”。 我还在虚拟机中安装了 AZ 模块。

为了从运行命令脚本中操作“az”命令,我应该做什么?

最佳答案

The term 'az' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

根据错误消息,您似乎尚未安装 az 模块 来运行 az 版本 cmdlet。

What should I do in order to operate 'az' commands from the Run Command Script?

您需要安装 Azure CLI 才能通过门户的运行命令脚本运行 az cmdlet。

您可以使用以下 cmdlet 安装 AzureCLI在预装了 Az 模块的 Windows 计算机上。

$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi

安装 Azure CLI 后,您可以运行 Az 版本 cmdlet 来检查 Az cli 版本。

关于azure - 运行命令脚本无法识别术语 'az',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69615140/

相关文章:

c# - Windows 10 Iot/UWP 上的 Azure 存储库客户端?

azure - 如何在 Azure 上创建可访问 Internet 的私有(private) VM

用于获取 VM 名称和私有(private) IP 地址的 Azure 图形查询

azure - 无法访问部署在 AKS 上的应用程序

azure - 锁定期限到期后如何续订锁定?使用 Azure 服务总线 session 队列

Azure VM 元数据缺失/为空 publicIpAddress

azure - 使用托管标识从 VM 访问 Azure 存储

azure - 搜索文本 "\**"引发错误 "Failed to parse query string."但 "\*"、 "\*~"和 "\~~"有效

c# - 应用程序洞察 - 全局最低严重性级别过滤器?