Azure VPN User access logs

365admin 0 Reputation points
2025-03-10T07:30:08.19+00:00

How to get distinct O365 users list who have accessed Azure VPN

Azure VPN Gateway
Azure VPN Gateway
An Azure service that enables the connection of on-premises networks to Azure through site-to-site virtual private networks.
1,678 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ganesh Patapati 4,320 Reputation points Microsoft External Staff
    2025-03-10T19:33:31.9133333+00:00

    Hi 365admin

    To retrieve a distinct list of Office 365 (Azure AD) users who have accessed your Azure VPN, you need to first enable the VPN Gateway diagnostic logs and ensure that these logs are sent to a Log Analytics workspace. If you are using Azure AD authentication for Azure VPN P2S, verify that the VPN is configured with Azure AD credentials. Then, run a KQL query in Log Analytics to extract distinct users from the Azure Diagnostics table:

    AzureDiagnostics | where ResourceType == "VPNGATEWAYS" | where Category == "P2SDiagnosticLog"  | where OperationName == "UserAuthentication" | extend User = tostring(parse_json(Properties).userPrincipalName) | where isnotempty(User) | summarize Count = count() by User | project User, Count
    

    Refer: P2SDiagnosticLog

    You can also try to check the Azure AD Sign-in logs or events to get the list the VPN users. For this,

    please navigate to Microsoft Entra ID >> Monitoring >> Sign-in logs and then filter for VPN connections using the below KQL query:

    SigninLogs | where AppId == "xxxx3e61-6xxe-4xx5-bxx7-cd054exxxxx4"  // Azure VPN App ID | where Status.errorCode == 0  // Successful sign-ins | project UserPrincipalName, IPAddress, DeviceDetail, TimeGenerated | summarize Count = count() by UserPrincipalName | sort by Count desc
    
    

    Refer: How to access the activity logs in the Microsoft Entra admin center


    If above is unclear and/or you are unsure about something add a comment below.

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.Accepted answer


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.