Search in sources :

Example 1 with CloudTableClient

use of com.microsoft.azure.storage.table.CloudTableClient in project stdlib by petergeneric.

the class ServiceManagerGuiceModule method getLogDataTable.

/**
 * For the Azure Log Store, the underlying table to use
 *
 * @param storageConnectionString
 *
 * @return
 *
 * @throws URISyntaxException
 * @throws StorageException
 * @throws InvalidKeyException
 */
@Provides
@Named("logdata")
public CloudTable getLogDataTable(@Named("azure.storage-connection-string") String storageConnectionString, @Named("azure.logging-table") String logTableName) throws URISyntaxException, StorageException, InvalidKeyException {
    // Retrieve storage account from connection-string.
    CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
    // Create the table client.
    CloudTableClient tableClient = storageAccount.createCloudTableClient();
    // Create the table if it doesn't exist.
    CloudTable table = tableClient.getTableReference(logTableName);
    table.createIfNotExists();
    return table;
}
Also used : CloudStorageAccount(com.microsoft.azure.storage.CloudStorageAccount) CloudTableClient(com.microsoft.azure.storage.table.CloudTableClient) CloudTable(com.microsoft.azure.storage.table.CloudTable) Named(com.google.inject.name.Named) Provides(com.google.inject.Provides)

Aggregations

Provides (com.google.inject.Provides)1 Named (com.google.inject.name.Named)1 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)1 CloudTable (com.microsoft.azure.storage.table.CloudTable)1 CloudTableClient (com.microsoft.azure.storage.table.CloudTableClient)1