I am using Azure Front Door Standard/Premium and have already manually enabled compression for my UI routes via Azure Portal. I wanted to map this configuration as IaC with Bicep. However, there was no proper documentation on how to do this. My attempts:
- I checked the Azure Bicep templates for Azure Front Door routes. Here I found a reference to a property
compressionSettings: any()
, whose usage was not further specified. - My next approach was to export the manual configuration in the portal via "Export template" as ARM and then compile it to Bicep. However, the
compressionSettings
property always kept the value{}
. If I deploy my bicep template with the valuecompressionSettings: {}
, then the compression in the portal remains disabled.
So how can I enable compression for Azure Front Door using Bicep?
CodePudding user response:
I found the solution by manually searching in azure-quickstart-templates. At the bottom of the page: Microsoft.Cdn profiles/afdEndpoints/routes 2020-09-01, I found the template Front Door Standard/Premium. After analyzing the main.bicep
file here, the compression settings must be set as follows:
compressionSettings: {
contentTypesToCompress: [
'application/javascript'
'application/json'
'font/woff'
'font/woff2'
'image/svg xml'
'image/x-icon'
'text/css'
'text/html'
]
isCompressionEnabled: true
}
Within a section of my entire code it then looks like this:
var contentTypesToCompress = [
'application/javascript'
'application/json'
'font/woff'
'font/woff2'
'image/svg xml'
'image/x-icon'
'text/css'
'text/html'
]
resource profile 'Microsoft.Cdn/profiles@2020-09-01' = {
name: 'frontDoor'
location: 'global'
sku: {
name: 'Premium_AzureFrontDoor'
}
tags: tags
}
resource endpoint 'Microsoft.Cdn/profiles/afdEndpoints@2020-09-01' = {
parent: profile
name: 'endpoint'
location: 'Global'
tags: tags
properties: {
originResponseTimeoutSeconds: 60
enabledState: 'Enabled'
}
}
resource route 'Microsoft.Cdn/profiles/afdEndpoints/routes@2020-09-01' = {
parent: endpoint
name: 'route'
properties: {
queryStringCachingBehavior: 'IgnoreQueryString'
compressionSettings: {
contentTypesToCompress: contentTypesToCompress
isCompressionEnabled: true
}
...
}
dependsOn: [
profile
]
}
Since this has not really been documented anywhere so far, I thought it would be useful to share this here in Q&A-style.