/// <summary> /// Delete the container with the specified name if it exists. /// </summary> /// <param name="containerName">Name of container to delete.</param> public async Task DeleteContainerAsync(string containerName) { using (IOperationContext azOp = L.Begin("Delete Azure Storage container")) { try { CloudBlobClient client = GetCloudBlobClient(); CloudBlobContainer container = client.GetContainerReference(containerName); await container.DeleteIfExistsAsync(); azOp.Complete(); } catch (Exception e) { L.Error(e, "Exception throw deleting Azure Storage container {c}.", containerName); } } }
/// <summary> /// Get a CloudBlobDirectory instance with the specified name in the given container. /// </summary> /// <param name="containerName">Container name.</param> /// <param name="directoryPath">Blob directory name.</param> /// <returns>A <see cref="Task{T}"/> object of type <see cref="CloudBlobDirectory"/> that represents the asynchronous IOperationContext.</returns> public CloudBlobDirectory GetCloudBlobDirectory(string containerName, string directoryPath) { using (IOperationContext azOp = L.Begin("Get Azure Storage blob directory {0)/{1}.", containerName, directoryPath)) { try { GetCloudBlobClient(); CloudBlobContainer container = BlobClient.GetContainerReference(containerName); CloudBlobDirectory dir = container.GetDirectoryReference(directoryPath); azOp.Complete(); return(dir); } catch (StorageException se) { if (RethrowExceptions) { throw se; } else { L.Error(se, "A storage error occurred getting Azure Storage directory {dn} from container {cn}.", directoryPath, containerName); return(null); } } catch (Exception e) { if (RethrowExceptions) { throw e; } else { L.Error(e, "An error occurred getting Azure Storage directory {dn} from container {cn}.", directoryPath, containerName); return(null); } } } }
protected void Complete() { _operation.Complete(); }