azure - ARM 模板 API 管理部署策略内容

标签 azure azure-resource-manager azure-api-management azure-resource-group

我正在尝试使用 ARM 模板来部署我的 API 管理服务,并使除策略内容之外的所有内容正常运行。基本上它希望policyContent作为“策略的Json转义Xml编码内容”。这是非常难以维护的,我们正在尝试找到一种方法来获取 XML 文件并将内容注入(inject)到该字符串中,或​​者一些更好的方法。我不想编写一个程序来维护这些字符串,因为它感觉不应该那么复杂。

Policy Reference

Example with string

{ “名称”:“政策”, “类型”:“Microsoft.ApiManagement/service/apis/policies”, "api版本": "2017-03-01", “特性”: { “政策内容”:“字符串” } }

最佳答案

您可以将策略维护到 XML 文件中并像这样引用它:

{
    "apiVersion": "2018-01-01",
    "name": "policy",
    "type": "Microsoft.ApiManagement/service/policies",
    "properties": {
        "policyContent": "[concat(parameters('repoBaseUrl'), '/policy.xml')]",
        "contentFormat": "rawxml-link"
    },
    "dependsOn": [
        "[resourceId('Microsoft.ApiManagement/service/', parameters('ApimServiceName'))]"
    ]
}

您的 policy.xml 文件必须可在线获取,并且如下所示:

<policies>
    <inbound>
        <rate-limit calls="3" renewal-period="10" />
        <base />
    </inbound>
    <outbound>
        <base />
    </outbound>
    <backend>
        <base />
    </backend>
    <on-error>
        <base />
    </on-error>
</policies>

关于azure - ARM 模板 API 管理部署策略内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48845321/

相关文章:

azure - 如何使用连接 token 连接到 azure 订阅?

azure - 通过托管标识将 Azure WebApp 限制为 APIM?

azure - APIM 从现有资源生成 API 不断返回 200

Azure AD B2C : An account could not be found for the provided user ID

azure - 使用 Azure Active Directory 或 ADFS 或 AD 进行 SSO

azure - 将 dscExtension 部署到 Azure VMSS 时出现问题

带有 VNET 链接的 Azure 私有(private) DNS 无法解析

sql - 当我创建一个数据库时,azure 会创建一个额外的数据库

azure - 通过 SAS URI 访问 blob 时出现 "Authentication failed"错误

powershell - Azure 资源模板中的 dataDisk.image 参数