public async Task AddTag() { #region Snippet:Managing_StorageAccounts_AddTagStorageAccount StorageAccountCollection accountCollection = resourceGroup.GetStorageAccounts(); StorageAccount storageAccount = await accountCollection.GetAsync("myAccount"); // add a tag on this storage account await storageAccount.AddTagAsync("key", "value"); #endregion }
public async Task AddRemoveTag() { //create storage account string accountName = await CreateValidAccountNameAsync(namePrefix); _resourceGroup = await CreateResourceGroupAsync(); StorageAccountContainer storageAccountContainer = _resourceGroup.GetStorageAccounts(); StorageAccountCreateParameters parameters = GetDefaultStorageAccountParameters(); StorageAccount account = (await storageAccountContainer.CreateOrUpdateAsync(accountName, parameters)).Value; //add tag to this storage account account = await account.AddTagAsync("key", "value"); //verify the tag is added successfully Assert.AreEqual(account.Data.Tags.Count, 1); //remove tag account = await account.RemoveTagAsync("key"); //verify the tag is removed successfully Assert.AreEqual(account.Data.Tags.Count, 0); }