How to identify disks in azure are managed or unmanaged and also way to convert managed disk to unmanaged to get ready to have it under Av set

GVS 156 Reputation points
2021-01-11T17:50:11.563+00:00

How to identify disks in azure are managed or unmanaged and also way to convert managed disk to unmanaged to get ready to have it under Av set

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,014 questions
{count} vote

1 answer

Sort by: Most helpful
  1. shiva patpi 13,366 Reputation points Microsoft Employee Moderator
    2021-01-11T20:17:45.933+00:00

    Hello @AzureisMyCareer-5423 ,
    Thanks for your query!
    There are multiple ways to identify whether a disk is managed or unmanaged disk.

    Using PowerShell Or Azure CLI commands or Using the Azure Portal:-

    Lets say you have a VM named "ftp" in ResourceGroup "ftp" , then you want to identify whether the disk used by "ftp" VM is a managed or Unmanaged.

    1) Open Azure CLI command line
    2) Run the command az vm show -g ftp -n ftp

    Sample output:
    "osDisk": {
    "caching": "ReadWrite",
    "createOption": "FromImage",
    "diffDiskSettings": null,
    "diskSizeGb": null,
    "encryptionSettings": null,
    "image": null,
    "managedDisk": {
    "diskEncryptionSet": null,
    "id": "/subscriptions/subid/resourceGroups/ftp/providers/Microsoft.Compute/disks/ftp_OsDisk_1_74aad09cef61455c8f643b8621c33c28",
    "resourceGroup": "ftp",
    "storageAccountType": null
    },
    "name": "ftp_OsDisk_1_74aad09cef61455c8f643b8621c33c28",
    "osType": "Windows",
    "vhd": null,
    "writeAcceleratorEnabled": false
    }

    3) In the above output : if you see VHD is null - This confirms it is a Managed Disk
    4) in the VHD section if you see some URI - This confirms it is an Unmanaged disk.
    Sample Output:
    "osDisk": {
    "vhd": {
    "uri": "https://storageaccountname.blob.core.windows.net/vhds/....vhd"
    }

    Here are couple of additional articles: https://stackoverflow.com/questions/43418208/how-to-find-if-a-virtual-machine-is-using-managed-unmanaged-disks-in-azure
    https://renjithmenon.com/azure-managed-disks-vs-unmanaged-disks-or-storage-accounts/

    To convert from Managed disk to UnManaged Disk use the below powershell commands:

    Connect to the Azure Subscription

    1) Connect-AzAccount

    Set the corresponding context (if you have multiple subscriptions , make sure to identify in which sub )

    2) Set-AzContext -SubscriptionId "EnterSubID"

    get the Managed Disk reference

    3) $sas = Grant-AzDiskAccess -resourceGroupName "ResourceGroupName" -DiskName "ManagedDiskName" -DurationInSecond 36000 -Access read

    Create the storage account context

    make sure to identify in which storage account you want to storage the .vhd file (i.e. UnManaged disk)

    Grab the storage account key using the azure portal

    4) $context = New-AzStorageContext -StorageAccountName "storageaccountname" -StorageAccountKey "StorageAccountKey"

    Below command will copy the Managed Disk as .vhd to the container (Make sure to create a container in the storage account)

    5) Start-AzStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestinationContainer "containername" -DestinationContext $context -DestBlob "UnmanagedDiskName.vhd"
    6) You can use the new .vhd file storage in the storage account container to create the VMs

    kindly make sure to "Accept the Answer" if the above steps helps you , so that it can help out the whole community out there.

    2 people found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.