Reputation: 189
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'
}
}
Upvotes: 3
Views: 1948
Reputation: 9002
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
Upvotes: 4