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

PostgreSQL for your AI app's backend | Azure Database for PostgreSQL Flexible Server

Use Postgres as a managed service on Azure. As you build generative AI apps, explore advantages of Azure Database for Postgres Flexible Server...

2 hours ago

Storage migration: Combine Azure Storage Mover and Azure Data Box

Migrating storage from on-premises can be challenging. That’s why we are on a mission to make your migrations as simple as possible. We've dev...

3 hours ago

Loop DDoS Attacks: Understanding the Threat and Azure's Defense

In the realm of cybersecurity, Distributed Denial-of-Service (DDoS) attacks are a significant concern. The recent holiday season has unveiled ...

11 hours ago

Azure Communication Services at Microsoft Build 2024

Join us in-person in Seattle or virtually for Microsoft Build 2024 from May 21 to 24. We're excited to share the latest updates from Azure Com...

13 hours ago

Azure Developer CLI (azd) – May 2024 Release

This post announces the May release of the Azure Developer CLI (`azd`), which includes a new demo mode, various .NET Aspire enhancements, and ...

13 hours ago

Join us at Build 2024: Get the latest on Azure Cosmos DB in Seattle or online!

Are you ready to dive into the future of AI and data innovation? Microsoft Build 2024 is just around the corner, taking place May 21–23 in Sea...

14 hours ago

Announcing Data API builder General Availability for Azure Cosmos DB

Great news for developers out there! The Data API Builder for Azure Cosmos DB is now officially available, eliminating the need for writing co...

1 day ago

Organizing rule collections and rule collection groups in Azure Firewall Policy

Firewall Policy is the recommended method to manage Azure Firewall security and operational configurations. When using Firewall Policy, any ru...

1 day ago

Get Started with Azure AI Services | Open AI and Deployment Models

Table of Contents   Overview - Azure AI Services Kind of Azure AI Services Responsible AI Services Limited Access Features Cognitive Acc...

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