Local file reference or file:// as Policy Format in ARM template

Nagashree Balasundaram 731 Reputation points
2022-11-17T20:31:47.763+00:00

When policyXML is stored in a separate (independent) xml file, the ARM template deployment (via az shell or Azure devops) expects that the policyXMLBaseURL is a valid http URL only.
Is it possible to use a file:// url or just a folder location in place of a URL?
I do see that the Policy Content formats supported are rawXML / XML and rawXml-link/Xml-link
https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.apimanagement.models.policycontentformat?view=azure-dotnet

(In some scenarios it helps to have separate policy XML files for each environment (for eg: CORS, or ip whitelisting etc), store them in the same repo and use the environment-specific policy files at deployment time, without the overhead of hosting them in a different repo)
{

  "apiVersion": "2021-08-01",  

  "type": "Microsoft.ApiManagement/service/apis/policies",  

  "name": "[concat(parameters('apimServiceName'), '/l360telemetryapi/policy')]",  

  "dependsOn": [  

    "[resourceId('Microsoft.ApiManagement/service/apis', parameters('apimServiceName'), 'l360telemetryapi')]"  

  ],  

  "properties": {  

    "value": "[concat(parameters('policyXMLBaseUrl'), 'l360telemetryapi-apiPolicy.xml')]",  

    "format": "rawxml-link"  

  }  

}  
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,773 questions
0 comments No comments
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,151 Reputation points
    2022-11-18T15:37:50.9+00:00

    @Nagashree Balasundaram Thank you for reaching out to Microsoft Q&A. As you mentioned in our docs: PolicyContentFormat, supported formats are rawxml, rawxml-link, xml, xml-link. You are correct, both rawxml-link and xml-link only supports http endpoint and unfortunately, local file reference is not supported.

    However, I think you can use rawxml/xml format, then pass the xml contents via parameter. Azure CLI supports reading file contents with @ in parameter and here is sample reference: https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/deploy-cli#inline-parameters or use different parameter files for each environment with XML values. I haven't tested this one before but thought it would be good to try.

    Refer Quick Template for passing XML string as parameter. Feel free to add a comment if you have any questions or thoughts. Would be happy to assist.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful