azure - APIM 策略中的泛型破坏了 Terraform

标签 azure terraform apim

以下 APIM 策略无法通过 Terraform 部署:

<policies>
    <inbound>
        <send-request mode="new" response-variable-name="xxx" timeout="20" ignore-error="true">
            <set-url>https://xxx/api/v1/xxx?code={{xxx}}</set-url>
            <set-method>GET</set-method>
        </send-request>
        <return-response>
            <set-status code="302" reason="Redirect" />
            <set-header name="Location" exists-action="override">
                <value>@{
                         var response = context;
                         IResponse variable = context.Variables["xxx"] as IResponse;
                         var content = variable.Body;
                         JObject obj = content.As<JObject>(); <------------ < and > characters
                         JProperty urlprop = obj.Property("xxx");
                         return "" + urlprop.Value;
                       }
                  </value>
            </set-header>
        </return-response>
    </inbound>
    ...
</policies>

出现以下错误:The 'JObject' start tag on line 15 position 26 does not match the end tag of 'value'. Line 18, position 4.

这是由于 content.As<JObject>

该策略的定义如the Terraform documentation中所示。 .

使用xml_content = "${file("xxx")}"时出现同样的错误.

除了找到不使用 content.As<JObject> 的解决方法之外,如何继续?

最佳答案

多行语句 (@{ }) 可以包含 XML 不友好字符,但不能通过 Terraform XML 读取器进行。

如果 XML 策略由 Terraform 配置,请使用 <>

关于azure - APIM 策略中的泛型破坏了 Terraform,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56773966/

相关文章:

json - Azure APIM-无法访问液体模板中的 json 正文值

python - Azure OCR API 在 90 个图像后停止。如何修复连接错误?

c# - Azure 数据湖与数据工厂自定义事件的连接

Azure函数应用程序: Error when loading V3 in portal for fresh function app?

powershell - Azure DSC。 Windows Server 2016 的 HA Active Directory 域 Controller 问题

terraform - 重构 terraform 代码时,是否有一种理智的方法来更新相应的 terraform 状态?

azure - 导出/导入 Azure API 管理开发人员门户 UI 更改

amazon-web-services - Terraform 获取不支持的操作 : Microsoft SQL when trying to start an amazon-linux instance

azure - 使用不同可用区的计数来部署虚拟机

Azure APIM - 协商客户端证书设置