public virtual Response <ResourceGroupResource> Update(PatchableResourceGroupData data, CancellationToken cancellationToken = default) { Argument.AssertNotNull(data, nameof(data)); using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroupResource.Update"); scope.Start(); try { var response = _resourceGroupRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, data, cancellationToken); return(Response.FromValue(new ResourceGroupResource(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task Update() { var rgName = Recording.GenerateAssetName("testrg"); SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); var rg1Op = await subscription.GetResourceGroups().CreateOrUpdateAsync(WaitUntil.Completed, rgName, new ResourceGroupData(AzureLocation.WestUS2)); ResourceGroupResource rg1 = rg1Op.Value; var parameters = new PatchableResourceGroupData { Name = rgName }; ResourceGroupResource rg2 = await rg1.UpdateAsync(parameters); Assert.AreEqual(rg1.Data.Name, rg2.Data.Name); Assert.AreEqual(rg1.Data.Id, rg2.Data.Id); Assert.AreEqual(rg1.Data.ResourceType, rg2.Data.ResourceType); Assert.AreEqual(rg1.Data.Properties.ProvisioningState, rg2.Data.Properties.ProvisioningState); Assert.AreEqual(rg1.Data.Location, rg2.Data.Location); Assert.AreEqual(rg1.Data.ManagedBy, rg2.Data.ManagedBy); Assert.AreEqual(rg1.Data.Tags, rg2.Data.Tags); Assert.ThrowsAsync <ArgumentNullException>(async() => _ = await rg1.UpdateAsync(null)); }