1

The following APIM policy cannot be deployed via 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>

With the following error: The 'JObject' start tag on line 15 position 26 does not match the end tag of 'value'. Line 18, position 4.

This is due to the content.As<JObject>.

The policy is defined as in the Terraform documentation.

Same error when using xml_content = "${file("xxx")}".

How to proceed, besides finding a workaround to not use content.As<JObject>?

4

1 回答 1

2

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

如果 XML 策略由 Terraform 提供,则&lt;使用。&gt;

于 2019-06-26T13:26:46.250 回答