Exemplo n.º 1
0
        public async Task Update()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await subscription.GetResourceGroups().GetAsync("DeviceUpdateResourceGroup");

            DeviceUpdateAccount account = await rg.GetDeviceUpdateAccounts().GetAsync("AzureDeviceUpdateAccount");

            DeviceUpdateInstance instance = await account.GetDeviceUpdateInstances().GetAsync("Instance");

            TagUpdateOptions updateOptions = new TagUpdateOptions();

            updateOptions.Tags.Add("newTag", "newValue");
            DeviceUpdateInstance updatedInstance = await instance.UpdateAsync(updateOptions);

            ResourceDataHelper.AssertInstanceUpdate(updatedInstance, updateOptions);
            updateOptions.Tags.Clear();
            updatedInstance = await instance.UpdateAsync(updateOptions);

            ResourceDataHelper.AssertInstanceUpdate(updatedInstance, updateOptions);
        }
        public async Task UpdateInstances()
        {
            #region Snippet:Managing_Instances_UpdateAnInstance
            // First we need to get the instance collection from the specific account
            DeviceUpdateAccount account = await resourceGroup.GetDeviceUpdateAccounts().GetAsync("myAccount");

            DeviceUpdateInstanceCollection instanceCollection = account.GetDeviceUpdateInstances();
            // Now we can get the instance with GetAsync()
            DeviceUpdateInstance instance = await instanceCollection.GetAsync("myInstance");

            // With UpdateAsync(), we can update the instance
            TagUpdateOptions updateOptions = new TagUpdateOptions();
            updateOptions.Tags.Add("newTag", "newValue");
            instance = await instance.UpdateAsync(updateOptions);

            #endregion Snippet:Managing_Instances_UpdateAnInstance
        }