コード例 #1
0
        public async Task UpdateAccounts()
        {
            #region Snippet:Managing_Accounts_UpdateAnAccount
            // First we need to get the account collection from the specific resource group
            DeviceUpdateAccountCollection accountCollection = resourceGroup.GetDeviceUpdateAccounts();
            // Now we can get the account with GetAsync()
            DeviceUpdateAccountResource account = await accountCollection.GetAsync("myAccount");

            // With UpdateAsync(), we can update the account
            DeviceUpdateAccountPatch updateOptions = new DeviceUpdateAccountPatch()
            {
                Location = AzureLocation.WestUS2,
                Identity = new ManagedServiceIdentity(ResourceManager.Models.ManagedServiceIdentityType.None)
            };
            ArmOperation <DeviceUpdateAccountResource> lro = await account.UpdateAsync(WaitUntil.Completed, updateOptions);

            account = lro.Value;
            #endregion Snippet:Managing_Accounts_UpdateAnAccount
        }
コード例 #2
0
        public async Task Update()
        {
            SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-");

            string accountName = Recording.GenerateAssetName("Account-");
            DeviceUpdateAccountResource account = await CreateAccount(rg, accountName);

            DeviceUpdateAccountPatch updateOptions = new DeviceUpdateAccountPatch()
            {
                Location = AzureLocation.WestUS2,
                Identity = new ManagedServiceIdentity(ResourceManager.Models.ManagedServiceIdentityType.None)
            };
            var lro = await account.UpdateAsync(WaitUntil.Completed, updateOptions);

            DeviceUpdateAccountResource updatedAccount = lro.Value;

            ResourceDataHelper.AssertAccountUpdate(updatedAccount, updateOptions);
        }
コード例 #3
0
 public static void AssertAccountUpdate(DeviceUpdateAccountResource updatedAccount, DeviceUpdateAccountPatch updateParameters)
 {
     Assert.AreEqual(updatedAccount.Data.Location.ToString(), updateParameters.Location);
     if (updatedAccount.Data.Identity != null || updateParameters.Identity != null)
     {
         Assert.NotNull(updatedAccount.Data.Identity);
         Assert.NotNull(updateParameters.Identity);
         Assert.AreEqual(updatedAccount.Data.Identity.ManagedServiceIdentityType, updateParameters.Identity.ManagedServiceIdentityType);
     }
 }
コード例 #4
0
        public virtual ArmOperation <DeviceUpdateAccountResource> Update(WaitUntil waitUntil, DeviceUpdateAccountPatch patch, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(patch, nameof(patch));

            using var scope = _deviceUpdateAccountAccountsClientDiagnostics.CreateScope("DeviceUpdateAccountResource.Update");
            scope.Start();
            try
            {
                var response  = _deviceUpdateAccountAccountsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch, cancellationToken);
                var operation = new DeviceUpdateArmOperation <DeviceUpdateAccountResource>(new DeviceUpdateAccountOperationSource(Client), _deviceUpdateAccountAccountsClientDiagnostics, Pipeline, _deviceUpdateAccountAccountsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation);
                if (waitUntil == WaitUntil.Completed)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }