【问题标题】:Change the boot diagnostic storage account of azure virtual machine更改 azure 虚拟机的启动诊断存储帐户
【发布时间】:2018-08-27 23:36:35
【问题描述】:
我已为我的虚拟机启用了诊断存储帐户。现在我想更改诊断存储帐户。如何在门户/PowerShell 中执行此操作?
我可以看到我们有一个 cmdlet -“Set-AzureRmVMBootDiagnostics”,但是,这不会将诊断存储帐户更新为新帐户。
具体来说:
我当前的诊断存储是“ibmngeus2”,我想更改为“sqlbackupacct”。
【问题讨论】:
标签:
azure
azure-storage
azure-virtual-machine
azure-powershell
azureportal
【解决方案1】:
在 Azure 门户中,您应该能够单击虚拟机的启动诊断部分,然后单击设置,然后单击存储帐户部分以更改存储帐户。请记住,您要使用的新存储帐户必须位于相同的订阅和位置,否则它不会显示为您可以选择的帐户。
【解决方案3】:
在 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 - 这使用了新名称,但警告仍然显示)