question

RajNair avatar image
0 Votes"
RajNair asked GitaraniSharmaMSFT-4262 commented

FrontDoor: Add Rules/Ruleset from JSON file

Is there anyway we can add ruleset/rules in frontdoor from a JSON file using CLI command....
If json file is not possible, is there any other way we can add it through any other file format...

basically i wanted to separate the rules from the CLI commands...

azure-front-doordotnet-cli
· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @RajNair ,

Welcome to Microsoft Q&A Platform. Thank you for reaching out & hope you are doing well.

I understand that you would like to know if there is a way to add ruleset/rules in Azure Frontdoor from a JSON file using CLI command.

Yes, it should be possible to add ruleset/rules in Azure Frontdoor from a JSON file using CLI command.
You can make an ARM template call, on the existing Frontdoor, adding the reference to rules engine. Save the ARM template file locally and import it using CLI commands.

Refer : https://docs.microsoft.com/en-us/azure/templates/microsoft.network/frontdoors/rulesengines?pivots=deployment-language-arm-template#arm-template-resource-definition

https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-cli#deploy-local-template

https://github.com/Azure/azure-quickstart-templates/tree/master/quickstarts/microsoft.cdn/front-door-standard-premium-rule-set/

Did you try this method?

Regards,
Gita

0 Votes 0 ·
RajNair avatar image RajNair GitaraniSharmaMSFT-4262 ·

241537-front.txt




I created this template file with just one rule to add to the existing rule set in the current frontdoor... but when i ran the cli command it says

az deployment group create --name ExampleDeployment --resource-group Examplegroup --template-file front.json


{"code": "InvalidRequestContent", "message": "The request content was invalid and could not be deserialized: 'Could not find member 'type' on object of type 'Template'. Path 'properties.template.type', line 2, position 9.'."}

Looks like there is some issue in my json file? @GitaraniSharmaMSFT-4262

0 Votes 0 ·
front.txt (1.6 KiB)

Hello @RajNair ,

Thank you for the details.

I'll check the template and also discuss this internally with the Azure Front Door Product Group team as there was an issue with ARM template deployment of AFD Rules before.
Refer : https://github.com/MicrosoftDocs/azure-docs/issues/64756
https://github.com/MicrosoftDocs/azure-docs/issues/65782
https://github.com/MicrosoftDocs/azure-docs/issues/61497

Regards,
Gita

0 Votes 0 ·

Hello @RajNair ,

Apologies for the delay in response.

The format of the shared template seems to be incorrect. Could you try to put rule definition under resource property?
Refer : https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/syntax#template-format

Also, you need to remove the “dependsOn” elements. It is used to define the resource deployment order and only needed if the dependent resources are also defined in the template.

Attaching a sample template for your reference.

Regards,
Gita

245621-afdruleset.txt


0 Votes 0 ·
afdruleset.txt (1.4 KiB)

0 Answers