Azure Function & Container Audit

点点圈 提交于 2021-02-11 15:22:39

问题


I have a file in an Azure container which is accessed via an Azure Function.

When the function is invoked - it is first AuthD against Azure AD only then the file is loaded.

What is the simplest way to identify "who" accessed my file ?

Any user id is NOT passed as parameter. There are 1000+ users in that AD.

Please guide.


回答1:


App Service passes user claims to your application by using special headers. External requests aren't allowed to set these headers, so they are present only if set by App Service. Some example headers include:

X-MS-CLIENT-PRINCIPAL-NAME

X-MS-CLIENT-PRINCIPAL-ID

You can use request.headers['your-header-name'] to get the corresponding value. The code example is as follows:

public static async Task<HttpResponseMessage> Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)]
HttpRequest httpRequest, 
ILogger logger)
{   
    var name1=httpRequest.Headers["X-MS-CLIENT-PRINCIPAL-NAME"].ToString();
}

For more details, you can refer to this official document, or you can also refer to this post.



来源:https://stackoverflow.com/questions/63125857/azure-function-container-audit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!