public virtual Response <ResourceGroup> Update(ResourceGroupUpdateOptions options, CancellationToken cancellationToken = default) { Argument.AssertNotNull(options, nameof(options)); using var scope = _resourceGroupClientDiagnostics.CreateScope("ResourceGroup.Update"); scope.Start(); try { var response = _resourceGroupRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, options, cancellationToken); return(Response.FromValue(new ResourceGroup(Client, response.Value), response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } }
public async Task Update() { var rgName = Recording.GenerateAssetName("testrg"); Subscription subscription = await Client.GetDefaultSubscriptionAsync().ConfigureAwait(false); var rg1Op = await subscription.GetResourceGroups().CreateOrUpdateAsync(true, rgName, new ResourceGroupData(AzureLocation.WestUS2)); ResourceGroup rg1 = rg1Op.Value; var parameters = new ResourceGroupUpdateOptions { Name = rgName }; ResourceGroup 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.Type, rg2.Data.Type); 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)); }