列出 Azure VM 时会列出 STDIN,因此出现 "invalid resource id" 错误

STDIN is getting listed while listing Azure VMs, hence getting "invalid resource id" error

我使用以下命令列出并停止了我帐户中的所有虚拟机。 VM 正在列出,但额外的 STDIN 正在列出。 此 STDIN 导致错误 “无效资源 ID”

我该怎么做才能忽略 STDIN??。非常感谢您的帮助。

az vm stop --ids $(az vm list --query "[].id" -o tsv) | grep -v "ABDK" 

谢谢

如果您通过 STDIN 表示 VM 名称并希望停止名称不包含字符串 ABDK 的所有 VM,则可以使用CLI 命令只像这样:

az vm stop --ids $(az vm list --query "[?contains(@.name, 'ABDK')==\`false\`].id" -o tsv)

更新:

如果您 运行 在 Windows PowerShell 中使用 CLI 命令,那么您需要像这样更改命令:

az vm stop --ids $(az vm list --query "[?!contains(@.name, 'ABDK')].id" -o tsv)