I'm trying to copy one blob, specifically a vhd, from on storage account to another storage account. The app that I am writing has owner access to both storage accounts and can run other operation on these storage accounts. The vhd does not have a lease on it (not attached a VM). I have the following code but get a 403 forbidden response.
StorageCredentials scSource = new StorageCredentials(SourceStorageName, strSourceStorageKey);
StorageCredentials scTarget = new StorageCredentials(TargetStorageName, strTargetStorageKey);
CloudStorageAccount csaSource = new CloudStorageAccount(scSource, true);
CloudStorageAccount csaTarget = new CloudStorageAccount(scTarget, true);
CloudBlobClient cbcSource = csaSource.CreateCloudBlobClient();
CloudBlobClient cbcTarget = csaTarget.CreateCloudBlobClient();
CloudBlobContainer bcSource = cbcSource.GetContainerReference(SourceContainer);
CloudBlobContainer bcTarget = cbcTarget.GetContainerReference(TargetContainer);
CloudBlob cbSource = bcSource.GetBlobReference(strSourceDiskName);
CloudBlob cbTarget = bcTarget.GetBlobReference(strTargetDiskName);
Task<string> tskCopy = cbTarget.StartCopyAsync(cbSource.Uri);
while (tskCopy.Status != TaskStatus.RanToCompletion)
{
if (tskCopy.Exception != null)
throw tskCopy.Exception;
Thread.Sleep(2500);
}
Not sure why this is happening because I am able to copy a blob from one storage account to another via other tools (cloud berry etc).
Read
permission and use that as source URL instead of blob's URL. – Gaurav Mantri