Is it possible to copy from a RA-GRS secondary using Start-AzureStorageBlobCopy?

1k views Asked by At

Is it possible to copy from a RA-GRS secondary using Start-AzureStorageBlobCopy?

It works using AZCopy, but when I try using the Azure cmdlet I get the following warning and nothing is copied:

WARNING: Ignore mismatch source storage context.. The source uri is https://portalvhdsblahblah-secondary.blob.core.windows.net/vhds/VM3.vhd, the end point is https://portalvhdsblahblah.blob.core.windows.net/.

Interestingly when explore object with Show-Object, there is no secondary URI listed for the container or blob. Although the Storage Account shows that a Read Access secondary is listed as available.

I've seen reference to this in a script online, but when I run the script I get the same error as above. Has the API changed? I've tried using ARM and ASM.

Again this work OK using AZCopy....

1

There are 1 answers

1
slepox On

Currently PowerShell Cmdlet Start-AzureStorageBlobCopy is not convenient enough to select secondary or primary if you use a basic Context to authenticate.

There are 2 ways to work around.

1) Use a source Uri containing the Authentication info: you may manually make up SAS url for secondary, since secondary and primary share the same SAS. For example:

$src = 'http://account1-secondary.blob.core.windows.net/con1/blob1'+(New-AzureStorageBlobSASToken -Container con1 -Blob blob1 -Permission r -Context $srcContext)

Start-AzureStorageBlobCopy -SrcUri $src -DestContainer con2 -DestBlob blob1 -DestContext $DestContext

2) Create a Context with customized endpoints with explicitly set to secondary. For example:

$srcctx = New-AzureStorageContext -ConnectionString "DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***;BlobEndpoint=http://***-secondary.blob.core.windows.net;FileEndpoint=http://***-secondary.file.core.windows.net;QueueEndpoint=http://***-secondary.queue.core.windows.net; TableEndpoint=http://***-secondary.table.core.windows.net;

Start-AzureStorageBlobCopy –Container *** -Blob *** -Context $srcctx –DestContainer *** -DestBlob *** -DestContext $destctx