what is the context.User.ID ?

Martin Kal 20 Reputation points
2024-06-23T03:44:52.82+00:00

What is the builtin context context.User.Id representing?
<set-header name="x-request-context-data" exists-action="override">
<value>@(context.User.Id)</value>
</set-header>

It is giving me a value like this --> 666375244634610c745019a4
But I cant seem to find what is this representing. I looked at the OID of the user in Azure AD and it is not the OID.
So, what is this context.User.Id? And where can I find it ?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,177 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Adharsh Santhanam 4,370 Reputation points
    2024-06-23T04:12:02.0566667+00:00

    Hello Martin Kal, in Azure APIM, the context.user.Id refers to the unique identifier of the user making an API call. It’s a valuable piece of information that can be used within policy expressions to customize behavior based on the user’s identity. For example, you can use it to enforce authorization rules, track usage, or personalize responses.

    Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    0 comments No comments

  2. JananiRamesh-MSFT 28,081 Reputation points
    2024-07-01T13:19:54.7766667+00:00

    @Martin Kal Thanks for reaching out. The context.User.Id property in Azure APIM represents the unique identifier of the user who is making the API request. This identifier is generated by the API Management service and is not related to the user's Azure AD object ID or any other identifier in Azure AD.

    The value you are seeing (666375244634610c745019a4) is a hexadecimal string that represents the user ID. This value is generated by the APIM service and is unique to each user who makes a request to the API.

    You can use the context.User.Id property to track user activity and perform user-specific operations in your API. Do let me know incase of further queries, I would be happy to assist you.

    Please accept as Yes if the answer provided is useful, so that you can help others in the community looking for remediation for similar issues.

    0 comments No comments

Your answer

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