SALES: 1-800-867-1380

CloudBlob.EndCopyFromBlob Method

Updated: April 24, 2013

[This topic is part of the Windows Azure Storage Client Library 1.7, which has been deprecated. The current recommended version is Storage Client Library 3.0.]

Ends an asynchronous operation to copy a blob's contents, properties, and metadata to a new blob.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)


public void EndCopyFromBlob (
	IAsyncResult asyncResult



Type: System.IAsyncResult

An IAsyncResult that references the pending asynchronous operation.

The following code example copies a blob only if an access condition on the source blob is met.

static void CopyBlobConditionallyAsync(Uri blobEndpoint, string accountName, string accountKey)
    // Create service client for credentialed access to the Blob service.
    CloudBlobClient blobClient = new CloudBlobClient(blobEndpoint, accountName, accountKey);

    // Create a new blob by uploading a file.
    CloudBlob sourceBlob = blobClient.GetBlobReference("mycontainer/sourceblob.txt");

    // Get a reference to the destination blob.
    CloudBlob destBlob = blobClient.GetBlobReference("mycontainer/destblob.txt");

    // Establish an access condition, so that the blob will be copied if the source blob
    // has not been changed in the past hour.
    BlobRequestOptions options = new BlobRequestOptions();
    options.CopySourceAccessCondition = AccessCondition.IfNotModifiedSince(DateTime.Now.AddHours(-1));

    destBlob.BeginCopyFromBlob(sourceBlob, options, CopyBlobCallback, destBlob);

static void CopyBlobCallback(IAsyncResult result)
    CloudBlob blobDest = (CloudBlob)result.AsyncState;

    // End the operation, checking for the exception that indicates the condition was not met.
    catch (StorageClientException e)
        if (e.StatusCode == HttpStatusCode.PreconditionFailed)
            Console.WriteLine("Access condition on source blob not met for blob copy operation.");
            Console.WriteLine("Error code: " + e.ErrorCode);

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7 and Windows Server 2008

Target Platforms

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft