In Focus
No items found.
thinformatics
Back to the blog
Governance
Log Analytics
Logic Apps

Azure AD Guest Governance Automation

How to add the inviter to a guest user object in Azure AD using a Logic App, Graph API, and Log Analytics Rest API We recently brainstormed about Azure AD Guest Management. If an organization is not (yet) able to use Access packages and reviews for their Access Management and Guest Handling they might...

Jakob Schaefer
Jakob Schaefer
Consultant & SME Team GRC[br]Governance, Risk & Compliance
August 16, 2022
6 Minuten
Reading time

How to add the inviter to a guest user object in Azure AD using a Logic App, Graph API, and Log Analytics Rest API

We recently brainstormed about Azure AD Guest Management. If an organization is not (yet) able to use Access packages and reviews for their Access Management and Guest Handling they might want to establish other processes to revalidate Guest Accounts.

One Method could include asking a responsible person if the guest’s account and his access are still valid. In our case, the responsible person was the user which invited the user to the Azure AD. To be able to identify the responsible person we thought about assigning the inviting person as a manager to the guest account. This could be used afterward to trigger some automation to expand the identity of the guest.

In this blog article, I will show you a way how to use Azure Log Analytics and Azure Logic Apps to fulfill the governance requirement described above.

Short Description of the Process

A scheduled Logic App will crawl the Audit Events from a Log Analytics Workspace in intervals. If the Log Analytics query finds new guests invites the UserID and InvitingUserID from the AuditLog will be used to identify and update the guest user accordingly by using the Graph API.

Log Analytics

Every admin action and more is stored in the AAD Admin Audit Logs. If you’re interested in this topic it’s likely that you already use Log Analytics to retain and handle your audit logs. If not, you can follow this instruction to enable it: Stream Azure Active Directory logs to Azure Monitor logs – Microsoft Entra | Microsoft Docs. This screenshot shows the minimum required Azure Active Directory Diagnostic Setting for the following tasks:

With that setting, you can query your AAD Audit Logs for any Event. You can do this with KQL. As you hear from every site – especially the #secinfo bubble – KQL is a great tool to explore your data. Unfortunately, I’m not experienced with it yet. But my co-worker Andre build a small query that fits our needs. You can start trying it out and query your Logs in Log Analytics for Guest Invites eg by using this KQL Query:

AuditLogs

| where OperationName has "Invite external user"

| where Result has "success"

| where TimeGenerated > ago(1d)

| project TimeGenerated, OperationName, GuestUserId = TargetResources[0].id,

InvitedById = InitiatedBy.user.id, Result

The query should list all invites and the relevant user data created in the last 24h.

App Registration / Authentication

We’re using the HTTP connector of the Logic App to assign the Manager via Microsoft Graph. To be able to authenticate against the Graph we’ve created an Azure AD App Registration. The App Registration is using App Permissions and has the permission ‚User.ReadWrite.All‘ assigned. To generate the token we’ve created an App Secret and stored it in an Azure Key Vault.

You can also use the Azure AD connector to get this job done. When I wrote this article you could only use a regular user authentication with this connector which we wanted to avoid. If you do so you can skip this step and use user-based authentication with all its caveat.

You can also use the Azure AD connector to get this job done. When I wrote this article you could only use a regular user authentication with this connector which we wanted to avoid. If you do so you can skip this step and use user-based authentication with all its caveat.

Logic App – Preparation

The processing of this task is done by a Logic App. The Logic App needs to connect and authenticate to the Log Analytics Workspace and to Microsoft Graph. While we’re using the App Registration described above to authenticate against AAD/Microsoft Graph, we can use a managed Identity to authenticate for Log Analytics. To be able to do this we need to enable a system-assigned managed identity for our new Logic App:

Next, we need to assign the ‚Log Analytics Reader‘ Role for the Log Analytics Workspace to the newly created Managed Identity. With that setting, our Logic App is able to authenticate and query for the events we need from the Log Analytics Workspace.

If you’re using an Azure Key Vault to store the App Secret (which you should do) you can also assign the ‚Key Vault Secret User‘ Role for the secret to the managed Identity.

