Example #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
            Profile AfdProfile = await resourceGroup.GetProfiles().GetAsync("myAfdProfile");

            AfdRuleSet ruleSet = await AfdProfile.GetAfdRuleSets().GetAsync("myAfdRuleSet");

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

            // With UpdateAsync(), we can update the rule
            RuleUpdateOptions input = new RuleUpdateOptions
            {
                Order = 2
            };
            input.Conditions.Add(new DeliveryRuleRequestUriCondition(new RequestUriMatchConditionParameters(RequestUriMatchConditionParametersOdataType.MicrosoftAzureCdnModelsDeliveryRuleRequestUriConditionParameters, RequestUriOperator.Any)));
            input.Actions.Add(new DeliveryRuleCacheExpirationAction(new CacheExpirationActionParameters(CacheExpirationActionParametersOdataType.MicrosoftAzureCdnModelsDeliveryRuleCacheExpirationActionParameters, CacheBehavior.Override, CacheType.All)
            {
                CacheDuration = "00:00:30"
            }));
            AfdRuleUpdateOperation lro = await rule.UpdateAsync(true, input);

            rule = lro.Value;
            #endregion Snippet:Managing_AfdRules_UpdateAnAzureFrontDoorRule
        }
Example #2
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
            PatchableAfdRuleData input = new PatchableAfdRuleData
            {
                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
        }
Example #3
0
        public async Task ListAfdRules()
        {
            #region Snippet:Managing_AfdRules_ListAllAzureFrontDoorRules
            // First we need to get the azure front door rule collection from the specific rule set
            Profile AfdProfile = await resourceGroup.GetProfiles().GetAsync("myAfdProfile");

            AfdRuleSet ruleSet = await AfdProfile.GetAfdRuleSets().GetAsync("myAfdRuleSet");

            AfdRuleCollection ruleCollection = ruleSet.GetAfdRules();
            // With GetAllAsync(), we can get a list of the rule in the collection
            AsyncPageable <AfdRule> response = ruleCollection.GetAllAsync();
            await foreach (AfdRule rule in response)
            {
                Console.WriteLine(rule.Data.Name);
            }
            #endregion Snippet:Managing_AfdRules_ListAllAzureFrontDoorRules
        }
Example #4
0
        public async Task DeleteAfdRules()
        {
            #region Snippet:Managing_AfdRules_DeleteAnAzureFrontDoorRule
            // First we need to get the azure front door rule collection from the specific rule set
            Profile AfdProfile = await resourceGroup.GetProfiles().GetAsync("myAfdProfile");

            AfdRuleSet ruleSet = await AfdProfile.GetAfdRuleSets().GetAsync("myAfdRuleSet");

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

            // With DeleteAsync(), we can delete the rule
            await rule.DeleteAsync(true);

            #endregion Snippet:Managing_AfdRules_DeleteAnAzureFrontDoorRule
        }