As mentioned in the comment , Its not possible to map Azure Disks with Windows Guest Disk in a Single Script.
You can use the LUN for the Disk to get mapping of the two .
Step -1 : Remote into the VM , open powershell and run the below command:
`get-disk | format-list number, path`
You will get the list of drives with their drive number (slot) and a path present in your VM.
For the data disks the path will look something like:
?\scsi#disk&ven_msft&prod_virtual_disk#000001
#{57f56307-b6bf-19d0-94f2-00a0c91efb8b}
Note : The disk#000001# is the LUN part. In this case it's LUN 1.
Or
- Connect to the VM and open Disk Management
- In the lower pane, right-click any of the Disks and choose
"Properties"
- The LUN will be listed in the "Location" property on the "General"
tab
Step -2 : Now to get the details of the Azure Disks you can run the below
command in CLI:
`az vm show -g myResourceGroup -n myVM --query "storageProfile.dataDisks"`
Or
Using Powershell:
$vm = Get-AzVM -ResourceGroupName myResourceGroup -Name myVM
$vm.StorageProfile.DataDisks | ft
Or
Using Python SDK:
from azure.mgmt.compute import ComputeManagementClient
from azure.identity import AzureCliCredential
credential = AzureCliCredential()
rg = 'ResourceGroupName'
name = 'VMName'
subscription_id = "SubID"
compute_client = ComputeManagementClient(credential, subscription_id)
vm = compute_client.virtual_machines.get(rg,name)
##get OS disk size(GB)
print (vm.storage_profile.os_disk.name,vm.storage_profile.os_disk.disk_size_gb)
datadisks = vm.storage_profile.data_disks
##get data disk size(GB)
for i in datadisks:
print (i.lun,i.name,i.disk_size_gb)
Reference:
How to map Azure Disks to Windows VM guest disks - Azure Virtual Machines | Microsoft Docs
Best Answer