Microsoft.WindowsAzure.Commands.Storage.Blob.RemoveStorageAzureBlobCommand.RemoveAzureBlob C# (CSharp) Method

RemoveAzureBlob() private method

remove the azure blob
private RemoveAzureBlob ( long taskId, IStorageBlobManagement localChannel, Microsoft.WindowsAzure.Storage.Blob.CloudBlob blob, bool isValidBlob ) : Common.Task
taskId long
localChannel IStorageBlobManagement
blob Microsoft.WindowsAzure.Storage.Blob.CloudBlob Cloudblob object
isValidBlob bool whether the Cloudblob parameter is validated
return Common.Task
        internal async Task RemoveAzureBlob(long taskId, IStorageBlobManagement localChannel, CloudBlob blob, bool isValidBlob)
        {
            if (!isValidBlob)
            {
                ValidatePipelineCloudBlob(blob);
            }

            ValidateBlobType(blob);

            DeleteSnapshotsOption deleteSnapshotsOption = DeleteSnapshotsOption.None;
            bool retryDeleteSnapshot = false;

            if (IsSnapshot(blob))
            {
                if (deleteSnapshot)
                {
                    throw new ArgumentException(String.Format(Resources.CannotDeleteSnapshotForSnapshot, blob.Name, blob.SnapshotTime));
                }
            }
            else
            {
                if (deleteSnapshot)
                {
                    deleteSnapshotsOption = DeleteSnapshotsOption.DeleteSnapshotsOnly;
                }
                else if (force)
                {
                    deleteSnapshotsOption = DeleteSnapshotsOption.IncludeSnapshots;
                }
                else
                {
                    retryDeleteSnapshot = true;
                }
            }

            try
            {
                await DeleteCloudAsync(taskId, localChannel, blob, deleteSnapshotsOption);
                retryDeleteSnapshot = false;
            }
            catch (StorageException e)
            {
                if (e.IsConflictException() && retryDeleteSnapshot)
                {
                    //If x-ms-delete-snapshots is not specified on the request and the blob has associated snapshots, the Blob service returns status code 409 (Conflict).
                    retryDeleteSnapshot = true;
                }
                else
                {
                    throw;
                }
            }

            if (retryDeleteSnapshot)
            {
                string message = string.Format(Resources.ConfirmRemoveBlobWithSnapshot, blob.Name, blob.Container.Name);

                if (await OutputStream.ConfirmAsync(message))
                {
                    deleteSnapshotsOption = DeleteSnapshotsOption.IncludeSnapshots;
                    await DeleteCloudAsync(taskId, localChannel, blob, deleteSnapshotsOption);
                }
                else
                {
                    string result = String.Format(Resources.RemoveBlobCancelled, blob.Name, blob.Container.Name);
                    OutputStream.WriteVerbose(taskId, result);
                }
            }
        }

Same methods

RemoveStorageAzureBlobCommand::RemoveAzureBlob ( long taskId, IStorageBlobManagement localChannel, Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer container, string blobName ) : Common.Task
RemoveStorageAzureBlobCommand::RemoveAzureBlob ( long taskId, IStorageBlobManagement localChannel, string containerName, string blobName ) : Common.Task