public static void AssertAccountUpdate(DeviceUpdateAccount updatedAccount, PatchableDeviceUpdateAccountData 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); } }
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 PatchableDeviceUpdateAccountData updateOptions = new PatchableDeviceUpdateAccountData() { 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 }
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); PatchableDeviceUpdateAccountData updateOptions = new PatchableDeviceUpdateAccountData() { 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); }
public virtual ArmOperation <DeviceUpdateAccount> Update(WaitUntil waitUntil, PatchableDeviceUpdateAccountData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _deviceUpdateAccountAccountsClientDiagnostics.CreateScope("DeviceUpdateAccount.Update"); scope.Start(); try { var response = _deviceUpdateAccountAccountsRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data, cancellationToken); var operation = new DeviceUpdateArmOperation <DeviceUpdateAccount>(new DeviceUpdateAccountOperationSource(Client), _deviceUpdateAccountAccountsClientDiagnostics, Pipeline, _deviceUpdateAccountAccountsRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Name, data).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }