Create an APIM with policies and HTTP Backend url #13604
sterankin
started this conversation in
Authoring Help
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am trying to replace some existing infrastructure with Bicep. I have been able to create the APIM and an operation (GET) endpoint.
However I am struggling to find an example of how to implement an HTTP endpoint for the GET endpoint. I want the request to hit the APIM operation, do some inbound processing with a policy, then be sent to the http endpoint (which also has a policy).
Here is the code so far. I have left out the params so its easier to read. The policy is empty for now but references a file. I think the confusion arises around the
Microsoft.ApiManagement/service/backends
as I am not sure this is the correct implementation.I need to be able to "Define which service to send the request to." with a HTTP(s) endpoint.
`resource apiManagementService 'Microsoft.ApiManagement/service@2022-08-01' = {
name: apiManagementServiceName
location: location
sku: {
name: sku
capacity: skuCount
}
properties: {
publisherEmail: publisherEmail
publisherName: publisherName
}
}
resource testApi 'Microsoft.ApiManagement/service/apis@2021-12-01-preview' = {
name: apiName
parent: apiManagementService
properties: {
description: apiDescription
displayName: apiDisplayName
path: apiPath
protocols: [ 'http', 'https' ]
subscriptionRequired: false
type: 'http'
}
}
resource operation 'Microsoft.ApiManagement/service/apis/operations@2023-05-01-preview' = {
name: 'test'
parent: testApi
properties: {
displayName: 'Test GET endpoint'
method: 'GET'
urlTemplate: '/test'
templateParameters: []
request: {
queryParameters: [
{
name: 'id'
type: 'String'
values: [
'1052'
]
}
]
headers: []
representations: []
}
responses: []
}
}
resource backend 'Microsoft.ApiManagement/service/backends@2021-08-01' = {
parent: apiManagementService
name: 'echo'
properties: {
title: 'echo'
description: 'A backend service for the Each API.'
protocol: 'http'
url: 'https://echo.contoso.com'
}
}
resource testapiPolicy 'Microsoft.ApiManagement/service/apis/policies@2021-12-01-preview' = {
name: 'policy'
parent: testApi
properties: {
format: 'rawxml'
value: loadTextContent('./policy.xml')
}
}`
How the Bicep file is visualised. The backend should come from the operation, not the APIM so I am guessing its the incorrect construct to use here.
Beta Was this translation helpful? Give feedback.
All reactions