-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] CopyStatus is not updated after copy is finished #19263
Comments
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @xgithubtriage. Issue DetailsDescribe the bug 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 Actual behavior (include Exception or Stack Trace) To Reproduce Environment:
|
Thank you for your feedback. Tagging and routing to the team best able to assist. |
@WillRock19, this is by design.
I would recommend this approach instead:
-Sean |
Hi @seanmcc-msft , how are you? I think we might need to re-open this issue. The solution that you've proposed does not seems to work, since everytime I'm calling the GetProperties the resulted blobPropertiesResponse still have it's CopyStatus with the value Pending. Here is my code: 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);
if (!sourceBlob.Exists())
throw new RequestFailedException($"A copy blob operation was requested, but the source blob {sourceBlobName} does not exist!");
targetBlob.SyncCopyFromUri(sourceBlob.Uri);
var blobPropertiesResponse = targetBlob.GetProperties();
while (blobPropertiesResponse.Value.CopyStatus == CopyStatus.Pending)
{
Thread.Sleep(500);
blobPropertiesResponse = targetBlob.GetProperties();
}
if (blobPropertiesResponse.Value.CopyStatus != CopyStatus.Success)
{
throw new Exception("Copy failed. The resulted status is: " + blobPropertiesResponse.Value.CopyStatus);
}
} I've post the synchronous version that I need to use, but I've tried the asynchronous version you've post it and it never comes out from the while statement (while debugging, I've noticed the blobPropertiesResponse.Value.CopyStatus never change from Pending, doesn't matter how many times I call the targetBlob.GetProperties()). |
Hi @seanmcc-msft, any updates on this? |
1 similar comment
Hi @seanmcc-msft, any updates on this? |
Describe 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
2. New version
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:
The text was updated successfully, but these errors were encountered: