I am trying to get certain details of disks attached to a VM in azure using Azure python SDK. I came to know that:
A VM will have two disks attached to it when created:
- OS disk (OS disks are attached with a drive letter of C: by default)
- Temporary disk (Temporary disks are attached with a drive letter of D: by default)
Apart from these we can add extra data disks to a VM, if we need. The problem is when we add a Data disk, we don't know which letter is attached to that disk.
I get the disk utilization details for a disk along with it's drive letter from Azure log analytics but i don't get the disk name in that logs. so, i am not able to identify which disk's utilization logs they are.
Using Azure's Python sdk, I am able to get the disk name and disk size but i am not able to get the Disk letter.
I want to know the letter of a disk so that i get to know the utilization details of a particular disk.
Can someone please help me with this?
Best Answer
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:
You will get the list of drives with their drive number (slot) and a path present in your VM.
Note : The disk#000001# is the LUN part. In this case it's LUN 1.
Or
Step -2 : Now to get the details of the Azure Disks you can run the below command in CLI:
Or
Using Powershell:
Or
Using Python SDK:
Reference:
How to map Azure Disks to Windows VM guest disks - Azure Virtual Machines | Microsoft Docs