static void Main(string[] args)
{
string token = GetAuthorizationHeader();
TokenCredentials credential = new TokenCredentials(token);
ResourceManagementClient resourcesClient = new ResourceManagementClient(credential) { SubscriptionId = subscriptionId };
StorageManagementClient storageMgmtClient = new StorageManagementClient(credential) { SubscriptionId = subscriptionId };
try
{
//Register the Storage Resource Provider with the Subscription
RegisterStorageResourceProvider(resourcesClient);
//Create a new resource group
CreateResourceGroup(rgName, resourcesClient);
//Create a new account in a specific resource group with the specified account name
CreateStorageAccount(rgName, accountName, storageMgmtClient);
//Get all the account properties for a given resource group and account name
StorageAccount storAcct = storageMgmtClient.StorageAccounts.GetProperties(rgName, accountName);
//Get a list of storage accounts within a specific resource group
IEnumerable<StorageAccount> storAccts = storageMgmtClient.StorageAccounts.ListByResourceGroup(rgName);
//Get all the storage accounts for a given subscription
IEnumerable<StorageAccount> storAcctsSub = storageMgmtClient.StorageAccounts.List();
//Get the storage account keys for a given account and resource group
IList<StorageAccountKey> acctKeys = storageMgmtClient.StorageAccounts.ListKeys(rgName, accountName).Keys;
//Regenerate the account key for a given account in a specific resource group
IList<StorageAccountKey> regenAcctKeys = storageMgmtClient.StorageAccounts.RegenerateKey(rgName, accountName, "key1").Keys;
//Update the storage account for a given account name and resource group
UpdateStorageAccountSku(rgName, accountName, SkuName.StandardLRS, storageMgmtClient);
//Check if the account name is available
bool? nameAvailable = storageMgmtClient.StorageAccounts.CheckNameAvailability(accountName).NameAvailable;
//Delete a storage account with the given account name and a resource group
DeleteStorageAccount(rgName, accountName, storageMgmtClient);
Console.ReadLine();
}
catch(Exception e)
{
Console.WriteLine(e.Message);
Console.ReadLine();
}
}