How to find if a Virtual Machine is using managed/Unmanaged disks in Azure
Asked Answered
P

8

9

Is there a way in Azure to find if a VM in azure created to with Managed/Unmanaged disks?

Platonism answered 14/4, 2017 at 19:43 Comment(0)
H
10

We can use PowerShell to list the information of Azure VM.

Here is the Unmanaged disks VM output:

PS C:\Users> (get-azurermvm -ResourceGroupName jasonvn -Name jasonvm1).StorageProfile.OsDisk
 StorageProfile and NetworkProfile, respectively.


OsType             : Linux
EncryptionSettings :
Name               : jasonvm1
Vhd                : Microsoft.Azure.Management.Compute.Models.VirtualHardDisk
Image              :
Caching            : ReadWrite
CreateOption       : FromImage
DiskSizeGB         :
ManagedDisk        :

Here is the Managed disks VM output:

PS C:\Users> (get-azurermvm -ResourceGroupName jasonvn -Name jasonvm).StorageProfile.OsDisk
 StorageProfile and NetworkProfile, respectively.


OsType             : Linux
EncryptionSettings :
Name               : jasonvm
Vhd                :
Image              :
Caching            : ReadWrite
CreateOption       : FromImage
DiskSizeGB         : 30
ManagedDisk        : Microsoft.Azure.Management.Compute.Models.ManagedDiskParameters

Another way, we can use Azure new portal to check automation script to find it:

enter image description here

Hylophagous answered 15/4, 2017 at 0:15 Comment(1)
Please let me know if you would like further assistance.Hylophagous
S
11

This information is available in another area of the Azure portal as well. Go to the 'Virtual machines' list in the portal, click the 'Columns' button, and add a column called "Uses Managed Disks".

Smallage answered 18/11, 2017 at 10:40 Comment(0)
H
10

We can use PowerShell to list the information of Azure VM.

Here is the Unmanaged disks VM output:

PS C:\Users> (get-azurermvm -ResourceGroupName jasonvn -Name jasonvm1).StorageProfile.OsDisk
 StorageProfile and NetworkProfile, respectively.


OsType             : Linux
EncryptionSettings :
Name               : jasonvm1
Vhd                : Microsoft.Azure.Management.Compute.Models.VirtualHardDisk
Image              :
Caching            : ReadWrite
CreateOption       : FromImage
DiskSizeGB         :
ManagedDisk        :

Here is the Managed disks VM output:

PS C:\Users> (get-azurermvm -ResourceGroupName jasonvn -Name jasonvm).StorageProfile.OsDisk
 StorageProfile and NetworkProfile, respectively.


OsType             : Linux
EncryptionSettings :
Name               : jasonvm
Vhd                :
Image              :
Caching            : ReadWrite
CreateOption       : FromImage
DiskSizeGB         : 30
ManagedDisk        : Microsoft.Azure.Management.Compute.Models.ManagedDiskParameters

Another way, we can use Azure new portal to check automation script to find it:

enter image description here

Hylophagous answered 15/4, 2017 at 0:15 Comment(1)
Please let me know if you would like further assistance.Hylophagous
M
2

Similar to Scottge's answer, but if you just go to the VM > Disks > select the disk, it opens a blade showing the disk information. At the top of this blade, "(unmanaged)" is displayed after the disk name if it is unmanaged. Nothing is displayed if it is managed.

Malleolus answered 10/7, 2018 at 2:49 Comment(0)
E
1

To add to Jason Ye's answer, you can also run a similar command in Azure CLI 2.0. The command is:

az vm show -g rg_name -n vm_name

And the output for non-managed disk is:

  ...
  "osDisk": {
      "caching": "ReadWrite",
      "createOption": "fromImage",
      "diskSizeGb": 32,
      "encryptionSettings": null,
      "image": null,
      "managedDisk": null,
      "name": "rhel-un",
      "osType": "Linux",
      "vhd": {
        "uri": "https://storageaccountname.blob.core.windows.net/vhds/....vhd"
      }

And for managed disk:

...
"osDisk": {
  "caching": "ReadWrite",
  "createOption": "fromImage",
  "diskSizeGb": 32,
  "encryptionSettings": null,
  "image": null,
  "managedDisk": {
    "id": "/subscriptions/sub_id/resourceGroups/rg_name/providers/Microsoft.Compute/disks/rhel_OsDisk_1...",
    "resourceGroup": "rg_name",
    "storageAccountType": "Standard_LRS"
  },
  "name": "rhel_OsDisk_1...",
  "osType": "Linux",
  "vhd": null
}
Esculent answered 19/9, 2017 at 18:14 Comment(0)
D
1

If looking for OS disk, this will work. Can mod for data disk.

$VmName="vmNameHere" #vmNameHere
$RGName="rgnameHere" #resourceGroupname

if((Get-AzureRmVM -Name $VmName -ResourceGroupName $RGName).StorageProfile.OsDisk.ManagedDisk -like ''){"$vmName,OS Disk,Unmanaged"}else{"$Vmname,OS Disk,Managed"}
Diahann answered 26/2, 2018 at 18:22 Comment(0)
E
0

Here is one way which I found, follow the below steps to determine the disk type:

  • Login to the Azure portal.
  • Select the VM in question. Select the
  • disk to check. Look at the disk's URL.

An Unmanaged Disk's URL will look like:

/storage_account_name.blob.core.windows.net/VM_name/VM_name.vhd

A Managed Disk's URL will look like:

/subscriptions/0cbded86-6088-430c-a320-xxxxxxxxxxxx/resourceGroups/Resource_Group_name/providers/Microsoft.Compute/disks/Disk_name

Etam answered 10/1, 2022 at 0:14 Comment(0)
C
0

This thread is a few years old, but I've found a better way to check them all at once using Powershell. Microsoft just emailed out that they're retiring unmanaged disks in 2 years, so hopefully this helps others before then!

This will try to connect to Azure, install the module if needed, get all your VMs, and list out the disk name and ManagedDisk field. If you have a lot of VMs I'd suggest adding a filter to only show when the ManagedDisk field is empty.

Try{Get-AzSubscription > Out-Null}
Catch{
    Try{Get-Module -ListAvailable -Name AZ.compute}
    Catch{
        Write-Host "Azure module does not exist, installing, importing, and connecting" -ForegroundColor Cyan
        [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
        Install-Module Az -Repository PSGallery -Force
    }
    Finally{
        Import-Module AZ

        Write-Verbose "Enter your Azure Admin Account creds" -ForegroundColor Cyan

        Connect-AzAccount
        Set-AzContext -Subscription "fe95db19-b91b-4492-990e-8c7c9ac355a4"
    }
}
Finally{
    Write-Host "You are connected to Azure" -ForegroundColor Cyan
}

#Get All VMs
$VMs = Get-AZVM 

#Go through each VM one at a time
ForEach($VM in $VMs){
    $VM.StorageProfile.OsDisk | Select Name,ManagedDisk
    $VM.StorageProfile.DataDisks | Select Name,ManagedDisk
}
Curtain answered 14/9, 2022 at 14:5 Comment(0)
D
0

It is shown in Virtual Machine JSON preview as well under osDisk

Dilatory answered 22/1, 2023 at 14:57 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Amoy

© 2022 - 2024 — McMap. All rights reserved.