Logic App – the steps

The Logic App is using the recurrence trigger. It should be enough that new guest users were processed once a day. Afterward, we initialize and fill the Variables for the Tenant ID, the App ID (of the App Registration we’ve created before), the Log Analytics Workspace ID, and the query we’re using to extract the audit events.

The query is the same as in the example above but only returns the essential id’s.

The timefilter we use in the query should match the interval of the recurrence trigger to avoid that guests being handled more than once. In this example the Logic App is triggered once a day.

Now we can go on and query Log Analytics. I’m using the Log Analytics Rest API and an HTTP Request instead of the build-in Log Analytics connector because it allows the authentication as a managed identity instead of user-based or SPN Authentication.

To be able to parse the output of the query I’ve started the LA once and used the result of the HTTP Action as sample payload.

We have now all information we need to update our guest accounts. Unfortunately, the output of the query is not so easy to process as I’m used to it from regular Graph API Queries. So we’ve used some loops and positional arrays to be able to select the right values. A loop to process each table, another for each row where I’ve then selected the first value as GuestUserID and the second one as the InvitingUserID.

To avoid update errors for Guests which were renewed because of Layer 8 problems etc, we check the existence of the user before with the request above. If the HTTP request results in a Status=200 the Logic App proceeds using an update request against the Graph:

That’s it! Now the Logic App will run daily and set the manager field to the value of the user who invited him.

The complete flow looks like this in our lab:

You can prove it by using e.g. a Log Analytics Query to find the specific update Events:

The result in the screenshot says that the AppReg ‚GuestGovernance‘ was used to set a new manager to a Guest Identity.

Thoughts?!

What would you do with this information to improve Guest Identity Governance? Do you have other ideas how to improve guest governance efforts?

I’m happy about every feedback. You can reach me via Twitter

