How to find if a virtual machine uses managed / unmanaged disks in Azure

Is there a way in Azure to find if a virtual machine in azure is created with managed / unmanaged disks?

+4
source share
4 answers

We can use PowerShell to display information about Azure VM.

Below is the output of Unmanaged Disks :

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        :

The following is the output of Managed Disks :

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

In another way, we can use the new Azure portal to test the automation script to find it:

enter image description here

+7
source

Azure. " " , "" " ".

+2

To add an answer to Jason Ye, you can also run a similar command in Azure CLI 2.0. Team:

az vm show -g rg_name -n vm_name

And the output for an unmanaged disk:

  ...
  "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 the 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
}
0
source

If you are looking for an OS drive, this will work. Modem 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"}
0
source

Source: https://habr.com/ru/post/1674853/


All Articles