public void removeStorageBlob(URI blobURI, String resourceGroupName) throws Exception { // Obtain container, storage account, and blob name String storageAccountName = blobURI.getHost().split("\\.")[0]; String containerName = PathUtility.getContainerNameFromUri(blobURI, false); String blobName = PathUtility.getBlobNameFromURI(blobURI, false); LOGGER.log(Level.INFO, "removeStorageBlob: Removing blob {0}, in container {1} of storage account {2}", new Object[]{blobName, containerName, storageAccountName}); CloudBlobContainer container = getCloudBlobContainer(azureClient, resourceGroupName, storageAccountName, containerName); container.getBlockBlobReference(blobName).deleteIfExists(); if (containerName.startsWith("jnk")) { Iterable<ListBlobItem> blobs = container.listBlobs(); if (blobs.iterator().hasNext()) { // the container is not empty return; } // the container is empty and we should delete it LOGGER.log(Level.INFO, "removeStorageBlob: Removing empty container ", containerName); container.delete(); } }
this.blobServiceClient = new CloudBlobClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getBlobNameFromURI(this.storageUri.getPrimaryUri(), usePathStyleUris);
this.blobServiceClient = new CloudBlobClient(PathUtility.getServiceClientBaseAddress( this.getStorageUri(), usePathStyleUris), credentials != null ? credentials : parsedCredentials); this.name = PathUtility.getBlobNameFromURI(this.storageUri.getPrimaryUri(), usePathStyleUris);