Java Code Examples for com.microsoft.azure.storage.StorageCredentials#tryParseCredentials()

The following examples show how to use com.microsoft.azure.storage.StorageCredentials#tryParseCredentials() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AzureBlobResource.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@javax.enterprise.inject.Produces
@Named("azureBlobClient")
public CloudBlob createBlobClient() throws Exception {
    StorageCredentials credentials = StorageCredentials.tryParseCredentials(System.getProperty("azurite.credentials"));
    URI uri = new URI(System.getProperty("azurite.blob.service.url") + "camel-test/test");
    CloudBlockBlob cloudBlockBlob = new CloudBlockBlob(uri, credentials);
    return cloudBlockBlob;
}
 
Example 2
Source File: AzureBlobResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@PostConstruct
public void init() throws Exception {
    StorageCredentials credentials = StorageCredentials.tryParseCredentials(System.getProperty("azurite.credentials"));
    URI uri = new URI(System.getProperty("azurite.blob.service.url") + "camel-test");
    CloudBlobContainer container = new CloudBlobContainer(uri, credentials);
    container.create();
}
 
Example 3
Source File: AzureQueueResource.java    From camel-quarkus with Apache License 2.0 5 votes vote down vote up
@javax.enterprise.inject.Produces
@Named("azureQueueClient")
public CloudQueue createQueueClient() throws Exception {
    StorageCredentials credentials = StorageCredentials.tryParseCredentials(System.getProperty("azurite.credentials"));
    URI uri = new URI(System.getProperty("azurite.queue.service.url") + QUEUE_NAME);
    return new CloudQueue(uri, credentials);
}
 
Example 4
Source File: VideoConfig.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
public List<StorageCredentials> getStorageAzureAccounts() {
   List<StorageCredentials> result = new ArrayList<>();

   for (int i = 1; true; ++i) {
      String rawAccount = "video.storage.azure.account" + i;
      ConfigurationKey confAccount = new ConfigurationKey(rawAccount, KeyParser.parse(rawAccount));
      Supplier<String> supAccount = configProvider.getStringSupplier(confAccount, null);
      String account = (supAccount == null) ? null : supAccount.get();

      if (account == null || account.trim().isEmpty()) {
         break;
      }

      try {
         StorageCredentials creds = StorageCredentials.tryParseCredentials(account);
         if (creds == null) {
            throw new RuntimeException("invalid azure storage credentials");
         }

         result.add(creds);
      } catch (InvalidKeyException ex) {
         throw new RuntimeException(ex);
      }
   }

   return result;
}
 
Example 5
Source File: PreviewConfig.java    From arcusplatform with Apache License 2.0 5 votes vote down vote up
public List<StorageCredentials> getStorageAzureAccounts() {
	List<StorageCredentials> result = new ArrayList<>();

	for (int i = 1; true; ++i) {
		String rawAccount = "previews.storage.azure.account" + i;
		ConfigurationKey confAccount = new ConfigurationKey(rawAccount, KeyParser.parse(rawAccount));
		Supplier<String> supAccount = configProvider.getStringSupplier(confAccount, null);
		String account = (supAccount == null) ? null : supAccount.get();

		if (account == null || account.trim().isEmpty()) {
			break;
		}

		try {
			StorageCredentials creds = StorageCredentials.tryParseCredentials(account);
			if (creds == null) {
				throw new RuntimeException("invalid azure storage credentials");
			}

			result.add(creds);
		} catch (InvalidKeyException ex) {
			throw new RuntimeException(ex);
		}
	}

	return result;
}