public async Task Update() { SubscriptionResource subscription = await Client.GetDefaultSubscriptionAsync(); ResourceGroupResource rg = await CreateResourceGroup(subscription, "testRg-"); string afdProfileName = Recording.GenerateAssetName("AFDProfile-"); ProfileResource afdProfile = await CreateAfdProfile(rg, afdProfileName, CdnSkuName.StandardAzureFrontDoor); string afdEndpointName = Recording.GenerateAssetName("AFDEndpoint-"); FrontDoorEndpointResource afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); FrontDoorEndpointPatch updateOptions = new FrontDoorEndpointPatch(); updateOptions.Tags.Add("newTag", "newValue"); var lro = await afdEndpointInstance.UpdateAsync(WaitUntil.Completed, updateOptions); FrontDoorEndpointResource updatedAfdEndpointInstance = lro.Value; ResourceDataHelper.AssertAfdEndpointUpdate(updatedAfdEndpointInstance, updateOptions); }
public virtual ArmOperation <FrontDoorEndpointResource> Update(WaitUntil waitUntil, FrontDoorEndpointPatch patch, CancellationToken cancellationToken = default) { Argument.AssertNotNull(patch, nameof(patch)); using var scope = _frontDoorEndpointClientDiagnostics.CreateScope("FrontDoorEndpointResource.Update"); scope.Start(); try { var response = _frontDoorEndpointRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); var operation = new CdnArmOperation <FrontDoorEndpointResource>(new FrontDoorEndpointOperationSource(Client), _frontDoorEndpointClientDiagnostics, Pipeline, _frontDoorEndpointRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch).Request, response, OperationFinalStateVia.AzureAsyncOperation); if (waitUntil == WaitUntil.Completed) { operation.WaitForCompletion(cancellationToken); } return(operation); } catch (Exception e) { scope.Failed(e); throw; } }
public static void AssertAfdEndpointUpdate(FrontDoorEndpointResource updatedAfdEndpoint, FrontDoorEndpointPatch updateOptions) { Assert.AreEqual(updatedAfdEndpoint.Data.Tags.Count, updateOptions.Tags.Count); foreach (var kv in updatedAfdEndpoint.Data.Tags) { Assert.True(updateOptions.Tags.ContainsKey(kv.Key)); Assert.AreEqual(kv.Value, updateOptions.Tags[kv.Key]); } }