azure - 如何使用 Bicep 激活 Azure Front Door 路线的压缩?

标签 azure compression azure-rm-template infrastructure-as-code azure-bicep

我正在使用 Azure Front Door 标准版/高级版,并且已经通过 Azure 门户手动启用了我的 UI 路由的压缩。我想将此配置映射为带有 Bicep 的 IaC。但是,没有关于如何执行此操作的适当文档。我的尝试:

  1. 我检查了Azure Bicep templates for Azure Front Door routes 。在这里我发现了对属性 compressionSettings: any() 的引用,其用法没有进一步指定。
  2. 我的下一个方法是通过“导出模板”将门户中的手动配置导出为 ARM,然后将其编译为 Bicep。不过,compressionSettings 属性始终保留值 {}。如果我使用值 compressionSettings: {} 部署二头肌模板,则门户中的压缩将保持禁用状态。

那么如何使用 Bicep 为 Azure Front Door 启用压缩?

最佳答案

我通过手动搜索 azure-quickstart-templates 找到了解决方案。页面底部:Microsoft.Cdn profiles/afdEndpoints/routes 2020-09-01 ,我找到了模板Front Door Standard/Premium 。分析完这里的 main.bicep 文件后,压缩设置必须设置如下:

compressionSettings: {
   contentTypesToCompress: [
     'application/javascript'
     'application/json'
     'font/woff'
     'font/woff2'
     'image/svg+xml'
     'image/x-icon'
     'text/css'
     'text/html'
   ]
   isCompressionEnabled: true
}

在我的整个代码的一部分中,它看起来像这样:

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
  ]
}

由于到目前为止还没有真正记录在案,我认为在 Q&A-style 中分享这一点会很有用。 .

关于azure - 如何使用 Bicep 激活 Azure Front Door 路线的压缩?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71097037/

相关文章:

javascript - Azure移动服务成功回调 `push.apns.send`

azure - 如何使用 Terraform 将所有流量重定向到 Azure 中的域

azure - 如何将操作组导出到 Azure 中的 ARM 模板?

php - 如何使用php压缩视频文件的大小,同时上传到支持ffmpeg的服务器?

部署时 Azure Function Runtime 版本设置为 ~1

json - 通过 ARM 模板将子网添加到现有 Vnet

python - 如何根据服务主体 ID 限制对 azure 函数的访问

azure - Azure SQL 数据库的可视化查询设计器?

c++ - DICOM 访问压缩数据 (DCMTK)

java - 如果我使用 org.apache.hadoop.mapreduce(新)API,如何配置 Hadoop MapReduce 映射器输出压缩?