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-"); AfdEndpointResource afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName); AfdEndpointPatch updateOptions = new AfdEndpointPatch(); updateOptions.Tags.Add("newTag", "newValue"); var lro = await afdEndpointInstance.UpdateAsync(WaitUntil.Completed, updateOptions); AfdEndpointResource updatedAfdEndpointInstance = lro.Value; ResourceDataHelper.AssertAfdEndpointUpdate(updatedAfdEndpointInstance, updateOptions); }
public static void AssertAfdEndpointUpdate(AfdEndpointResource updatedAfdEndpoint, AfdEndpointPatch 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]); } }
public virtual ArmOperation <AfdEndpointResource> Update(WaitUntil waitUntil, AfdEndpointPatch patch, CancellationToken cancellationToken = default) { Argument.AssertNotNull(patch, nameof(patch)); using var scope = _afdEndpointClientDiagnostics.CreateScope("AfdEndpointResource.Update"); scope.Start(); try { var response = _afdEndpointRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Name, Id.Name, patch, cancellationToken); var operation = new CdnArmOperation <AfdEndpointResource>(new AfdEndpointOperationSource(Client), _afdEndpointClientDiagnostics, Pipeline, _afdEndpointRestClient.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; } }