use of com.microsoft.azure.storage.blob.BlobContainerPermissions in project azure-sdk-for-java by Azure.
the class ManageWebAppStorageAccountConnection 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.BlobContainerPermissions 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.BlobContainerPermissions in project cloudbreak by hortonworks.
the class AzureClient method setPublicPermissionOnContainer.
public void setPublicPermissionOnContainer(String resourceGroup, String storageName, String containerName) {
LOGGER.debug("set public permission on container: RG={}, storageName={}, containerName={}", resourceGroup, storageName, containerName);
CloudBlobContainer container = getBlobContainer(resourceGroup, storageName, containerName);
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
try {
container.uploadPermissions(containerPermissions);
} catch (StorageException e) {
throw new CloudConnectorException("can't set public permission on container, storage service error occurred", e);
}
}
use of com.microsoft.azure.storage.blob.BlobContainerPermissions in project components by Talend.
the class AzureStorageBlobService method setPublicAccess.
public void setPublicAccess(String containerName) throws URISyntaxException, StorageException, InvalidKeyException {
CloudBlobClient cloudBlobClient = connection.getCloudStorageAccount().createCloudBlobClient();
CloudBlobContainer cloudBlobContainer = cloudBlobClient.getContainerReference(containerName);
BlobContainerPermissions containerPermissions = new BlobContainerPermissions();
containerPermissions.setPublicAccess(BlobContainerPublicAccessType.CONTAINER);
cloudBlobContainer.uploadPermissions(containerPermissions);
}
Aggregations