What changes would lead to number of data disks changes in the VM/Image?

Varma 1,255 Reputation points
2024-01-15T13:53:36.83+00:00
  1. What changes would lead to number of data disks changes in the VM/Image?
  2. is there any PS command to list the images with count of data disks, these images are present in the one of build image gallery
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
590 questions
{count} votes

Accepted answer
  1. Anand Prakash Yadav 7,775 Reputation points Microsoft Vendor
    2024-01-16T11:55:15.1733333+00:00

    Hello Varma, Thank you for posting your query here!

    Can you please check the below PowerShell script:

    $resourceGroupName = "<Your-Resource-Group-Name>"

    $galleryName = "<Your-Gallery-Name>"

    $imageDefinitionName = "<Your-Image-Definition-Name>"

    $imageVersionName = "<Your-Image-Version-Name>"

    $imageVersion = Get-AzGalleryImageVersion -ResourceGroupName $resourceGroupName -GalleryName $galleryName -GalleryImageDefinitionName $imageDefinitionName -Name $imageVersionName

    $dataDiskCount = $imageVersion.StorageProfile.DataDiskImages.Count

    Write-Output "Image Version: $($imageVersion.Name)"

    Write-Output "Number of Data Disks: $dataDiskCount"

    Please let us know if you have any further queries. I’m happy to assist you further.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Sumarigo-MSFT 44,906 Reputation points Microsoft Employee
    2024-02-02T08:29:27.9366667+00:00

    @Varma Welcome to Microsoft Q&A Forum, Thank you for posting your query here!
    Adding more information to the above response.

    1. There are several changes that can lead to a change in the number of data disks in an Azure VM or image. Some of these changes include:

    Resizing the VM: When you resize a VM to a different size, the number of data disks that can be attached to the VM may change. For example, if you resize a VM to a smaller size, you may not be able to attach as many data disks as you could with the previous size. Adding or removing data disks: Adding or removing data disks to a VM can change the number of data disks associated with the VM. Creating a new VM from an image: When you create a new VM from an image, the number of data disks associated with the new VM may be different from the original VM. Updating the VM image: If you update the VM image, the number of data disks associated with the image may change.

    1. Changing the storage account type: Changing the storage account type associated with a VM can affect the number of data disks that can be attached to the VM
    2. You can use the Azure CLI command az sig image-version list to list the images in a gallery. Here is an example of how to use this command: az sig image-version

    Please replace MyGallery, MyImageDefinition, and MyResourceGroup with your actual gallery name, image definition, and resource group respectively.

    After you have the list of images, you can count the data disks for each image using additional commands like az stack-hci-vm disk list or az disk list. Please note that you would need to iterate over each image and count the disks separately.

    az sig image-version list --gallery-name MyGallery --gallery-image-definition MyImageDefinition --resource-group MyResourceGroup
    
    
    
    $imageList = Get-AzGalleryImage -ResourceGroupName $resourceGroup -GalleryName $galleryName
    

    Please let us know if you have any further queries. I’m happy to assist you further.     

    ---Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.