You are configuring policies for an Azure API Management (APIM) gateway that routes requests to a backend microservice. You must meet the following requirements:
1. Authenticate the gateway to the backend microservice by using the APIM instance's system-assigned managed identity to acquire a Microsoft Entra ID token.
2. Strip the X-Powered-By header from the response returned by the backend microservice before the response is sent back to the clients.
Which policy configuration should you use?
- <policies>
<inbound>
<base />
<authentication-managed-identity resource="https://graph.microsoft.com" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<set-header name="X-Powered-By" exists-action="delete" />
</outbound>
<on-error>
<base />
</on-error>
</policies>Cevap - B<policies>
<inbound>
<base />
<authentication-managed-identity resource="https://graph.microsoft.com" />
<set-header name="X-Powered-By" exists-action="delete" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies> - C<policies>
<inbound>
<base />
<authentication-managed-identity resource="https://graph.microsoft.com" client-id="87654321-4321-4321-4321-210987654321" />
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<set-header name="X-Powered-By" exists-action="delete" />
</outbound>
<on-error>
<base />
</on-error>
</policies> - D<policies>
<inbound>
<base />
<set-header name="Authorization" exists-action="override">
<value>@("Bearer " + {{vault-token}})</value>
</set-header>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
<set-header name="X-Powered-By" exists-action="delete" />
</outbound>
<on-error>
<base />
</on-error>
</policies>
Cevap
The configuration that places the authentication-managed-identity policy without a client-id inside the inbound section, and the set-header policy with exists-action="delete" inside the outbound section.
The correct configuration places the authentication-managed-identity policy (with only the resource attribute specified) in the inbound section. This correctly triggers authentication using the system-assigned managed identity before routing. It also places the set-header policy in the outbound section with exists-action="delete" to successfully strip the X-Powered-By header from the backend response before returning it to the client.
Adım Adım Çözüm
Anahtar Kavram
Azure API Management policy sections and identity configuration