Need a query to discover all Azure applications and registrations that haven't signed in greater than 90 days

Jeff Taylor (CE CEN) 21 Reputation points
2022-10-03T15:44:11.87+00:00

Hello,

Is it possible to take a list of Application IDs (Azure apps as well as Azure App Registrations) and design a KQL to query our workspace (log retention is 90 days) for all sign-ins? What would that look like? With PowerShell we can import-csv that list but I don't see how to do with Kusto.

We want to disable and ultimately delete unused apps and at a total count of around 1,000+, want to discover apps that have long gone.

thanks

Microsoft Security Microsoft Entra Microsoft Entra ID
0 comments No comments
{count} votes

Accepted answer
  1. Marilee Turscak-MSFT 37,206 Reputation points Microsoft Employee Moderator
    2022-10-06T00:23:30.383+00:00

    Hi @Jeff Taylor (CE CEN) ,

    To design a KQL query to find service principals that haven't had sign-ins in more than 90 days, you could look at the service principal sign-in logs and AAD audit logs and use a query like this:

    AADServicePrincipalSignInLogs
    | where TimeGenerated > ago (90d)

    Doing some digging, I found a few KQL queries written by Matthew Zorich from the Sentinel team. These examples look pretty close to what you are looking for.

    This sample finds any Azure AD service principals that have been granted any .All access in the last year that haven't signed in for 30 days.

    And this example summarizes your Azure AD service principals by the last time they signed in, grouped by month:

    //Data connector required for this query - Azure Active Directory - Service Principal Signin Logs  
    
    AADServicePrincipalSignInLogs  
    | project TimeGenerated, AppId, ResultType, ServicePrincipalName  
    | where TimeGenerated > ago (360d)  
    | where ResultType == 0  
    | summarize arg_max(TimeGenerated, *) by AppId  
    | summarize ['Application List']=make_set(ServicePrincipalName) by Month=startofmonth(TimeGenerated)  
    | sort by Month asc   
    

    -
    Please Accept the answer if the information helped you. This will help us and other community members as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.