Coder Perfect

When defining APIM policies in ARM/Bicep Templates, what is the difference between ‘xml’ and ‘rawxml’ formats?


The format of the policy value can be specified to rawxml (and rawxml-link) or xml when setting an Azure API Management policy in a Bicep or ARM template (and xml-link). I understand the link formats, but the distinction between rawxml and xml is unclear.

I searched through the MS Docs on this (ApiManagement Policy Template Definition) but couldn’t find anything that indicated the differences or goals of the two formats. In any case, googling hasn’t yielded a direct answer, at least not according to my google abilities.

I’m not sure what the difference is between rawxml and xml.

Asked by Ijwu

Solution #1

All characters that are not valid in XML must be correctly escaped in a policy written in xml format. That is, for example, how a basic statement must seem.

<set-variable name="var" value="@(&quot;user id:&quot; + context.User?.Id)"/>

When you change policy code in Azure Portal, you’ll view it in rawxml format, which uses razor syntax. You don’t need to escape XML incorrect characters in expressions in this format, so:

<set-variable name="var" value="@("user id:" + context.User?.Id)"/>

Aside from that, there is no difference; you can use whatever format best suits your needs.

Answered by Vitaliy Kurokhtin

Solution #2

This article from Microsoft will assist you:

When specifically acting on the generic identification row>, the specific Microsoft term “rawxml” makes a difference.

Answered by Andreas Hauser

Post is based on