Answered by:
Copy snapshot of a managed disk to same subscription

Question
-
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-577d0050e1b4Here 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
- Edited by Dennis Mutua Tuesday, July 28, 2020 2:59 PM
Saturday, July 25, 2020 2:12 PM
Answers
-
Hi Dennis,
I can see your source and target is same in PS code block, could you please crate a new RG in same location for testing also in same subscription and change this to as target RG in PS code.
What is happening here, It is trying to copy same snapshot in same subscription and RG with property change. So Azure is preventing PS to do the same.
Lets give it a try and let me know if this works or still no luck, just my two cents.
Cheers, Gourav Please remember to mark the replies as answers if it helped.
- Proposed as answer by Yang YoungMicrosoft contingent staff Tuesday, July 28, 2020 1:41 AM
- Marked as answer by Dennis Mutua Tuesday, July 28, 2020 5:34 PM
Monday, July 27, 2020 6:49 AM
All replies
-
Hi Dennis,
I can see your source and target is same in PS code block, could you please crate a new RG in same location for testing also in same subscription and change this to as target RG in PS code.
What is happening here, It is trying to copy same snapshot in same subscription and RG with property change. So Azure is preventing PS to do the same.
Lets give it a try and let me know if this works or still no luck, just my two cents.
Cheers, Gourav Please remember to mark the replies as answers if it helped.
- Proposed as answer by Yang YoungMicrosoft contingent staff Tuesday, July 28, 2020 1:41 AM
- Marked as answer by Dennis Mutua Tuesday, July 28, 2020 5:34 PM
Monday, July 27, 2020 6:49 AM -
Thanks Gourav. This worked.Tuesday, July 28, 2020 5:34 PM