/** * Deletes the container. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void delete() throws StorageException { this.delete(null /* accessCondition */, null /* options */, null /* opContext */); }
@Test public void testCloudBlobContainerDeleteIfExistsErrorCode() throws StorageException { try { container.delete(); fail("Container should not already exist."); } catch (StorageException e) { assertEquals(StorageErrorCodeStrings.CONTAINER_NOT_FOUND, e.getErrorCode()); } OperationContext ctx = new OperationContext(); ctx.getSendingRequestEventHandler().addListener(new StorageEvent<SendingRequestEvent>() { @Override public void eventOccurred(SendingRequestEvent eventArg) { if (((HttpURLConnection) eventArg.getConnectionObject()).getRequestMethod().equals("DELETE")) { try { container.delete(); assertFalse(container.exists()); } catch (StorageException e) { fail("Delete should succeed."); } } } }); container.create(); // Container deletes succeed before garbage collection occurs. assertTrue(container.deleteIfExists(null, null, ctx)); }
/** * Deletes the container. * * @throws StorageException * If a storage service error occurred. */ @DoesServiceRequest public void delete() throws StorageException { this.delete(null /* accessCondition */, null /* options */, null /* opContext */); }
@NotNull public static String deleteContainer(@NotNull final StorageInputs inputs) throws Exception { final CloudBlobClient blobClient = getCloudBlobClient(inputs); final CloudBlobContainer container = blobClient.getContainerReference(inputs.getContainerName()); container.delete(); return inputs.getContainerName(); }
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(); } }
@Override public void dispose(DataStore dataStore) { if (dataStore == null) { return; } try { dataStore.close(); } catch (DataStoreException e) { log.warn("Issue while disposing DataStore", e); } CloudBlobContainer container = containers.get(dataStore); if (container != null) { log.info("Removing Azure test blob container {}", container.getName()); try { // For Azure, you can just delete the container and all // blobs it in will also be deleted container.delete(); } catch (StorageException e) { log.warn("Unable to delete Azure Blob container {}", container.getName()); } containers.remove(dataStore); } } }
if (exists) { try { this.delete(accessCondition, options, opContext); return true;
if (exists) { try { this.delete(accessCondition, options, opContext); return true;
@Override public void eventOccurred(SendingRequestEvent eventArg) { if (((HttpURLConnection) eventArg.getConnectionObject()).getRequestMethod().equals("DELETE")) { try { container.delete(); assertFalse(container.exists()); } catch (StorageException e) { fail("Delete should succeed."); } } } });
container.delete();
container.delete();
try { final BlobRequestOptions options = new BlobRequestOptions(); session.getClient().getContainerReference(containerService.getContainer(file).getName()).delete( AccessCondition.generateEmptyCondition(), options, context);
container.delete();
/** * Check a container's existence * * @throws StorageException */ @Test @Category({ DevFabricTests.class, DevStoreTests.class }) public void testCloudBlobContainerExists() throws StorageException { assertFalse(this.container.exists()); this.container.create(); assertTrue(this.container.exists()); assertNotNull(this.container.getProperties().getEtag()); this.container.delete(); assertFalse(this.container.exists()); }
source.delete(); copySas.delete(); container.delete();