简体   繁体   中英

Managed azure storage account via powershell for VM

I am trying to create a VM using AZ PowerShell but I get an error.

New-AzVM : Using a client owned (un-managed) storage account for boot diagnostics is not supported for VMs.
ErrorCode: OperationNotAllowed
ErrorMessage: Using a client owned (un-managed) storage account for boot diagnostics is not supported for VMs.
ErrorTarget:
StatusCode: 409
ReasonPhrase: Conflict
OperationID : 
+         New-AzVM -ResourceGroupName $primaryResourceGroupName -Locati ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzVM], ComputeCloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.NewAzureVMCommand

I am wondering

  1. how to check if my storage account is managed or unmanaged
  2. how to make the storage account to be managed?

To more specific to your ask

  • 1. how to check if my storage account is managed or unmanaged

Run the following cmd to check whether the VM OS DISK is managed or unmanaged:

(get-azurermvm -ResourceGroupName NAME -Name yourvm).StorageProfile.OsDisk

Here is the sample screenshot with unmanaged disk VM.

在此处输入图像描述

  • 2.how to make the storage account to be managed?

Now we need to stop the VM to convert Unmanaged to managed disk

Run the below cmd to STOP the VM

$rgName = "myResourceGroup"
$vmName = "myVM"
Stop-AzVM -ResourceGroupName $rgName -Name $vmName -Force

在此处输入图像描述

  • Then Run this cmd to convert to Managed disk

    ConvertTo-AzVMManagedDisk -ResourceGroupName $rgName -VMName $vmName

Here are the reference output of successfully converted: 在此处输入图像描述

在此处输入图像描述

For more information please refer this MS DOC: Create VM & Convert Single Instance VM

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM