public async Task UpdateInstances() { #region Snippet:Managing_Instances_UpdateAnInstance // First we need to get the instance collection from the specific account DeviceUpdateAccountResource account = await resourceGroup.GetDeviceUpdateAccounts().GetAsync("myAccount"); DeviceUpdateInstanceCollection instanceCollection = account.GetDeviceUpdateInstances(); // Now we can get the instance with GetAsync() DeviceUpdateInstanceResource instance = await instanceCollection.GetAsync("myInstance"); // With AddTagAsync(), we can add tag to the instance instance = await instance.AddTagAsync("newTag", "newValue"); #endregion Snippet:Managing_Instances_UpdateAnInstance }
public async Task AddTag() { SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-"); string accountName = Recording.GenerateAssetName("Account-"); DeviceUpdateAccountResource account = await CreateAccount(rg, accountName); string instanceName = Recording.GenerateAssetName("Instance-"); DeviceUpdateInstanceResource instance = await CreateInstance(account, instanceName); string key = "newTag", value = "newValue"; DeviceUpdateInstanceResource updatedInstance = await instance.AddTagAsync(key, value); CollectionAssert.AreEquivalent(new Dictionary <string, string> { { key, value } }, updatedInstance.Data.Tags); }