You are developing a solution that uses Azure API Management (APIM). You need to configure an inbound policy that forwards the client's original IP address to the backend service by adding a custom request header named `X-Client-IP`. You must use a C# policy expression within the `<set-header>` policy.
Complete the policy configuration by filling in the missing C# expression in the blank. What is the C# expression to retrieve the client's IP address from the request context?
Cevap:<inbound>
<base />
<set-header name="X-Client-IP" exists-action="override">
<value>@(【context.Request.IpAddress】)</value>
</set-header>
</inbound>
<base />
<set-header name="X-Client-IP" exists-action="override">
<value>@(【context.Request.IpAddress】)</value>
</set-header>
</inbound>
Cevap
context.Request.IpAddress
In Azure API Management, the context object is a read-only variable available within policy expressions. To access details about the client's request, you use the Request property of the context. The client's IP address is specifically exposed via the IpAddress property on the Request object. Therefore, the correct expression to fill the blank is context.Request.IpAddress.
Adım Adım Çözüm
Anahtar Kavram
Azure API Management context variables and policy expressions