Azure Storage Container

Error_401 86 Reputation points
2021-03-01T07:31:29.487+00:00

Hi,

Can anybody tell me how do I upload VHD files within Azure cloud to Storage Container?

I have around 19TB of different disk storages which I have detached from different VMs and now I want to upload them to Azure Storage Container and Archive them.

72863-image.png

I cannot find any option on Azure Portal or Azure Storage Explorer Application (for Windows).
If there is any such script please let me know.

Thanks

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,834 questions
Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
587 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. deherman-MSFT 34,686 Reputation points Microsoft Employee
    2021-03-03T23:21:03.39+00:00

    @Error_401

    The script includes an option to use azcopy I have modified line 47 below, please check to see if it works for you.

    #Provide the subscription Id of the subscription where managed disk is created  
    $subscriptionId = "yourSubscriptionId"  
      
    #Provide the name of your resource group where managed is created  
    $resourceGroupName ="yourResourceGroupName"  
      
    #Provide the managed disk name   
    $diskName = "yourDiskName"  
      
    #Provide Shared Access Signature (SAS) expiry duration in seconds e.g. 3600.  
    #Know more about SAS here: https://learn.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 underlying VHD of the managed disk.   
    $storageAccountName = "yourstorageaccountName"  
      
    #Name of the storage container where the downloaded VHD will be stored  
    $storageContainerName = "yourstoragecontainername"  
      
    #Provide the key of the storage account where you want to copy the VHD of the managed disk.   
    $storageAccountKey = 'yourStorageAccountKey'  
      
    #Provide the name of the destination VHD file to which the VHD of the managed disk will be copied.  
    $destinationVHDFileName = "yourvhdfilename"  
      
    #Set the value to 1 to use AzCopy tool to download the data. This is the recommended option for faster copy.  
    #Download AzCopy v10 from the link here: https://learn.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-v10  
    #Ensure that AzCopy is downloaded in the same folder as this file  
    #If you set the value to 0 then Start-AzStorageBlobCopy will be used. Azure storage will asynchronously copy the data.   
    $useAzCopy = 1   
      
    # Set the context to the subscription Id where managed disk is created  
    Select-AzSubscription -SubscriptionId $SubscriptionId  
      
    #Generate the SAS for the managed disk   
    $sas = Grant-AzDiskAccess -ResourceGroupName $ResourceGroupName -DiskName $diskName -DurationInSecond $sasExpiryDuration -Access Read   
      
    #Create the context of the storage account where the underlying VHD of the managed disk will be copied  
    $destinationContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey  
      
    #Copy the VHD of the managed disk to the storage account  
    if($useAzCopy -eq 1)  
    {  
        $containerSASURI = New-AzStorageContainerSASToken -Context $destinationContext -ExpiryTime(get-date).AddSeconds($sasExpiryDuration) -FullUri -Name $storageContainerName -Permission rw  
        $containername,$sastokenkey = $containerSASURI -split "\?"  
        $containerSASURI = "$containername/$destinationVHDFileName`?$sastokenkey"  
        azcopy copy $sas.AccessSAS $containerSASURI --blob-type=BlockBlob --block-blob-tier=Archive  
      
    }else{  
      
        Start-AzStorageBlobCopy -AbsoluteUri $sas.AccessSAS -DestContainer $storageContainerName -DestContext $destinationContext -DestBlob $destinationVHDFileName  
    }  
    
    1 person found this answer helpful.

  2. Rodrigo Fernández M 21 Reputation points
    2021-03-01T07:58:04.597+00:00

    From what i know there is a storage account in every diskX you have. So i will be like putting a storage account inside other.

    If you are worried about backup you could make incremental snapshots if each disk. If you want to backup that data there is a snapshot process that can be incremental.

    You could also see how the storage account in disks have redundancy configured: LRS, ZRS o GRS.

    Regards.


  3. deherman-MSFT 34,686 Reputation points Microsoft Employee
    2021-03-01T19:04:57.05+00:00

    @Error_401
    This Stack Overflow thread has a PowerShell Script which copies a managed disk to VHD and moves it to storage account. Please review and see if it suites your use-case.

    -------------------------------

    Please don’t forget to "Accept the answer" and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.