@84017655 Thanks for your follow up questions on this.
As suggested by Sakshi Kokardekar you need to define separate policy files for each operation and reference them in your Bicep template. You will indeed need multiple .xml files in your repo, one for each operation policy. I think, In your Bicep template, you'll specify the apiOperation resource and reference the corresponding policy file
I want to apply an individual policy to GET /api/v5/auth_code - GET operation. What changes do I need to make in this bicep snippet? Do I need to mention GET /api/v5/auth_code - GET operation name in the name property of
Microsoft.ApiManagement/service/apis/operations/policies
resource?
You have to pass the value name property under Microsoft.ApiManagement/service/apis/operations/policies
as policy only and here the sample policy resource block which we have used to create to policy for a specific operation under an API.
resource getresourceechoapipolicy 'Microsoft.ApiManagement/service/apis/operations/policies@2024-06-01-preview' = {
name: 'policy'
parent: apiretrieveresource
#update the resource block name of API Operation Name
dependsOn: [
apiretrieveresource #update the resource block name of API Operation Name
apiManagementService #update the resource block name of APIM instance
]
properties: {
value: loadTextContent('./policydefinition.xml')
format: 'xml'
}
}
Also confirm, do I need to define
Microsoft.ApiManagement/service/apis/operations/policies
resource again If I want to apply individual policies to POST [/api/v5/appversion - POST] operation of same API in same API Gateway Instance?
Yes, you have to define multiple resource blocks since you want to add policy at operation level inside an API.
Hope this helps, let me know if you have any further questions on this.