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"); 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 PatchableAfdRuleData input = new PatchableAfdRuleData { 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 = new TimeSpan(0, 0, 30) })); ArmOperation <AfdRule> lro = await rule.UpdateAsync(WaitUntil.Completed, input); rule = lro.Value; #endregion Snippet:Managing_AfdRules_UpdateAnAzureFrontDoorRule }
public async Task CreateAfdRules() { #region Snippet:Managing_AfdRules_CreateAnAzureFrontDoorRule // Create a new azure front door profile string AfdProfileName = "myAfdProfile"; var input1 = new ProfileData("Global", new CdnSku { Name = CdnSkuName.StandardAzureFrontDoor }); ArmOperation <ProfileResource> lro1 = await resourceGroup.GetProfiles().CreateOrUpdateAsync(WaitUntil.Completed, AfdProfileName, input1); ProfileResource AfdProfileResource = lro1.Value; // Get the rule set collection from the specific azure front door ProfileResource and create a rule set string ruleSetName = "myAfdRuleSet"; ArmOperation <AfdRuleSet> lro2 = await AfdProfile.GetAfdRuleSets().CreateOrUpdateAsync(WaitUntil.Completed, ruleSetName); AfdRuleSet ruleSet = lro2.Value; // Get the rule collection from the specific rule set and create a rule string ruleName = "myAfdRule"; AfdRuleData input3 = new AfdRuleData { Order = 1 }; input3.Conditions.Add(new DeliveryRuleRequestUriCondition(new RequestUriMatchConditionParameters(RequestUriMatchConditionParametersOdataType.MicrosoftAzureCdnModelsDeliveryRuleRequestUriConditionParameters, RequestUriOperator.Any))); input3.Actions.Add(new DeliveryRuleCacheExpirationAction(new CacheExpirationActionParameters(CacheExpirationActionParametersOdataType.MicrosoftAzureCdnModelsDeliveryRuleCacheExpirationActionParameters, CacheBehavior.Override, CacheType.All) { CacheDuration = new TimeSpan(0, 0, 20) })); ArmOperation <AfdRule> lro3 = await ruleSet.GetAfdRules().CreateOrUpdateAsync(WaitUntil.Completed, ruleName, input3); AfdRule rule = lro3.Value; #endregion Snippet:Managing_AfdRules_CreateAnAzureFrontDoorRule }
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 ProfileResource AfdProfileResource = 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 }
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 ProfileResource AfdProfileResource = 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(WaitUntil.Completed); #endregion Snippet:Managing_AfdRules_DeleteAnAzureFrontDoorRule }