use of com.azure.storage.blob.BlobContainerClientBuilder in project ApplicationInsights-Java by microsoft.
the class ServiceProfilerUploader method uploadToSasLink.
/**
* Upload the given file to a blob storage defined by a sas link.
*/
private Mono<Response<BlockBlobItem>> uploadToSasLink(BlobAccessPass uploadPass, UploadContext uploadContext, File file) {
try {
URL sasUrl = new URL(uploadPass.getUriWithSasToken());
LOGGER.debug("SAS token: {}", uploadPass.getUriWithSasToken());
BlobUploadFromFileOptions options = createBlockBlobOptions(file, uploadContext);
BlobContainerAsyncClient blobContainerClient = new BlobContainerClientBuilder().endpoint(sasUrl.toString()).buildAsyncClient();
BlobAsyncClient blobClient = blobContainerClient.getBlobAsyncClient(uploadPass.getBlobName());
return blobClient.uploadFromFileWithResponse(options).doFinally((done) -> LOGGER.info("upload done"));
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Malformed url", e);
}
}
use of com.azure.storage.blob.BlobContainerClientBuilder in project springboot-samples by joergjo.
the class EventHubWorker method run.
public void run() {
logger.info("Worker is starting");
var blobContainerAsyncClient = new BlobContainerClientBuilder().connectionString(storageConnectionString).containerName(containerName).buildAsyncClient();
Consumer<EventContext> processEvent = eventContext -> {
logger.info("Processing event: Event Hub name = {}; consumer group name = {}; partition id = {}; sequence number = {}", eventContext.getPartitionContext().getEventHubName(), eventContext.getPartitionContext().getConsumerGroup(), eventContext.getPartitionContext().getPartitionId(), eventContext.getEventData().getSequenceNumber());
eventContext.updateCheckpoint();
total.increment();
};
Consumer<ErrorContext> processError = errorContext -> {
logger.error("Error while processing {}, {}, {}, {}", errorContext.getPartitionContext().getEventHubName(), errorContext.getPartitionContext().getConsumerGroup(), errorContext.getPartitionContext().getPartitionId(), errorContext.getThrowable().getMessage());
};
eventProcessorClient = new EventProcessorClientBuilder().consumerGroup(consumerGroup).connectionString(eventHubConnectionString, eventHubName).processEvent(processEvent).processError(processError).checkpointStore(new BlobCheckpointStore(blobContainerAsyncClient)).buildEventProcessorClient();
eventProcessorClient.start();
logger.info("Worker has started");
}
use of com.azure.storage.blob.BlobContainerClientBuilder in project document-management-store-app by hmcts.
the class AzureStorageConfiguration method cloudBlobContainer.
@Bean
@ConditionalOnProperty(value = "azure.storage.enabled", havingValue = "true")
BlobContainerClient cloudBlobContainer() throws UnknownHostException {
String blobAddress = connectionString.contains("azure-storage-emulator-azurite") ? connectionString.replace("azure-storage-emulator-azurite", InetAddress.getByName("azure-storage-emulator-azurite").getHostAddress()) : connectionString;
final BlobContainerClient client = new BlobContainerClientBuilder().connectionString(blobAddress).containerName(containerReference).buildClient();
try {
client.create();
return client;
} catch (BlobStorageException e) {
return client;
}
}
Aggregations