Copy Blob from Azure to Local Storage with Start-AzureStorageBlobCopy

1.9k views Asked by At

I would like to copy a Blob from "Azure storage" to my "Local storage" (Emulator) with powershell.

I am using "Start-AzureStorageBlobCopy"

It's working well between "Azure" to "Azure" storage. But for an "Azure" to "Local" (emulator) storage, blobs are copied but with 0 byte. Blobs are created because I can see them in the Storage Explorer.

In the Azure Storage Explorer, I have the following properties :

  • CopyProgress: 0/34550784
  • CopyStatus: failed

I've no error in Powershell during the copy. But 0 bytes are transferred

VERBOSE: Performing the operation "Copy" on target "https://xxxxx.blob.core.windows.net/aaaa.db".
VERBOSE: Copy request to blob 'aaaaaa.db' in container 'yyyyy' has been scheduled with copyId 865e4d31-6729-44d1-997d-fdb76409d6cb.
ICloudBlob        : Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob
BlobType          : BlockBlob
Length            : 0
ContentType       : 
LastModified      : 9/10/2017 2:10:45 PM +00:00
SnapshotTime      : 
ContinuationToken : 
Context           : Microsoft.WindowsAzure.Commands.Storage.AzureStorageContext
Name              : aaaaaa.db

VERBOSE: Transfer Summary
--------------------------------
Total:  1.
Successful: 1.
Failed: 0.
2

There are 2 answers

1
Gaurav Mantri On BEST ANSWER

I don't think it is possible to copy a blob from your cloud storage account to local emulator account using Start-AzureStorageBlobCopy Cmdlet.

Azure copy blob is a server-side asynchronous operation performed by Azure Storage Service. For copy blob to work, Azure Storage Service should be able to reach to the destination. Because the destination account is your local storage account not accessible from outside of your machine, Azure Storage Service is never able to reach the destination.

One possible solution would be to download the blob and then upload it in local storage account using respective Cmdlets.

Another option would be to use AzCopy's Sync Copy blob functionality. Sync Copy Blob implementation in AzCopy actually download the blob content from source and then uploads it in the target.

0
Thom Schumacher On

Get-AzureStorageBlobContent might work for you. I wrote up an article on AzureStorageFileContent download that I posted here: Azure File Storage Download