Snapshot Disk Access using powershell

Gaurav Singh 130 Reputation points
2023-08-21T10:36:01.59+00:00

Hello Team

Is there a way to set disk access for a snapshot using PowerShell, can you help with commands or any documentations

User's image

Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,529 questions
{count} votes

Accepted answer
  1. Tech-Hyd-1989 5,816 Reputation points
    2023-08-21T10:55:36.92+00:00

    Hello Gaurav Singh

    Yes, you can set disk access for a snapshot using PowerShell. Here are the steps:

    1. Grant access to the disk: $sas = Grant-AzDiskAccess -ResourceGroupName $rg -DiskName $diskName -DurationInSecond $sasExpiryDuration -Access Read
    2. Create a snapshot of the disk: $snapshot = New-AzSnapshot -SourceUri $sas.AccessSAS -SnapshotName $snapshotName -ResourceGroupName $rg
    3. Revoke access to the disk: Revoke-AzDiskAccess -ResourceGroupName $rg -DiskName $diskName

    You can find more information about creating a managed disk from a snapshot with PowerShell in this Microsoft Learn article.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.