manage-external-communications-in-teams
Manage external Communications in Teams
September 18, 2025
6 Minuten
Microsoft Teams
Security
Collaboration
Microsoft 365
ansatz-zum-behandeln-des-datenabflusses-bei-der-nutzung-von-m365-fr-sensible-accounts
Isolation von sensiblen Accounts in M365
January 9, 2025
10 Minuten
Identity
Security
Enterprise
Compliance
SSE
GSA
export-archiv-mailbox-content-using-ediscovery
Export Exchange Online Archiv Mailbox content using eDiscovery
September 6, 2024
6 Minuten
Compliance
Microsoft Purview
Export
Exchange Online
Archiving
PowerShell
cloning-entra-cloud-sync-jobs
Cloning Entra Cloud Sync Jobs
May 6, 2024
7 Minuten
Entra ID
PowerShell
Cloud Sync
Hybrid
Microsoft Graph API
entra-cloud-sync-group-provisioning-mappings
Entra Cloud Sync - Group Provisioning
February 21, 2024
6 Minuten
Entra ID
Active Directory
Hybrid
Identity
TIL
do-more-with-less-or-do-less-with-more
“Do more with less” or „Do less with more“?
January 10, 2024
8 Minuten
Allgemein
wie-wandle-ich-meine-sharepoint-liste-in-eine-mini-app
Wie wandle ich meine SharePoint-Liste in eine Mini-APP
July 31, 2023
4 Minuten
Citizen Development
Lists
SharePoint
shared-channels-in-microsoft-teams
Shared Channels in Microsoft Teams: So bringen wir unsere Unternehmensgruppe zusammen
April 24, 2023
7 Minuten
Allgemein
Microsoft 365
User Adoption
Entra ID
Security
Microsoft Teams
datengetriebenes-change-management
Datengetriebenes Change Management? Analyse von Nutzungszahlen und deren Aussagekraft bei der Erfolgsmessung der Digitalisierung und User Adoption
April 13, 2023
8 Minuten
Change Management
Messbarkeit
teams-inventory-implement-membership-requests
Teams Inventory – Implement Membership Requests
March 1, 2023
5 Minuten
Allgemein
Governance
Microsoft 365
Power Automate
Power Platform
SharePoint
Microsoft Teams
how-to-build-a-simple-teams-inventory
How to build a simple Teams Inventory
February 17, 2023
9 Minuten
Logic Apps
update-power-automate-dein-day-summary-flow
Update: Power Automate: Dein „Day Summary“-Flow
February 1, 2023
2 Minuten
Citizen Development
Power Automate
power-automate-dein-day-summary-flow
Power Automate: Dein „Day Summary“-Flow
January 4, 2023
2 Minuten
Citizen Development
Power Automate
tenant-to-tenant-pst-based-exchange-migration-automation-approach-part-v
Tenant-to-Tenant – PST based Exchange Migration automation approach – Part V
December 27, 2022
5 Minuten
Allgemein
Exchange Online
Microsoft 365
Migrations
PowerShell
tenant-to-tenant-pst-based-exchange-migration-automation-approach-part-iv
Tenant-to-Tenant – PST based Exchange Migration automation approach – Part IV
November 30, 2022
5 Minuten
Allgemein
Exchange Online
Microsoft 365
Migrations
PowerShell
tenant-to-tenant-pst-based-exchange-migration-automation-approach-part-iii
Tenant-to-Tenant – PST based Exchange Migration automation approach – Part III
November 25, 2022
4 Minuten
Allgemein
Azure
Exchange Online
Microsoft 365
Migrations
PowerShell
tenant-to-tenant-pst-based-exchange-migration-automation-approach-part-ii
Tenant-to-Tenant – PST based Exchange Migration automation approach – Part II
November 18, 2022
5 Minuten
Allgemein
Compliance
Exchange Online
Microsoft 365
Microsoft Purview
Migrations
PowerShell
tenant-to-tenant-pst-based-exchange-migration-automation-approach-part-i
Tenant-to-Tenant – PST based Exchange Migration automation approach – Part I
November 16, 2022
5 Minuten
Allgemein
Compliance
Exchange Online
Microsoft 365
Microsoft Purview
Migrations
PowerShell
ignite-impressionen-was-ist-neu-in-microsoft-viva
Ignite Impressionen: Was ist neu in Microsoft Viva?
October 28, 2022
5 Minuten
Employee Experience
ignite-impressionen-summary-und-persoenliches-fazit
Ignite Impressionen: Summary und persönliches Fazit zur Session „Microsoft To Do is good for your mental health!“
October 28, 2022
5 Minuten
Allgemein
Microsoft 365
Planner
To Do
ignite-impressionen-microsoft-entra-workload-identities
Ignite Impressionen: Microsoft Entra Workload Identities
October 28, 2022
4 Minuten
Microsoft 365
Entra ID
Conditional Access
Identity
Identity Governance
Identity Protection
ignite-impressionen-microsoft-syntex-die-freundliche-ki-von-nebenan
Ignite Impressionen: Microsoft Syntex – die freundliche KI von nebenan
October 28, 2022
3 Minuten
Allgemein
Microsoft 365
Governance
Information Governance
Power Automate
Power Platform
SharePoint
ignite-impressionen-uebersetzung-mit-ai-builder
Ignite Impressionen: Übersetzung mit AI Builder
October 28, 2022
3 Minuten
Allgemein
Microsoft 365
Citizen Development
Power Automate
Power Platform
SharePoint
how-to-retain-exchange-online-content-an-overview-of-the-different-compliance-options-in-microsoft-365
How to retain Exchange Online content – An overview of the different compliance options in Microsoft 365
September 28, 2022
10 Minuten
Archiving
Compliance
Governance
Retention
azure-ad-guest-governance-automation
Azure AD Guest Governance Automation
August 16, 2022
6 Minuten
Governance
Log Analytics
Logic Apps
assign-teams-app-permission-policies-to-groups
Assign Teams app permission policies to Groups(-Members)
July 1, 2022
8 Minuten
Allgemein
Microsoft 365
Governance
PowerShell
Microsoft Teams
powerautomate-prozente-in-einer-html-tabelle
PowerAutomate: Prozente in einer HTML-Tabelle
May 30, 2022
2 Minuten
Citizen Development
planner-e-mail-report-mit-aufgaben-gruppiert-nach-bucket
Planner E-Mail-Report mit Aufgaben gruppiert nach Bucket
March 31, 2022
3 Minuten
Citizen Development
sharepoint-liste-als-e-mail-uebersicht-mit-personen-feldern-und-odata-meistern
SharePoint-Liste als E-Mail-Übersicht mit Personen-Feldern (und OData meistern)
March 29, 2022
2 Minuten
Citizen Development
Power Automate
use-graph-directory-schema-extensions-for-microsoft-teams-governance
Use Graph Directory Schema Extensions for Microsoft Teams Governance
October 15, 2021
9 Minuten
Microsoft Graph API
teams-invitation-processes-a-comparison
Teams Invitation Processes - A comparison
July 8, 2021
6 Minuten
Access Packages
Compliance
Entitlement Management
Governance
Microsoft Teams
Security
use-more-access-packages
Use more Access Packages!
June 28, 2021
8 Minuten
Access Packages
Identity Governance
Compliance
Governance
Security
Microsoft Teams
microsoft-teams-fulfill-advanced-guest-access-requirements
Microsoft Teams – Fulfill Advanced Guest Access Requirements
December 4, 2020
6 Minuten
Allgemein
Entra ID
Governance
Identity Governance
Microsoft 365
Microsoft Teams
microsoft-365-language-confusion
Microsoft 365 – Language Confusion
September 30, 2020
12 Minuten
Language
another-microsoft-teams-governance-approach-using-azure-ad-identity-governance
Another Microsoft Teams Governance Approach – Using Azure AD Identity Governance
September 18, 2020
21 Minuten
Governance
Identity Governance
Microsoft Teams
planner-migration-tenant-to-tenant
Planner Migration Tenant to Tenant
July 9, 2020
3 Minuten
Migrations
Planner
PowerShell
Tenant to Tenant
flow-instant-raumbuchung
Flow: Instant Raumbuchung
February 25, 2020
2 Minuten
Citizen Development
Power Automate
ai-integrations
ai-solutions
ai-applications
ai-solutions
intranet-solutions
digital-workplace
endpoint-security
security
compliance-regulatorik
security-compliance-zero-trust
plattform-engineering
cloud-plattformen-engineering
endpoint-management-2
workplace
ai-assistants
ai-solutions
cloud-security
security-compliance-zero-trust
cloud-transformation
cloud-strategie-architektur
system-integration
intelligence-automation
business-applications
custom-software
identity-security
security
container-platforms
platform
employee-experience
modern-workplace
collaboration-productivity
modern-workplace
transformation-management
cloud-transformation
application-modernization
cloud-transformation
cloud-governance-und-betriebsmodell
cloud-strategie-architektur
workflow-automation
intelligence-automation
sharepoint-solutions
digital-workplace
security-monitoring
security
collaboration-platforms
workplace
cloud-platforms
platform
virtualization-operations
infrastructure
server-operations
infrastructure
ai-security-compliance
ai-digital-innovation
endpoint-management
modern-workplace
cyber-resillience
security-compliance-zero-trust
identity-access
security-compliance-zero-trust
change-enablement
cloud-transformation
workload-modernization
cloud-transformation
plattformautomatisierung
cloud-plattformen-engineering
hybrid-connectivity
cloud-plattformen-engineering
landing-zones
cloud-plattformen-engineering
business-process-automation
intelligence-automation
microsoft-365-extensions
digital-workplace
apis-integrationen
custom-software
web-applications
custom-software
ai-for-modern-workplace
ai-digital-innovation
aitransformation-adoption
ai-digital-innovation
ai-platforms-engineering
ai-digital-innovation
ai-strategie-und-governance
ai-digital-innovation
workplace-security
modern-workplace
zero-trust
security-compliance-zero-trust
cloud-migration
cloud-transformation
cloud-foundations
cloud-plattformen-engineering
cloud-assesments
cloud-strategie-architektur
hybrid--multi-cloud-strategie
cloud-strategie-architektur
modern-work-adoption
modern-workplace
hybrid--multi-cloud-architektur
cloud-strategie-architektur