/// <summary>
/// Requests that the service start to copy a blob's contents, properties, and metadata to a new blob asynchronously.
/// </summary>
/// <param name="blobClient">Cloud blob client.</param>
/// <param name="source">The URI of a source blob.</param>
/// <param name="sourceAccessCondition">An object that represents the access conditions for the source blob.</param>
/// <param name="destAccessCondition">An object that represents the access conditions for the destination blob.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns>
/// The copy ID associated with the copy operation.
/// </returns>
public static Task<string> GetBlobReferenceFromServerAsync(
ICloudBlob blobClient,
Uri source,
AccessCondition sourceAccessCondition = null,
AccessCondition destAccessCondition = null,
CancellationToken cancellationToken = default (CancellationToken))
{
ICancellableAsyncResult asyncResult = blobClient.BeginStartCopyFromBlob(source, sourceAccessCondition, destAccessCondition, null, null, null, null);
CancellationTokenRegistration registration = cancellationToken.Register(p => asyncResult.Cancel(), null);
return Task<string>.Factory.FromAsync(
asyncResult,
result =>
{
registration.Dispose();
return blobClient.EndStartCopyFromBlob(result);
});
}