无法从 Azure 自动化 Runbook 为 Azure 虚拟机设置标签

Unable to set tags for azure virtual machine from Azure automation runbook

我正在使用以下代码为我的 Azure 虚拟机设置标签。当我 运行 在我的笔记本电脑上使用代码时,该代码正在运行(VM 正在被标记)。但是,当我 运行 来自 Azure Automation 运行 的相同代码时,虚拟机没有被标记。未观察到错误或警告 post 运行预订执行。

代码:

$resource_group = "agentinstall-poc"

$tags = (Get-AzureRmResource -ResourceGroupName $resource_group -Name "client-2").Tags

$tags += @{manju="rao"}


Set-AzureRmResource -ResourceGroupName $resource_group -Name "client-2" -ResourceType "Microsoft.Compute/VirtualMachines" -Tag $tags -Force -ApiVersion '2015-06-15'

问题是 Azure 自动化帐户中的 PowerShell 模块默认不更新(创建帐户时它们是 v1.0 ish)。我不得不更新模块,它们开始工作了。