Loading...

Leverage Azure API Management to distribute API traffic to multiple backend services

Leverage Azure API Management to distribute API traffic to multiple backend services
 

Load-balanced pool

Limitation

Logico_jp_1-1706500276422.png

 

Circuit breaker

 

Limitation

Please refer to “NOTE” in the document for more details.

Azure API Management backends | Microsoft Learn

 

Configuration

Preparation

Circuit breakers

 

{ "type": "Microsoft.ApiManagement/service/backends", "apiVersion": "2023-05-01-preview", "name": "test1", "properties": { "description": "backend (test1)", "type": "Single", "protocol": "http", "url": "<URL1>/api/test", "circuitBreaker": { "rules": [ { "failureCondition": { "count": "3", "errorReasons": [ "Server errors" ], "interval": "PT5M", "statusCodeRanges": [ { "min": "500", "max": "599" } ] }, "name": "myBreakerRule", "tripDuration": "PT10M" } ] } } }

 

Load-balanced pool

 

{ "type": "Microsoft.ApiManagement/service/backends", "apiVersion": "2023-05-01-preview", "name": "backendPool", "properties": { "description": "Load balanced backends", "type": "Pool", "protocol": "http", "url": "http://localhost", "pool": { "services": [ { "id": "/backends/test1" }, { "id": "/backends/test2" } ] } } }

 

Let’s try it.

 

Logico_jp_0-1706500394476.png

How about using these features with retry policy?

 

 

<!-- retryCount is specified in Named Values. --> <!-- Load-balanced pool "backendPool4AOAI" is already configured --> <policies> <inbound> <base /> <set-backend-service backend-id="backendPool4AOAI" /> <set-variable name="retryCount" value="@(int.Parse(" {{retryCount}}"))" /> <set-variable name="maxRetryCount" value="@((int)context.Variables[" retryCount"] -1)" /> <authentication-managed-identity resource="https://cognitiveservices.azure.com" output-token-variable-name="msi-access-token"ignore-error="false" /> <set-header name="Authorization" exists-action="override"> <value>@("Bearer " + (string)context.Variables["msi-access-token"])</value> </set-header> </inbound> <backend> <retry condition="@(context.Response.StatusCode >= 300)" count="@((int)context.Variables[" maxRetryCount"])" interval="1" max-interval="10" delta="1" first-fast-retry="false"> <!-- forward request and request body is stored for retry --> <forward-request buffer-request-body="true" /> </retry> </backend> <outbound> <base /> </outbound> <on-error> <base /> </on-error> </policies>

 

Logico_jp_0-1706498833372.png

Conclusion

Published on:

Learn more
Azure Architecture Blog articles
Azure Architecture Blog articles

Azure Architecture Blog articles

Share post:

Related posts

Microsoft Purview: Data Lifecycle Management- Azure PST Import

Azure PST Import is a migration method that enables PST files stored in Azure Blob Storage to be imported directly into Exchange Online mailbo...

3 days ago

Microsoft Rewards: Retirement of Azure AD Account Linking

Microsoft is retiring the Azure AD Account Linking feature for Microsoft Rewards by March 19, 2026. Users can no longer link work accounts to ...

4 days ago

Azure Function to scrape Yahoo data and store it in SharePoint

A couple of weeks ago, I learned about an AI Agent from this Microsoft DevBlogs, which mainly talks about building an AI Agent on top of Copil...

9 days ago

Maximize Azure Cosmos DB Performance with Azure Advisor Recommendations

In the first post of this series, we introduced how Azure Advisor helps Azure Cosmos DB users uncover opportunities to optimize efficiency and...

12 days ago

February Patches for Azure DevOps Server

We are releasing patches for our self‑hosted product, Azure DevOps Server. We strongly recommend that all customers stay on the latest, most s...

13 days ago

Building AI-Powered Apps with Azure Cosmos DB and the Vercel AI SDK

The Vercel AI SDK is an open-source TypeScript toolkit that provides the core building blocks for integrating AI into any JavaScript applicati...

13 days ago

Time Travel in Azure SQL with Temporal Tables

Applications often need to know what data looked like before. Who changed it, when it changed, and what the previous values were. Rebuilding t...

14 days ago
Stay up to date with latest Microsoft Dynamics 365 and Power Platform news!
* Yes, I agree to the privacy policy