Manuprasad M N Thanks for posting your question in Microsoft Q&A. Based on the expression evaluation, it appears that context.User
is null, and this might occur if the subscription key used in the request didn't have userId. Are you observing this error from Azure Portal Test console? If so, it uses built-in all-access subscription which doesn't have user info.
You can test with a subscription key which has user info mapped (like All APIs in the screenshot above) by passing it in the header like below and should provide the result.
Also, I would suggest checking context.User
as null to avoid null reference exception. I hope this helps and let me know if any questions.
set-header name="user" exists-action="override">
<value>@(context.User?.Email)</value>
</set-header>
If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.