Exemplo n.º 1
0
        public async Task Update()
        {
            Subscription subscription = await Client.GetDefaultSubscriptionAsync();

            ResourceGroup rg = await CreateResourceGroup(subscription, "testRg-");

            string  afdProfileName = Recording.GenerateAssetName("AFDProfile-");
            Profile afdProfile     = await CreateAfdProfile(rg, afdProfileName, SkuName.StandardAzureFrontDoor);

            string      afdEndpointName     = Recording.GenerateAssetName("AFDEndpoint-");
            AfdEndpoint afdEndpointInstance = await CreateAfdEndpoint(afdProfile, afdEndpointName);

            string         afdOriginGroupName     = Recording.GenerateAssetName("AFDOriginGroup-");
            AfdOriginGroup afdOriginGroupInstance = await CreateAfdOriginGroup(afdProfile, afdOriginGroupName);

            string    afdOriginName     = Recording.GenerateAssetName("AFDOrigin-");
            AfdOrigin afdOriginInstance = await CreateAfdOrigin(afdOriginGroupInstance, afdOriginName);

            string     afdRuleSetName = Recording.GenerateAssetName("AFDRuleSet");
            AfdRuleSet afdRuleSet     = await CreateAfdRuleSet(afdProfile, afdRuleSetName);

            string   afdRouteName = Recording.GenerateAssetName("AFDRoute");
            AfdRoute afdRoute     = await CreateAfdRoute(afdEndpointInstance, afdRouteName, afdOriginGroupInstance, afdRuleSet);

            AfdRouteUpdateOptions updateOptions = new AfdRouteUpdateOptions
            {
                EnabledState = EnabledState.Disabled
            };
            var lro = await afdRoute.UpdateAsync(true, updateOptions);

            AfdRoute updatedAfdRoute = lro.Value;

            ResourceDataHelper.AssertAfdRouteUpdate(updatedAfdRoute, updateOptions);
        }
Exemplo n.º 2
0
        public virtual ArmOperation <AfdRoute> Update(bool waitForCompletion, AfdRouteUpdateOptions options, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(options, nameof(options));

            using var scope = _afdRouteClientDiagnostics.CreateScope("AfdRoute.Update");
            scope.Start();
            try
            {
                var response  = _afdRouteRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, options, cancellationToken);
                var operation = new CdnArmOperation <AfdRoute>(new AfdRouteOperationSource(Client), _afdRouteClientDiagnostics, Pipeline, _afdRouteRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, options).Request, response, OperationFinalStateVia.OriginalUri);
                if (waitForCompletion)
                {
                    operation.WaitForCompletion(cancellationToken);
                }
                return(operation);
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
 public static void AssertAfdRouteUpdate(AfdRoute updatedRoute, AfdRouteUpdateOptions updateOptions)
 {
     Assert.AreEqual(updatedRoute.Data.EnabledState, updateOptions.EnabledState);
 }