use of com.microsoft.azure.storage.blob.CloudBlobContainer in project azure-sdk-for-java by Azure.
the class ManageLinuxWebAppStorageAccountConnection method setUpStorageAccount.
private static CloudBlobContainer setUpStorageAccount(String connectionString, String containerName) {
try {
CloudStorageAccount account = CloudStorageAccount.parse(connectionString);
// Create a blob service client
CloudBlobClient blobClient = account.createCloudBlobClient();
CloudBlobContainer container = blobClient.getContainerReference(containerName);
container.createIfNotExists();
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
// Include public access in the permissions object
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
// Set the permissions on the container
container.uploadPermissions(containerPermissions);
return container;
} catch (StorageException | URISyntaxException | InvalidKeyException e) {
throw new RuntimeException(e);
}
}
use of com.microsoft.azure.storage.blob.CloudBlobContainer in project jackrabbit-oak by apache.
the class DataStoreUtils method deleteAzureContainer.
public static void deleteAzureContainer(Map<String, ?> config, String containerName) throws Exception {
String accountName = (String) config.get(AzureConstants.AZURE_STORAGE_ACCOUNT_NAME);
String accountKey = (String) config.get(AzureConstants.AZURE_STORAGE_ACCOUNT_KEY);
if (Strings.isNullOrEmpty(containerName) || Strings.isNullOrEmpty(accountName) || Strings.isNullOrEmpty(accountKey)) {
return;
}
log.info("deleting container [" + containerName + "]");
CloudBlobContainer container = org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.Utils.getBlobContainer(org.apache.jackrabbit.oak.blob.cloud.azure.blobstorage.Utils.getConnectionString(accountName, accountKey), containerName);
if (container.deleteIfExists()) {
log.info("container [ " + containerName + "] deleted");
} else {
log.info("container [" + containerName + "] doesn't exists");
}
}
use of com.microsoft.azure.storage.blob.CloudBlobContainer in project jackrabbit-oak by apache.
the class AzureDataStoreUtils method deleteContainer.
public static void deleteContainer(String containerName) throws Exception {
if (Strings.isNullOrEmpty(containerName)) {
log.warn("Cannot delete container with null or empty name. containerName={}", containerName);
return;
}
log.info("Starting to delete container. containerName={}", containerName);
Properties props = getAzureConfig();
CloudBlobContainer container = Utils.getBlobContainer(Utils.getConnectionStringFromProperties(props), containerName);
boolean result = container.deleteIfExists();
log.info("Container deleted. containerName={} existed={}", containerName, result);
}
use of com.microsoft.azure.storage.blob.CloudBlobContainer in project jackrabbit-oak by apache.
the class AzureBlobStoreBackend method getAzureContainer.
protected CloudBlobContainer getAzureContainer() throws DataStoreException {
CloudBlobContainer container = Utils.getBlobContainer(connectionString, containerName);
RequestOptions requestOptions = container.getServiceClient().getDefaultRequestOptions();
if (retryPolicy != null) {
requestOptions.setRetryPolicyFactory(retryPolicy);
}
if (requestTimeout != null) {
requestOptions.setTimeoutIntervalInMs(requestTimeout);
}
return container;
}
Aggregations