Azure API Management (APIM) is a powerful facade for your backend services, offering security, analytics, and transformation features. A fundamental aspect of using APIM effectively is configuring backends and implementing strategies like load balancing to ensure high availability and optimal performance. This blog post will guide you through setting up backends, configuring load balancing, and customizing requests by setting query parameters on your endpoints within APIM.
The video below shows this in action. In the video, it outlines using Azure Logic App Standard as the backend but any backend can be used.
What is an APIM Backend?
In APIM, a Backend is a configuration object representing the service your API Management instance will forward requests to. This could be a single web service URL, an Azure App Service, an Azure Functions app, a Logic App. Defining backends in APIM allows you to decouple your API configuration from the specific location of your backend services, making it easier to manage changes and implement routing policies.
Setting Up a Backend in APIM
Configuring a backend in APIM is a straightforward process through the Azure portal:

APIM Back Ends
- Navigate to your APIM instance in the Azure portal.
- In the left-hand menu, under APIs, select Backends.
- Click + Add.
- Provide a descriptive Backend name.
- Choose the Backend type
- Enter the URL of your backend service.
- You can configure advanced settings like certificates, validation, and credentials if required.
- Click Create.
Once created, this backend can be referenced by your APIs and operations. They can also be used in a defined APIM Load Balancer, as seen in the video.
Setting Up Load Balancing in Configuration using APIM
APIM provides built-in support for load balancing across multiple backend instances or different backend services for a single API operation. This is typically achieved by defining multiple backend URLs and using the Load Balancer feature to distribute incoming requests.

APIM Load Balancer
By setting up the Load Balancer in APIM, you can add one or more Backends to the pool. This allows you to configure priority and weight per endpoint and define Circuit Breakers to automatically reroute requirements under specific conditions.

APIM Weight and Priority
Once the Load Balancer is set up, it can be called using a set-backend-service
policy within an API operation’s inbound processing. This is shown in the Inbound Policy code sample below.
APIM Inbound Policy using Backends and built in Load Balancing
<inbound>
<base />
<!-- Set the Load Balancer as configured under Backends -->
<set-backend-service backend-id="Endpoint-Main" />
<!-- Set the actual web service URL without query string parameters -->
<!-- Set copy-unmatched-params to true so all query parameters are copied -->
<rewrite-uri template="/Orders/triggers/When_a_HTTP_request_is_received/invoke"
copy-unmatched-params="true" />
</inbound>
Watch for exciting content related to the Azure Integration Services, Azure Logic Apps, and Azure AI being created soon.
If you have any questions, feel free to reach out!
Recent Comments