【问题标题】:How do I set Origin Path in Azure CDN using Resouce Manager API?如何使用资源管理器 API 在 Azure CDN 中设置源路径?
【发布时间】:2016-08-06 07:07:08
【问题描述】:

我想告诉 Azure CDN 我的来源位于特定路径,例如mydomain.com/cdn。此选项可通过 Azure 门户获得(CDN 配置文件 > 端点 > 配置 > 源路径)

我正在使用资源管理器 API 和 Json 模板部署我的 Azure 资源。但是,我在此处的模板中找不到此设置:https://github.com/Azure/azure-quickstart-templates/tree/master/201-cdn-customize

这是不可用还是我错过了什么?

更新 使用资源浏览器,我在端点节点上找到了带有null 的属性。即使我尝试设置该值(并且 API 接受它),该值也没有设置。

    {
      "value": [
        {
          "name": "<hidden>",
          "id": "/subscriptions/<hidden>/resourcegroups/<hidden>/providers/Microsoft.Cdn/profiles/<hidden>/endpoints/<hidden>",
          "type": "Microsoft.Cdn/profiles/endpoints",
          "tags": {},
          "location": "NorthEurope",
          "properties": {
            "hostName": "<hidden>",
            "originHostHeader": "<hidden>",
            "provisioningState": "Succeeded",
            "resourceState": "Running",
            "isHttpAllowed": true,
            "isHttpsAllowed": true,
            "queryStringCachingBehavior": "UseQueryString",
            "originPath": null,
            "origins": [
              {
                "name": "<hidden>",
                "properties": {
                  "hostName": "<hidden>",
                  "httpPort": null,
                  "httpsPort": null
                }
              }
            ],
            "contentTypesToCompress": [
              "application/x-javascript",
              "text/css",
              "text/html",
              "text/javascript",
              "text/plain"
            ],
            "isCompressionEnabled": false
          }
        }
      ]
    }

【问题讨论】:

    标签: azure azure-resource-manager azure-cdn


    【解决方案1】:

    于 2016 年 4 月 15 日编辑以更正代码插入

    由于这是一个可选配置,模板可能没有它。 azuredeploy.json 第 97 行的部分似乎正在配置 CDN 端点。如下添加第 104 行应该会有所帮助。

     97      "properties": {
     98      "originHostHeader": "[parameters('originUrl')]",
     99      "isHttpAllowed": "[parameters('isHttpAllowed')]",
     100     "isHttpsAllowed": "[parameters('isHttpsAllowed')]",
     101     "queryStringCachingBehavior": "[parameters('queryStringCachingBehavior')]",
     102     "contentTypesToCompress": "[parameters('contentTypesToCompress')]",
     103     "isCompressionEnabled": "[parameters('isCompressionEnabled')]",
     104     "originPath": "[parameters('originPath')]",
     105     "origins": [
     106     {
     107       "name": "origin1",
     108       "properties": {
     109         "hostName": "[parameters('originUrl')]"
     110
     111       }
     112     }
     113   ]
    

    当然你需要在你的参数文件中添加这个块

            "originPath": {
            "value": "/cdn"
        }
    

    希望这对你有用

    【讨论】:

    • 您的指导让我开始思考,我使用资源浏览器查看我能找到什么。在端点属性下,实际上有一个originPath 属性。不幸的是,对此值的任何更改都不会保留。
    • 感谢您的更新和输出。我错了,它不是起源的子属性,它直接附加到父属性。如果您在第 103 行和第 104 行之间插入 "originPath": "[parameters('originPath')]",,它应该可以工作。编辑了反映这一变化的答案
    • 我终于让它工作了。也许问题是我更新了现有端点。创建新端点时,该设置确实有效。
    猜你喜欢
    • 2016-12-23
    • 1970-01-01
    • 1970-01-01
    • 2014-05-21
    • 1970-01-01
    • 1970-01-01
    • 2016-04-10
    • 2016-04-21
    相关资源
    最近更新 更多