Share via

Problem Azure API manager routing to backend

Peter Vercoutter 0 Reputation points
2026-04-27T09:51:45.4366667+00:00

I have a network problem that I've narrowed down to the Azure API manager. I've got 2 services, erpservice (backend: https://api-erpservice.van.be/p/dock/erpservice/) and configuratorservice (backend:https://api-configuratorservice.van.be/p/dock/configuratorservice/). If I try to use another backend url for erpservice (https://api.van.be/p/dock/erpservice/) and configuratorservice (https://api.van.be/p/dock/configuratorservice/) (that are defined URL's and going to the same api backend service) , it seems like Azure is 0.0x% of the time sending to the wrong backend. Namely, the other service of the two.

Is it possible that Azure API mgr has problems with multiple API's having the same hostname? Does it have networking pooling problems? In the application insights of the API's, it also looks like it's using the right backend url.

I don't have a scenario where it's reproduceable, it's really random.

My API policy looks like this

<policies>
    <inbound>
        <base />
        <set-backend-service backend-id="configuratorservice-backend" />
    </inbound>
    <backend>
        <forward-request timeout="0" />
    </backend>
    <outbound>
        <base />
    </outbound>
    <on-error>
        <base />
    </on-error>
</policies>
Azure API Management
Azure API Management

An Azure service that provides a hybrid, multi-cloud management platform for APIs.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Siddhesh Desai 6,555 Reputation points Microsoft External Staff Moderator
    2026-04-27T14:44:20.7266667+00:00

    Hi @Peter Vercoutter

    Thank you for reaching out to Microsoft Q&A.

    Azure API Management does not have any inherent issues with routing traffic when multiple APIs use the same hostname, and it does not randomly forward requests to an incorrect backend due to networking or connection pooling. Routing in APIM is deterministic and is strictly controlled by API configuration, operation matching, and applied policies. When traffic appears to be routed to the wrong backend in a seemingly random manner, the issue is almost always related to policy inheritance, backend resource reuse, API path or operation overlap, or API revision/version configuration. Although Application Insights may show the expected backend URL, an inherited or overridden policy can still redirect traffic at runtime, which makes the behavior appear intermittent and difficult to reproduce.

    Refer below points to resolve this issue or this is the workaround

    Verify policy scope and inheritance

    Ensure that the <set-backend-service> policy is applied only at the intended API or operation level. Check for the same policy at the global (All APIs), product, or parent API level, as policies applied there are inherited by all APIs and can cause traffic to be routed to an unintended backend.

    Use dedicated backend resources per API

    Even if multiple APIs ultimately point to the same backend host, define separate backend resources in APIM (for example, one backend for erpservice and another for configuratorservice). This avoids accidental reuse or overrides of backend configuration across APIs.

    Validate API base paths and operation definitions

    Confirm that each API has a unique base path and that there are no overlapping or wildcard (/*) operations that could match requests for multiple APIs. Overlapping paths can cause APIM to select an unexpected API or operation.

    Check API revisions and versions

    Make sure only the intended API revision or version is active and receiving traffic. If multiple revisions are enabled, traffic may be split, leading to different backend routing behavior.

    Enable APIM diagnostic logs for backend requests

    Turn on API Management diagnostic logging (BackendRequest/BackendResponse). These logs show the exact backend URL used for each request and are the most reliable way to confirm which backend APIM is actually calling.


  2. Q&A Assist
    2026-04-27T09:52:03.5366667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Azure API Management supports multiple APIs that share the same hostname. The behavior described is not caused by hostname reuse or connection pooling between different backends.

    Key points from the configuration and platform behavior:

    1. The set-backend-service policy
      • The policy explicitly routes the request to the backend entity identified by backend-id:
             <set-backend-service backend-id="configuratorservice-backend" />
        
      • This changes the backend service base URL for the request to the URL configured on the configuratorservice-backend entity, regardless of the original API serviceUrl.
      • Backend entities are the supported way to centralize backend URLs and apply features like load balancing and circuit breaker rules across multiple APIs.
    2. Multiple backends with the same hostname
      • API Management can have multiple backend entities whose URLs share the same hostname but differ by path (for example, /erpservice vs /configuratorservice).
      • API Management selects the backend based on the policy (backend-id or base-url) applied to the request, not by hostname alone. Having the same hostname on different backends is supported and is not documented as a cause of cross-routing.
    3. Automatic backend detection
      • At runtime, if set-backend-service is not used, API Management can automatically detect and use a backend entity when its URL matches the backend service URL being called.
      • In the provided policy, set-backend-service is explicitly used, so the backend for that operation is determined by backend-id, not by automatic detection.
    4. Recommended checks
      • Ensure each API/operation that must call a specific backend uses the correct set-backend-service policy (correct backend-id) at the effective policy level (API, operation, product, or global). Use “calculate effective policy” to confirm there is no conflicting routing policy.
      • Verify that each backend entity has the correct base URL and that there is no overlap or misconfiguration between the erpservice and configuratorservice backend definitions.
      • Avoid trailing-slash inconsistencies in base-url definitions, as recommended, to prevent subtle misrouting or path concatenation issues.

    There is no documented limitation indicating that API Management randomly routes to the wrong backend when multiple APIs share the same hostname. When set-backend-service is configured with the correct backend-id, requests are routed deterministically to the configured backend entity.


    References:

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.