【问题标题】:Unable to set tags for azure virtual machine from Azure automation runbook无法从 Azure 自动化 Runbook 为 azure 虚拟机设置标签
【发布时间】:2018-10-08 04:22:20
【问题描述】:

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

代码:

$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 PS 版本与 azure runbook 使用的版本不同而发生
  • 您是否在 Runbook 中使用您的 RunAs 帐户之一?

标签: azure-virtual-machine azure-powershell azure-automation


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2019-07-17
    • 2021-01-10
    • 1970-01-01
    • 1970-01-01
    • 2020-09-22
    • 1970-01-01
    • 2019-05-17
    • 2021-08-05
    • 1970-01-01
    相关资源
    最近更新 更多