更改 Azure 虚拟机的启动诊断存储帐户

Change the boot diagnostic storage account of azure virtual machine

我已经为我的虚拟机启用了诊断存储帐户。现在我想更改诊断存储帐户。我如何在门户/PowerShell 中执行此操作?

我可以看到我们有一个 cmdlet - "Set-AzureRmVMBootDiagnostics",但是,这并没有将诊断存储帐户更新为新帐户。

具体来说: 我当前的诊断存储是 "ibmngeus2",我想更改为 "sqlbackupacct"。

我在虚拟机窗格下的 "Boot Diagnostic" 选项下进行了设置。

在 Azure 门户中,您应该可以单击虚拟机的启动诊断部分,然后单击设置,然后单击存储帐户部分以更改存储帐户。请记住,您要使用的新存储帐户必须位于相同的订阅和位置,否则它不会显示为您可以选择的帐户。

在 PowerShell 中(使用 now-deprecated AzureRM module),您可以这样做:

Get-AzureRmVM <Stuff to filter the VMs you want go here> | Set-AzureRmVMBootDiagnostics -Enable -ResourceGroupName <storage-account-rg> -StorageAccountName <storage-account-name> | Update-AzureRmVM

这将获取 VM 对象、更改设置并应用更改。

例如,要将 所有 VM' 诊断存储帐户更新到 RG mygroup:

中的 bucket
Get-AzureRmVM | Set-AzureRmVMBootDiagnostics -Enable -ResourceGroupName mygroup -StorageAccountName bucket | Update-AzureRmVM

(您可能想要过滤更多...)

对于新的 Az module,命令将更改为:(将应用与上述相同的警告)

Get-AzVM <Stuff to filter the VMs you want go here> | Set-AzVMBootDiagnostic -Enable -ResourceGroupName <storage-account-rg> -StorageAccountName <storage-account-name> | Update-AzVM

Get-AzVM | Set-AzVMBootDiagnostic -Enable -ResourceGroupName mygroup -StorageAccountName bucket | Update-AzVM

(有一个 deprecation warning for the plural version of the command - 这使用了新名称,但警告仍然显示)