Custom Jq Templates - Azure/AzOps GitHub Wiki
Custom Jq Templates
Introduction
As a part of AzOps Pull, information retrieved from Azure is converted into files. This is performed at processing with jq which applies filters based on templates and re-structures information.
For scenarios where you need to customize the information filtered or its structure, AzOps supports the use of bring your own templates by configuring two settings: Core.SkipCustomJqTemplate and Core.CustomJqTemplatePath.
The setting Core.SkipCustomJqTemplate represents the flag to enable (false) or disable (true) the capability and Core.CustomJqTemplatePath is the path to the folder location of your custom templates (default's to .customtemplates).
Logic
What happens, when the following is set: "Core.SkipCustomJqTemplate": true and "Core.CustomJqTemplatePath": ".customtemplates"?
For retrieved resources, AzOps will look for a matching template file in the custom location. If no match is found AzOps falls back to built-in templates.
Template Folder and filename
AzOps performs transformation of pulled information in three high level steps.
-
Removal templates (templates specifying information to be filtered away)
- Look for folder matching
providerNamespaceand a file matchingresourceType.jq - If no match found default to
generic.jqat given template folder root
- Look for folder matching
-
Generating Template Parameter (treat policy definitions with json escaping)
- Look for folder matching
providerNamespaceand a file matchingresourceTypeName.parameters.jq - If no match found default to
template.parameters.jqat given template folder root
- Look for folder matching
-
Generating Template
- Look for folder matching
providerNamespaceand a file matchingresourceTypeName.template.jq - If no match found default to
template.jqat given template folder root
- Look for folder matching
Example of custom templates for policyExemptions, resulting in policyExemptions resources being transformed with custom templates (according to step 1 and 3 above) and all other resources being transformed with built-in:
.customtemplates
└── Microsoft.Authorization
├── policyExemptions.template.jq
└── policyExemptions.jq
Example of built-in base templates:
.built-in
├── Microsoft.Network
│ └── virtualnetworks.jq
├── generic.jq
├── template.jq
├── template.parameters.jq
└── templateChildResource.jq