简体   繁体   中英

Copy page blob from one storage account to Another storage account using .Net API startCopy

I am trying to copy a page blob in one storage account to another storage account using .net API startCopy. Both storage accounts are standard type and blob exists in source location. I am getting "cannotverifysourcepath" error with below exception details.

I was hoping that startcopy API works to copy from account to another. Can anyone please help me to figure out what's the issue here?

Exception- Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (404) Not Found. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
   at System.Net.HttpWebRequest.GetResponse()
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext)
   at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.StartCopy(Uri source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext)
   at Microsoft.WindowsAzure.Storage.Blob.CloudPageBlob.StartCopy(CloudPageBlob source, AccessCondition sourceAccessCondition, AccessCondition destAccessCondition, BlobRequestOptions options, OperationContext operationContext)
Request Information
RequestID:1a82f5b6-0001-008f-7328-26bec1000000
RequestDate:Fri, 14 Oct 2016 14:35:31 GMT
StatusMessage:The specified resource does not exist.
ErrorCode:CannotVerifyCopySource

For copying blob across storage accounts, source blob must be publicly accessible. Please check the ACL on the source blob container and see if it is Private .

If the source blob container's ACL is Private , there are two possible solutions:

  1. Create a Shared Access Signature (SAS) on the source blob with at least Read permission and an expiry date of at least 15 days and use that SAS URL (blob URL + SAS token) as copy source.
  2. Not recommended, but you can change the ACL of the source blob container to Blob . This will make the source blob publicly accessible. Your code should work as is in that case.

You can try using the data movement library . Specifically:

await TransferManager.CopyAsync(source, target, false);

The boolean parameter specifies whether or not this is a service-side asynchronous copy. If it is, the local task may complete before the copy is complete.

I have verified that this works when source and target are in different accounts and both access policies are 'private.'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM