Quantcast
Viewing latest article 12
Browse Latest Browse All 21975

Copy snapshot of a managed disk to same subscription

Please help.I keep getting below this error.

Line |
  32 |  New-AzSnapshot -Snapshot $snapshotConfig -SnapshotName $snapshotName  …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Changing property 'sourceResourceId' is not allowed for existing disk 'Astorage_snapshot'.
     | ErrorCode: BadRequest ErrorMessage: Changing property 'sourceResourceId' is not allowed for
     | existing disk 'AO_storage_snapshot'. ErrorTarget:  StatusCode: 400 ReasonPhrase: Bad Request
     | OperationID : 82e78192-84b2-4264-a540-577d0050e1b4

Here is my script

#Provide the subscription Id of the subscription where snapshot exists
$sourceSubscriptionId='876c1648-5bd4-444b-8eaa-168f576b8457'

#Provide the name of your resource group where snapshot exists
$sourceResourceGroupName='WNS'

#Provide the name of the snapshot
$snapshotName='WNSstorage_snapshot'

#Set the context to the subscription Id where snapshot exists
Select-AzSubscription -SubscriptionId $sourceSubscriptionId

#Get the source snapshot
$snapshot= Get-AzSnapshot -ResourceGroupName $sourceResourceGroupName -Name $snapshotName

#Provide the subscription Id of the subscription where snapshot will be copied to
#If snapshot is copied to the same subscription then you can skip this step
#$targetSubscriptionId='yourTargetSubscriptionId'

#Name of the resource group where snapshot will be copied to
$targetResourceGroupName='WNS'

#Set the context to the subscription Id where snapshot will be copied to
#If snapshot is copied to the same subscription then you can skip this step
#Select-AzSubscription -SubscriptionId $targetSubscriptionId

#We recommend you to store your snapshots in Standard storage to reduce cost. Please use Standard_ZRS in regions where zone redundant storage (ZRS) is available, otherwise use Standard_LRS
$snapshotConfig = New-AzSnapshotConfig -SourceResourceId $snapshot.Id -Location $snapshot.Location -CreateOption Copy -SkuName Standard_LRS

#Create a new snapshot in the target subscription and resource group
New-AzSnapshot -Snapshot $snapshotConfig -SnapshotName $snapshotName -ResourceGroupName $targetResourceGroupName 




Viewing latest article 12
Browse Latest Browse All 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>