Why can't I copy a disk across subscriptions?

Yuta Matsuzaki 0 Reputation points
2023-11-01T02:12:07.7633333+00:00

I would like to ask a question.

I would like to ask about duplicating resources (OS disks, etc.) across Azure subscriptions (different Microsft accounts).

Currently, I exported the template from the copy source, edited it, and ran it from the azure cli with the following command.

$ az deployment group create --name phr-export-copy --resource-group phr-export-prod --template-file /Users/yutamatsuzaki/Desktop/仕事用フォルダ/beyonds/健康日記研究利用/ExportedTemplate-phr-export/template.json
{"status":"Failed","error":{"code":"DeploymentFailed","target":"/subscriptions/d4083897-646b-4388-89ce-ae583987e52a/resourceGroups/phr-export-prod/providers/Microsoft.Resources/deployments/phr-export-copy","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.","details":[{"code":"BadRequest","message":"'disk.supportsHibernation' is not supported for this subscription/region"}]}}


I am waiting for your reply.

Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
650 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Andreas Baumgarten 111.5K Reputation points MVP
    2023-11-01T06:44:18.2133333+00:00

    Hi @Yuta Matsuzaki ,

    generally it is possible to copy managed disks from one Azure Subscription to another Azure Subscription.

    Maybe this helps: Copy managed disks to same or different subscription with CLI


    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards

    Andreas Baumgarten


  2. Ramya Harinarthini_MSFT 5,356 Reputation points Microsoft Employee
    2023-11-06T09:46:04.6766667+00:00

    @Yuta Matsuzaki Welcome to Microsoft Q&A, thank you for posting your here!!

    You can try to Export/Copy managed snapshots as VHD to a storage account in different tenant with below PowerShell.

    Step:1 Create Snapshot of the managed disk.

    User's image

    User's image

    To create a snapshot using the Azure portal, complete these steps.

    1. In the Azure portal, select Create a resource.
    2. Search for and select Snapshot.
    3. In the Snapshot window, select Create. The Create snapshot window appears.
    4. For Resource group, select an existing resource group or enter the name of a new one.
    5. Enter a Name, then select a Region and Snapshot type for the new snapshot.
    6. For Source subscription, select the subscription that contains the managed disk to be backed up.
    7. For Source disk, select the managed disk to snapshot.
    8. For Storage type, select Standard HDD,
    9. Select Review + create.

    Step: 2 Now Copy the managed snapshots as VHD to a destination storage account(General Purpose V2 type) in different tenant with below PowerShell.

    #Provide the subscription Id of the subscription where snapshot is created
    $subscriptionId = "yourSubscriptionId"
    #Provide the name of your resource group where snapshot is created
    $resourceGroupName ="yourResourceGroupName"
    #Provide the snapshot name 
    $snapshotName = "yourSnapshotName"
    #Provide Shared Access Signature (SAS) expiry duration in seconds e.g. 3600.
    #Know more about SAS here: https://docs.microsoft.com/en-us/Az.Storage/storage-dotnet-shared-access-signature-part-1
    $sasExpiryDuration = "3600"
    #Provide storage account name where you want to copy the snapshot. 
    $storageAccountName = "yourstorageaccountName"
    #Name of the storage container where the downloaded snapshot will be stored
    $storageContainerName = "yourstoragecontainername"
    #Provide the key of the storage account where you want to copy snapshot. 
    $storageAccountKey = 'yourStorageAccountKey'
    #Provide the name of the VHD file to which snapshot will be copied.
    $destinationVHDFileName = "yourvhdfilename"
    # Set the context to the subscription Id where Snapshot is created
    Select-AzSubscription -SubscriptionId $SubscriptionId
    #Generate the SAS for the snapshot 
    $sas = Grant-AzSnapshotAccess -ResourceGroupName $ResourceGroupName -SnapshotName $SnapshotName  -DurationInSecond $sasExpiryDuration -Access Read
    #Create the context for the storage account which will be used to copy snapshot to the storage account 
    $destinationContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
    #Copy the snapshot to the storage account 
    Start-AzStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer $storageContainerName -DestContext $destinationContext -DestBlob $destinationVHDFileName
    

    Source Link: https://learn.microsoft.com/en-us/previous-versions/azure/virtual-machines/scripts/virtual-machines-powershell-sample-copy-snapshot-to-storage-account#sample-script

    Step:3 Now create disk from the VHD file

    1. In the Azure portal, select Create a resource.
    2. Search for and select Disks.
    3. In the Disks window, select Create. The Create Disk window appears.
    4. For Resource group, select an existing resource group or enter the name of a new one.
    5. Enter a Name, then select a Region and Source type as Storage blob and source blob and select the storage account location where you have copied the VHD in previous step.
    6. Select Review + create.

    Navigate to Disks

    User's image

    User's image

    User's image

    Hope this helps!
    Kindly let us know if the above helps or you need further assistance on this issue.


    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.

    0 comments No comments

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.