本文整理汇总了C#中IStorageBlobManagement.AbortCopyAsync方法的典型用法代码示例。如果您正苦于以下问题:C# IStorageBlobManagement.AbortCopyAsync方法的具体用法?C# IStorageBlobManagement.AbortCopyAsync怎么用?C# IStorageBlobManagement.AbortCopyAsync使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IStorageBlobManagement
的用法示例。
在下文中一共展示了IStorageBlobManagement.AbortCopyAsync方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StopCopyBlob
/// <summary>
/// Stop copy operation by CloudBlob object
/// </summary>
/// <param name="blob">CloudBlob object</param>
/// <param name="copyId">Copy id</param>
private async Task StopCopyBlob(long taskId, IStorageBlobManagement localChannel, CloudBlob blob, string copyId, bool fetchCopyIdFromBlob = false)
{
ValidateBlobType(blob);
AccessCondition accessCondition = null;
BlobRequestOptions abortRequestOption = RequestOptions ?? new BlobRequestOptions();
//Set no retry to resolve the 409 conflict exception
abortRequestOption.RetryPolicy = new NoRetry();
if (null == blob)
{
throw new ArgumentException(String.Format(Resources.ObjectCannotBeNull, typeof(CloudBlob).Name));
}
string specifiedCopyId = copyId;
if (string.IsNullOrEmpty(specifiedCopyId) && fetchCopyIdFromBlob)
{
if (blob.CopyState != null)
{
specifiedCopyId = blob.CopyState.CopyId;
}
}
string abortCopyId = string.Empty;
if (string.IsNullOrEmpty(specifiedCopyId) || Force)
{
//Make sure we use the correct copy id to abort
//Use default retry policy for FetchBlobAttributes
BlobRequestOptions options = RequestOptions;
await localChannel.FetchBlobAttributesAsync(blob, accessCondition, options, OperationContext, CmdletCancellationToken);
if (blob.CopyState == null || String.IsNullOrEmpty(blob.CopyState.CopyId))
{
ArgumentException e = new ArgumentException(String.Format(Resources.CopyTaskNotFound, blob.Name, blob.Container.Name));
OutputStream.WriteError(taskId, e);
}
else
{
abortCopyId = blob.CopyState.CopyId;
}
if (!Force)
{
string confirmation = String.Format(Resources.ConfirmAbortCopyOperation, blob.Name, blob.Container.Name, abortCopyId);
if (!await OutputStream.ConfirmAsync(confirmation))
{
string cancelMessage = String.Format(Resources.StopCopyOperationCancelled, blob.Name, blob.Container.Name);
OutputStream.WriteVerbose(taskId, cancelMessage);
}
}
}
else
{
abortCopyId = specifiedCopyId;
}
await localChannel.AbortCopyAsync(blob, abortCopyId, accessCondition, abortRequestOption, OperationContext, CmdletCancellationToken);
string message = String.Format(Resources.StopCopyBlobSuccessfully, blob.Name, blob.Container.Name);
OutputStream.WriteObject(taskId, message);
}