1

I'm trying to add multiple Backend policies to my Azure APIM Management endpoint, but I'm getting an error that I can only have one policy: "Error in element 'backend' on line xx, column 6: backend section allows only one policy to be specified"

<backend>
    <forward-request />
    <set-header name="Content-Type" exists-action="append">
        <value>application/json</value>
    </set-header>
    <set-header name="x-correlation-id" exists-action="append">
        <value>asdf-qwer-1234-zxcv</value>
    </set-header>
</backend>

Is it possible to set multiple backend policies? If so, how can I do this? If not, what are some possible workarounds?

  • 1
    Does this answer your question? [How Do I Configure API Management With Multiple Back Ends?](https://stackoverflow.com/questions/56467244/how-do-i-configure-api-management-with-multiple-back-ends) – Vova Bilyachat Nov 18 '21 at 03:47
  • You can refer to [Azure API Management with multiple backends](https://stackoverflow.com/questions/64376326/azure-api-management-with-multiple-backends), [API Gateway to multiple backends?](https://social.msdn.microsoft.com/Forums/azure/en-US/224e7b38-5cf2-4067-ae97-d59b3d5092bc/api-gateway-to-multiple-backends) and [API Aggregation Using Azure API Management](https://www.c-sharpcorner.com/blogs/api-aggregation-using-azure-apim) – Ecstasy Nov 18 '21 at 07:49
  • As I've found you can only one (!) backend rule, as the warning indicates. But in order for the request to be delivered to the backend, this one request is required to be either `` or ``. Effectively, it seems you therefor cannot add any additional `` rules at the time of this writing. I've encountered a situation which cannot be moved to the `` unfortunately. – Juliën Jun 22 '22 at 09:05

1 Answers1

1

Thank you Vova and DeepDave-MT for the quick responses! Those are similar issues, but not necessarily related to multiple backend policies, rather related to having multiple backends.

We figured it out! A co-worker recommended moving the policies to the Inbound policies. This is rather interesting and wouldn't have guessed that.

Here's an example of what did the trick:

<policies>
    <inbound>
        ...
        <set-header name="Content-Type" exists-action="override">
            <value>application/json</value>
        </set-header>
        <set-header name="x-correlation-id" exists-action="override">
            <value>asdf-qwer-1234-zxcv</value>
        </set-header>
    </inbound>
    <backend>
        <forward-request />
    </backend>
    <outbound>
        ...
    </outbound>
    <on-error></on-error>
</policies>