CloudBlob.EndCopyFromBlob Method
From Storage Client Library NET API
[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See Storage Client Library for the latest version.]
Ends an asynchronous operation to copy a blob's contents, properties, and metadata to a new blob.
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)
Usage
| Visual Basic |
|---|
Dim instance As CloudBlob Dim asyncResult As IAsyncResult instance.EndCopyFromBlob(asyncResult) |
Syntax
| Visual Basic |
|---|
Public Sub EndCopyFromBlob ( _ asyncResult As IAsyncResult _ ) |
| C# |
|---|
public void EndCopyFromBlob ( IAsyncResult asyncResult ) |
| C++ |
|---|
public: void EndCopyFromBlob ( IAsyncResult^ asyncResult ) |
| J# |
|---|
| JScript |
|---|
Parameters
- asyncResult
Type: System.IAsyncResult
An IAsyncResult that references the pending asynchronous operation.
Example
The following code example copies a blob only if an access condition on the source blob is met.
| C# | |
|---|---|
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");
sourceBlob.UploadFile("C:\\somefile.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.
try
{
blobDest.EndCopyFromBlob(result);
}
catch (StorageClientException e)
{
if (e.StatusCode == HttpStatusCode.PreconditionFailed)
{
Console.WriteLine("Access condition on source blob not met for blob copy operation.");
}
else
{
Console.WriteLine("Error code: " + e.ErrorCode);
}
}
}
| |
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.