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
        }
        public virtual Response <DeviceUpdateInstance> Update(TagUpdateOptions tagUpdatePayload, CancellationToken cancellationToken = default)
        {
            if (tagUpdatePayload == null)
            {
                throw new ArgumentNullException(nameof(tagUpdatePayload));
            }

            using var scope = _deviceUpdateInstanceInstancesClientDiagnostics.CreateScope("DeviceUpdateInstance.Update");
            scope.Start();
            try
            {
                var response = _deviceUpdateInstanceInstancesRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, tagUpdatePayload, cancellationToken);
                return(Response.FromValue(new DeviceUpdateInstance(ArmClient, response.Value), response.GetRawResponse()));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
Exemple #3
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);
        }
Exemple #4
0
        //public static void AssertAccountUpdate(DeviceUpdateAccount updatedAccount, DeviceUpdateAccountUpdateOptions updateParameters)
        //{
        //    Assert.AreEqual(updatedAccount.Data.Location, updateParameters.Location);
        //    if (updatedAccount.Data.Identity != null || updateParameters.Identity != null)
        //    {
        //        Assert.NotNull(updatedAccount.Data.Identity);
        //        Assert.NotNull(updateParameters.Identity);
        //        Assert.AreEqual(updatedAccount.Data.Identity.Type, updateParameters.Identity.Type);
        //    }
        //}

        public static void AssertInstanceUpdate(DeviceUpdateInstance updatedInstance, TagUpdateOptions updateParameters)
        {
            foreach (var kv in updatedInstance.Data.Tags)
            {
                Assert.True(updateParameters.Tags.ContainsKey(kv.Key));
                Assert.AreEqual(kv.Value, updateParameters.Tags[kv.Key]);
            }
        }