Copy and distribute managed disk snapshots across multiple Azure Subscriptions
A managed disk snapshot is created from data disks that are attached to the source virtual machine.
Name | Description |
---|---|
SourceVM | Virtual Machine source for data disks to snapshot |
snapshotRG | Resource Group to store snapshots |
# Required Parameters
param (
# Default
[parameter(position=0, mandatory=$true)][string]$sourceVm,
[parameter(position=1, mandatory=$true)][string]$snapshotRG,
)
Configuration options from the original data disk will be recorded as tags on the new snapshot.
Tag | Description |
---|---|
LUN | Assigned LUN from sourceVM |
diskSKU | Managed disk SKU |
diskSizeGB | Managed disk size |
SourceVM | Source VM Name |
Copy a managed disk snapshot between Azure subscriptions.
Note: The user running this script needs to have appropriate permissions to create and manage snapshots in the source and target subscriptions.
Name | Description |
---|---|
sourceSubscriptionID | Source Azure Subscription ID |
targetSubscriptionID | Target remote Azure Subscription ID |
snapshotRg | Resource Group where source snapshots are located |
targetResourceGroupName | Remote Resource Group to copy snapshots |
# Required Parameters
[parameter(position=0, mandatory=$true)][string]$sourceSubscriptionID = "",
[parameter(position=1, mandatory=$true)][string]$targetSubscriptionID = "",
[parameter(position=2, mandatory=$true)][string]$snapshotRg = "",
[parameter(position=3, mandatory=$true)][string]$targetResourceGroupName = ""
The source snapshot will be used to create a new managed disk (per VM). The new disk will be attached to the target VM.
Name | Description |
---|---|
snapshotRGName | Resource Group where snapshots are stored |
targetVmName | Target VM to attach disk |
targetVmResourceGroupName | optional: Target VM Resource Group Name |
# Required Parameters
param (
[parameter(position=1, mandatory=$true)][string]$snapshotRGName,
[parameter(position=2, Mandatory=$true)][string]$targetVmName,
[parameter(position=3, Mandatory=$false)][string]$targetVmResourceGroupName
)
Configuration options stored as Tags on the source snapshot will be used to define options for creating and attaching the new disk.
Tag | Description |
---|---|
LUN | Assigned LUN from sourceVM |
diskSKU | Managed disk SKU |
diskSizeGB | Managed disk size |
SourceVM | Source VM Name |