Copy entire storage account to another one using AzCopy

Roman Muntyanu 1 Reputation point
2023-12-17T17:53:55.3866667+00:00
I am trying to copy content of entire storage account to another storage account using azcopy utility
The help for this utility tells the following

Copy all blob containers, directories, and blobs from storage account to another by using a SAS token:
  - azcopy cp "https://[srcaccount].blob.core.windows.net?[SAS]" "https://[destaccount].blob.core.windows.net?[SAS]" --recursive=true
  
  I generated SAS for source and destination the following way.
$sourceSasToken = New-AzStorageAccountSASToken -ResourceType Service,Container,Object -Service Blob -Context $srcCtx -Permission $srsPermissions -StartTime $startTime -ExpiryTime $expiryTime

$destinationSasToken = New-AzStorageAccountSASToken -ResourceType Service,Container,Object -Service Blob -Context $destCtx -Permission $destPermissions -StartTime $startTime -ExpiryTime $expiryTime
  
I tested if using these SAS I can copy single file from source account to destination account and the following command works and file was copied to another storage
  
  "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe" copy https://mydcadevt98765dvlp.blob.core.windows.net/claims/cps/9aa1553e-b4df-4952-8561-0b327f3908a5.dat?sv=2019-02-02^&sig=JmCwsx6cXwtiCYTbVdX77bVrK07s2moR61HUSC5Pe3U%3D^&st=2023-12-17T15%3A54%3A50Z^&se=2023-12-17T16%3A39%3A50Z^&srt=sco^&ss=b^&sp=r^&sr=c https://mydcatstcact98765dvp.blob.core.windows.net/claims/cps/9aa1553e-b4df-4952-8561-0b327f3908a5.dat?sv=2019-02-02^&sig=hD6H9xrRiJkm4IZvVVfYspf1fPyHJnP1rEbPad3tfLY%3D^&st=2023-12-17T15%3A54%3A50Z^&se=2023-12-17T16%3A39%3A50Z^&srt=sco^&ss=b^&sp=raw^&sr=c --recursive=true
  
  Then I tried to execute command to copy entire account as help for azcopy command suggested using this command 
  
  "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy\AzCopy.exe" copy https://mydcadevt98765dvlp.blob.core.windows.net?sv=2019-02-02^&sig=PGFPL3VWIgscToRwOdBuNaomjGQU7ZvuX2qyQhR1SK0%3D^&st=2023-12-17T15%3A32%3A56Z^&se=2023-12-17T16%3A17%3A56Z^&srt=sco^&ss=b^&sp=r^&sr=c https://myldcatstcact98765dvp.blob.core.windows.net?sv=2019-02-02^&sig=DOLptZBzzBc4Mj%2FFDxfYkvkw7sSWOobNuQa38h2y6yw%3D^&st=2023-12-17T15%3A32%3A56Z^&se=2023-12-17T16%3A17%3A56Z^&srt=sco^&ss=b^&sp=raw^&sr=c --recursive=true
  
  After executing this command I got this error 
  
INFO: Scanning...

failed to perform copy command due to error: failed to initialize enumerator: failed to list containers: GET https://abeldcadevt98765dvlp.blob.core.windows.net
--------------------------------------------------------------------------------
RESPONSE 403: 403 This request is not authorized to perform this operation using this permission.
ERROR CODE: AuthorizationPermissionMismatch
--------------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthorizationPermissionMismatch</Code><Message>This request is not authorized to perform this operation using this permission.
RequestId:c002052e-301e-003f-1500-312c2a000000
Time:2023-12-17T15:46:08.6759486Z</Message></Error>

Please advice what is incorrect in my last command. I am assigned with the owner role for both source and destination 

Thank you in advance
Roman
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,754 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pranathi Panyam_MSFT 1,006 Reputation points Microsoft Employee
    2023-12-25T08:17:28.5466667+00:00

    Hello @Roman Muntyanu

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

    This error message could either be because of not having proper permissions to the storage account, or due the firewall or network blockage at the storage account level.

    This error is telling you that you need to add a role assignment to the user. Please go to Storage account -> Access Control -> Add -> Add role assignment, then add Storage Blob Data Owner to your login account.

    [enter image description here

    ](https://i.stack.imgur.com/QupZS.png)

    If this problem persists, please check in the networking tab if the firewall is enabled or if the storage account network settings are restricted to certain virtual network.

    Please check the above and let us know if this helped.

    Please "Accept as Answer" if it helped so it can help others in community looking for help on similar topics.

    0 comments No comments