What is the difference between 'xml' and 'rawxml' formats when defining APIM policies in ARM/Bicep Templates

Viewed 590

When defining an Azure API Management policy in a Bicep or ARM template, the format of the policy value may be set to rawxml (and rawxml-link) or xml (and xml-link). I know what the link formats are, however there is an unclear difference between rawxml and xml.

I have looked through the MS Docs on this (ApiManagement Policy Template Definition) but have not found any indicator as to the differences or purposes of either format. Googling around has not produced a straight answer anyway, at least to my google skills.

What is the difference between rawxml and xml?

2 Answers

Policy in xml format must be a valid XML, i.e. all characters that are not valid in XML must be properly escaped. For example, that is how simple expression must look

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

Policy in rawxml format utilizes razor syntax and it is what you see in Azure Portal when you edit policy code. In this format you don't need to escape XML invalid characters in expressions, like so:

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

Otherwise there is no difference, you can choose whatever format fits your needs best.

Related