本文整理汇总了Java中com.microsoft.azure.storage.CloudStorageAccount.parse方法的典型用法代码示例。如果您正苦于以下问题:Java CloudStorageAccount.parse方法的具体用法?Java CloudStorageAccount.parse怎么用?Java CloudStorageAccount.parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.microsoft.azure.storage.CloudStorageAccount
的用法示例。
在下文中一共展示了CloudStorageAccount.parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectToAzTable
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
/***
*
* @param azStorageConnStr
* @param tableName
* @param l
* @return
*/
public CloudTable connectToAzTable(String azStorageConnStr, String tableName) {
CloudTable cloudTable = null;
try {
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(azStorageConnStr);
// Create the table client
CloudTableClient tableClient = storageAccount.createCloudTableClient();
// Create a cloud table object for the table.
cloudTable = tableClient.getTableReference(tableName);
} catch (Exception e)
{
logger.warn("Exception in connectToAzTable: "+tableName, e);
}
return cloudTable;
}
示例2: createClient
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
void createClient(AzureStorageSettings azureStorageSettings) {
try {
logger.trace("creating new Azure storage client using account [{}], key [{}]",
azureStorageSettings.getAccount(), azureStorageSettings.getKey());
String storageConnectionString =
"DefaultEndpointsProtocol=https;"
+ "AccountName=" + azureStorageSettings.getAccount() + ";"
+ "AccountKey=" + azureStorageSettings.getKey();
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
// Create the blob client.
CloudBlobClient client = storageAccount.createCloudBlobClient();
// Register the client
this.clients.put(azureStorageSettings.getAccount(), client);
} catch (Exception e) {
logger.error("can not create azure storage client: {}", e.getMessage());
}
}
示例3: setUpStorageAccount
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
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);
}
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:19,代码来源:ManageLinuxWebAppStorageAccountConnection.java
示例4: getCloudBlobContainer
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private CloudBlobContainer getCloudBlobContainer(String accountName, String accountKey, String containerName) {
CloudBlobContainer container = null;
if (StringUtils.isNotBlank(containerName)) {
final String storageConnectionString = "DefaultEndpointsProtocol=https"
+ ";AccountName=" + accountName
+ ";AccountKey=" + accountKey;
try {
final CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString);
CloudBlobClient serviceClient = account.createCloudBlobClient();
container = serviceClient.getContainerReference(containerName);
container.createIfNotExists();
} catch (StorageException | URISyntaxException | InvalidKeyException e) {
logger.error("Error connecting to container for account {} and container name {}", accountName, containerName, e);
}
}
return container;
}
示例5: AzureNotebookRepo
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
public AzureNotebookRepo(ZeppelinConfiguration conf)
throws URISyntaxException, InvalidKeyException, StorageException {
this.conf = conf;
user = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_USER);
shareName = conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_SHARE);
CloudStorageAccount account = CloudStorageAccount.parse(
conf.getString(ZeppelinConfiguration.ConfVars.ZEPPELIN_NOTEBOOK_AZURE_CONNECTION_STRING));
CloudFileClient client = account.createCloudFileClient();
CloudFileShare share = client.getShareReference(shareName);
share.createIfNotExists();
CloudFileDirectory userDir = StringUtils.isBlank(user) ?
share.getRootDirectoryReference() :
share.getRootDirectoryReference().getDirectoryReference(user);
userDir.createIfNotExists();
rootDir = userDir.getDirectoryReference("notebook");
rootDir.createIfNotExists();
}
示例6: testCreateContainer
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@Before
public void testCreateContainer() {
try {
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(storageConnectionString);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
// Get a reference to a container.
// The container name must be lower case
container = blobClient.getContainerReference(containerName);
// Create the container if it does not exist.
container.createIfNotExists();
} catch (Exception e) {
// Output the stack trace.
e.printStackTrace();
}
}
示例7: validateWasbFileSystem
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private void validateWasbFileSystem(FileSystem fileSystem, String fileSystemType) throws URISyntaxException, InvalidKeyException, StorageException {
String accountName = fileSystem.getParameter(WasbFileSystemConfiguration.ACCOUNT_NAME, String.class);
String accountKey = fileSystem.getParameter(WasbFileSystemConfiguration.ACCOUNT_KEY, String.class);
String connectionString = "DefaultEndpointsProtocol=https;AccountName=" + accountName + ";AccountKey=" + accountKey;
CloudStorageAccount storageAccount = CloudStorageAccount.parse(connectionString);
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
CloudBlobContainer containerReference = blobClient.getContainerReference(TEST_CONTAINER + System.nanoTime());
try {
containerReference.createIfNotExists();
containerReference.delete();
} catch (StorageException e) {
if (e.getCause() instanceof UnknownHostException) {
throw new CloudConnectorException("The provided account does not belong to a valid storage account");
}
}
}
示例8: getLogDataTable
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
/**
* 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;
}
示例9: getContainer
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private CloudBlobContainer getContainer() throws Exception {
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount
.parse(storageConnectionString);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
Timber.d(blobClient.getEndpoint().toString());
// Get a reference to a container.
// The container name must be lower case
CloudBlobContainer container = blobClient.getContainerReference(CONTAINER_NAME);
return container;
}
示例10: getCloudStorageAccount
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
protected CloudStorageAccount getCloudStorageAccount(final FunctionApp app) throws Exception {
final AppSetting internalStorageSetting = app.appSettings().get(INTERNAL_STORAGE_KEY);
if (internalStorageSetting == null || StringUtils.isEmpty(internalStorageSetting.value())) {
logError(INTERNAL_STORAGE_NOT_FOUND);
throw new Exception(INTERNAL_STORAGE_NOT_FOUND);
}
logDebug(INTERNAL_STORAGE_CONNECTION_STRING + internalStorageSetting.value());
return CloudStorageAccount.parse(internalStorageSetting.value());
}
示例11: getStorageAccount
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@Bean
public CloudStorageAccount getStorageAccount() throws InvalidKeyException, URISyntaxException {
String cs = String.format("DefaultEndpointsProtocol=http;AccountName=%s;AccountKey=%s",
azureStorageProperties.getName(),
azureStorageProperties.getKey());
return CloudStorageAccount.parse(cs);
}
示例12: getStorageAccount
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@Bean
public CloudStorageAccount getStorageAccount() throws InvalidKeyException, URISyntaxException {
String cs = String.format("DefaultEndpointsProtocol=http;AccountName=%s;AccountKey=%s",
azureStorageProperties.getName(),
azureStorageProperties.getKey());
return CloudStorageAccount.parse(cs);
}
示例13: getContainer
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
private static CloudBlobContainer getContainer() throws Exception {
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount
.parse(storageConnectionString);
// Create the blob client.
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
// Get a reference to a container.
// The container name must be lower case
CloudBlobContainer container = blobClient.getContainerReference("images");
return container;
}
示例14: AzureStore
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@SuppressWarnings("resource")
public AzureStore() throws InvalidKeyException, URISyntaxException,
StorageException, IOException {
FileReader fileReader = new FileReader("/secret/azure.key");
BufferedReader bufferedReader = new BufferedReader(fileReader);
String accountName = bufferedReader.readLine();
String accountKey = bufferedReader.readLine();
CloudStorageAccount account = CloudStorageAccount
.parse("DefaultEndpointsProtocol=http;" + "AccountName="
+ accountName + ";" + "AccountKey=" + accountKey);
CloudBlobClient serviceClient = account.createCloudBlobClient();
container = serviceClient
.getContainerReference(Constants.AZURE_CONTAINER_NAME);
container.createIfNotExists();
}
示例15: getAccount
import com.microsoft.azure.storage.CloudStorageAccount; //导入方法依赖的package包/类
@Override
public CloudStorageAccount getAccount() {
String envValue = System.getenv(storageConnectionStringEnvKey);
if (envValue == null || envValue == "")
throw new IllegalStateException("No " + storageConnectionStringEnvKey + " environment variable was provided while trying to load the Azure Storage Connection String");
try {
return CloudStorageAccount.parse(envValue);
} catch (URISyntaxException | InvalidKeyException | IllegalArgumentException e) {
throw new IllegalStateException(e);
}
}