[BUG] CopyStatus is not updated after copy is finished
See original GitHub issueDescribe the bug I’m making the migration from Microsoft.WindowsAzure.Storage.Blob versio 9.3.2.0 to Azure.Storage.Blobs version 12.8.0.0 and trying to replicate the CopyBlobData functionality. In the oldest version, we could check a property CopyStatus to see if the copy is finished. In the new one we still have this property, but it’s never updated and so we can never know if the copy has ended. See more bellow:
1. Original code
public virtual void CopyFromBlob(string sourceConnectionString, string sourceContainerName, string sourceBlobName, string targetConnectionString, string targetContainerName, string targetBlobName)
{
var sourceContainer = GetContainer(sourceConnectionString, sourceContainerName);
CloudBlockBlob sourceBlockBlob = sourceContainer.GetBlockBlobReference(sourceBlobName);
var targetContainer = GetContainer(targetConnectionString, targetContainerName);
CloudBlockBlob targetBlockBlob = targetContainer.GetBlockBlobReference(targetBlobName);
targetBlockBlob.StartCopy(sourceBlockBlob);
while (targetBlockBlob.CopyState.Status == Microsoft.WindowsAzure.Storage.Blob.CopyStatus.Pending)
{
Thread.Sleep(500);
}
if (targetBlockBlob.CopyState.Status != Microsoft.WindowsAzure.Storage.Blob.CopyStatus.Success)
{
throw new Exception("Copy failed: " + targetBlockBlob.CopyState.Status);
}
}
2. New version
public virtual void CopyFromBlobNew(string sourceConnectionString, string sourceContainerName, string sourceBlobName, string targetConnectionString, string targetContainerName, string targetBlobName)
{
var sourceContainer = GetContainerNew(sourceConnectionString, sourceContainerName);
var sourceBlob = sourceContainer.GetBlobClient(sourceBlobName);
var targetContainer = GetContainerNew(targetConnectionString, targetContainerName);
var targetBlob = targetContainer.GetBlobClient(targetBlobName);
var copyInformation = targetBlob.SyncCopyFromUri(sourceBlob.Uri);
while (copyInformation.Value.CopyStatus == Azure.Storage.Blobs.Models.CopyStatus.Pending)
{
Thread.Sleep(500);
}
if (copyInformation.Value.CopyStatus != Azure.Storage.Blobs.Models.CopyStatus.Success)
{
throw new Exception("Copy failed: " + copyInformation.Value.CopyStatus);
}
}
The problem is: the CopyStatus property inside the BlobCopyInfo object that the SyncCopyFromUri method returns is never updated. I’ve eve tried to get the blob properties directly, but, as you can see bellow, the CopyStatus property still with the wrong value even if there is no more data to copy:
Expected behavior The CopyStatus property should be updated as soon as the copy is finished.
Actual behavior (include Exception or Stack Trace) The CopyStatus is never updated
To Reproduce Described above
Environment:
- Azure.Storage.Blobs version 12.8.0.0
- Windows 10, .NET Framework 4.7
- IDE and version : Version 16.8.5
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top GitHub Comments
@WillRock19, this is by design.
copyInformation
is not a dynamic object, and will not be updated.I would recommend this approach instead:
-Sean
Hi @seanmcc-msft, any updates on this?