Пример #1
0
        public async Task UpdateAfdRules()
        {
            #region Snippet:Managing_AfdRules_UpdateAnAzureFrontDoorRule
            // First we need to get the azure front door rule collection from the specific rule set
            ProfileResource AfdProfileResource = await resourceGroup.GetProfiles().GetAsync("myAfdProfile");

            AfdRuleSetResource ruleSet = await AfdProfileResource.GetAfdRuleSets().GetAsync("myAfdRuleSet");

            AfdRuleCollection ruleCollection = ruleSet.GetAfdRules();
            // Now we can get the rule with GetAsync()
            AfdRuleResource rule = await ruleCollection.GetAsync("myAfdRule");

            // With UpdateAsync(), we can update the rule
            AfdRulePatch input = new AfdRulePatch
            {
                Order = 2
            };
            input.Conditions.Add(new DeliveryRuleRequestUriCondition(new RequestUriMatchConditionParameters(RequestUriMatchConditionParametersTypeName.DeliveryRuleRequestUriConditionParameters, RequestUriOperator.Any)));
            input.Actions.Add(new DeliveryRuleCacheExpirationAction(new CacheExpirationActionParameters(CacheExpirationActionParametersTypeName.DeliveryRuleCacheExpirationActionParameters, CacheBehavior.Override, CacheType.All)
            {
                CacheDuration = new TimeSpan(0, 0, 30)
            }));
            ArmOperation <AfdRuleResource> lro = await rule.UpdateAsync(WaitUntil.Completed, input);

            rule = lro.Value;
            #endregion Snippet:Managing_AfdRules_UpdateAnAzureFrontDoorRule
        }
Пример #2
0
        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             afdRuleSetName = Recording.GenerateAssetName("AFDRuleSet");
            AfdRuleSetResource afdRuleSet     = await CreateAfdRuleSet(afdProfile, afdRuleSetName);

            string          afdRuleName = Recording.GenerateAssetName("AFDRule");
            AfdRuleResource afdRule     = await CreateAfdRule(afdRuleSet, afdRuleName);

            AfdRulePatch updateOptions = new AfdRulePatch
            {
                Order = 2
            };

            updateOptions.Conditions.Add(ResourceDataHelper.CreateDeliveryRuleCondition());
            updateOptions.Actions.Add(ResourceDataHelper.CreateDeliveryRuleOperation());
            var lro = await afdRule.UpdateAsync(WaitUntil.Completed, updateOptions);

            AfdRuleResource updatedAfdRule = lro.Value;

            ResourceDataHelper.AssertAfdRuleUpdate(updatedAfdRule, updateOptions);
        }
Пример #3
0
        public virtual ArmOperation <AfdRuleResource> Update(WaitUntil waitUntil, AfdRulePatch patch, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(patch, nameof(patch));

            using var scope = _afdRuleClientDiagnostics.CreateScope("AfdRuleResource.Update");
            scope.Start();
            try
            {
                var response  = _afdRuleRestClient.Update(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, Id.Parent.Name, Id.Name, patch, cancellationToken);
                var operation = new CdnArmOperation <AfdRuleResource>(new AfdRuleOperationSource(Client), _afdRuleClientDiagnostics, Pipeline, _afdRuleRestClient.CreateUpdateRequest(Id.SubscriptionId, Id.ResourceGroupName, Id.Parent.Parent.Name, 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 AssertAfdRuleUpdate(AfdRuleResource updatedRule, AfdRulePatch updateOptions)
 {
     Assert.AreEqual(updatedRule.Data.Order, updateOptions.Order);
 }