1

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 rawxml and xml formats are, but I rather have a separated file i.e. api-policy.xml and call it from the module bicep file. Is this even possible?

if I try putting the local path like that it would just return "The provided link is malformed."

resource service_api_management_name_policy 'Microsoft.ApiManagement/service/apis/policies@2021-08-01' = {
  parent: service_internal_api
  name: 'policy'
  properties: {
    value: '/api-policy.xml'
    format: 'rawxml-link'
  }
}
Ubaldo Quintero
  • 169
  • 3
  • 15

1 Answers1

2

You can load policy text from file and operate with it as string (ex. replace some template values):

resource apiPolicy 'Microsoft.ApiManagement/service/apis/policies@2021-08-01' = {
  parent: api
  name: 'policy'
  properties: {
    format: 'rawxml'
    value: loadTextContent('./policies/policies.xml')
  }
}

Also you can try policy fragments: https://learn.microsoft.com/en-us/azure/templates/microsoft.apimanagement/service/policyfragments?tabs=bicep

algreat
  • 8,592
  • 5
  • 41
  • 54