Esempio n. 1
0
        public async Task GetAllStorageAccounts()
        {
            //create two storage accounts
            string accountName1 = await CreateValidAccountNameAsync(namePrefix);

            string accountName2 = await CreateValidAccountNameAsync(namePrefix);

            _resourceGroup = await CreateResourceGroupAsync();

            StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts();
            StorageAccount          account1 = (await storageAccountContainer.CreateOrUpdateAsync(accountName1, GetDefaultStorageAccountParameters())).Value;
            StorageAccount          account2 = (await storageAccountContainer.CreateOrUpdateAsync(accountName2, GetDefaultStorageAccountParameters())).Value;

            //validate two storage accounts
            int            count    = 0;
            StorageAccount account3 = null;
            StorageAccount account4 = null;

            await foreach (StorageAccount account in storageAccountContainer.GetAllAsync())
            {
                count++;
                if (account.Id.Name == accountName1)
                {
                    account3 = account;
                }
                if (account.Id.Name == accountName2)
                {
                    account4 = account;
                }
            }
            Assert.AreEqual(count, 2);
            VerifyAccountProperties(account3, true);
            VerifyAccountProperties(account4, true);
        }
 public async Task list()
 {
     #region Snippet:Managing_StorageAccounts_ListStorageAccounts
     StorageAccountContainer        accountContainer = resourceGroup.GetStorageAccounts();
     AsyncPageable <StorageAccount> response         = accountContainer.GetAllAsync();
     await foreach (StorageAccount storageAccount in response)
     {
         Console.WriteLine(storageAccount.Id.Name);
     }
     #endregion
 }
 public async Task ClearStorageAccount()
 {
     if (_resourceGroup != null)
     {
         StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts();
         await foreach (StorageAccount account in storageAccountContainer.GetAllAsync())
         {
             await account.DeleteAsync();
         }
         _resourceGroup  = null;
         _storageAccount = null;
     }
 }
Esempio n. 4
0
        public async Task ClearStorageAccounts()
        {
            //remove all storage accounts under current resource group
            if (_resourceGroup != null)
            {
                StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts();
                List <StorageAccount>   storageAccountList      = await storageAccountContainer.GetAllAsync().ToEnumerableAsync();

                foreach (StorageAccount account in storageAccountList)
                {
                    await account.DeleteAsync();
                }
                _resourceGroup = null;
            }
        }