Close Menu
Peter Klapwijk – In The Cloud 24-7Peter Klapwijk – In The Cloud 24-7
    Facebook X (Twitter) Instagram
    Peter Klapwijk – In The Cloud 24-7Peter Klapwijk – In The Cloud 24-7
    • Home
    • Intune
    • Windows
      • Modern Workplace
    • macOS
    • Android
    • iOS
    • Automation
      • Logic Apps
      • Intune Monitoring
      • GitHub
    • Security
      • Passwordless
      • Security
    • Speaking
    • About me
    Peter Klapwijk – In The Cloud 24-7Peter Klapwijk – In The Cloud 24-7
    Home»Automation»Configure a user-assigned Azure Managed Identity – the basics
    Automation

    Configure a user-assigned Azure Managed Identity – the basics

    Peter KlapwijkBy Peter KlapwijkMay 21, 2022Updated:February 14, 20255 Mins Read

    If you have read one of my automation-related flows before, you know most of these solutions rely on querying Graph API using HTTP actions in a Logic Apps flow. When I first started using these flows, I used Azure App Registrations with a client secret for authentication (and stored these in a Key Vault).

    But for a few months, I didn’t use App Registrations anymore but started using Azure Managed Identities. The benefit of using Managed Identities, is that you get an identity in Azure, but without the App Registration. You don’t have to use a client secret anymore, which is actually just some sort of password.

    In this post, I show you how to set up a user-assigned Managed Identity (a user-assigned Managed Identity can be shared between multiple Logic Apps flows for example) and how to assign different kinds of roles and permissions. We can for example assign an Azure role or Azure AD role and Graph API permissions to the identity. I just show the basics of setting up the Managed Identity, there are multiple ways to set up the identity and assign the roles and permissions.

    Create a Managed Identity

    One of the options to create a Managed Identity, is to use the Azure Portal.

    • Sign in to the Azure portal
    • Under All services search for Managed Identity
    • Open the Managed Identity service
    • Click Create
    • Select the Subscription and Resource group
    • Select the Region
    • Enter a name for the Managed Identity
    • Click Review + Create
    • Click Create

    That’s all to create the Managed Identity via the portal.

    Assign an Azure role to the Managed Identity

    It is possible to assign an Azure role to the Managed Identity. One of the ways to do this is via the Azure Portal.

    Open the Managed Identity after creation.
    Here you can find the properties of the Managed Identity and also assign an Azure role to the identity.

    • Click on Azure role assignments
    • Make your choice for the scope
    • Select your subscription
    • Select the Resource group (in case you selected Resource group as scope)
    • Select the Role(s) you like to assign
    • Click Save

    As you can see you can assign different kinds of Azure roles to the identity, like Log analytics Reader or Storage Blob Reader.

    Assign an Azure AD role to the Managed Identity

    We can also assign an Azure AD role to a Managed Identity, both built-in and custom roles can be assigned. This might come in handy for example when a Graph API call doesn’t support application permissions.

    Assigning an AAD role is done in the same way as assigning the role to an AD account, but only active assignments are allowed. To assign an AAD role, follow the below steps.

    • Browse to Azure Active Directory
    • Open Roles and administrators
    • Search for the role you want to assign
    • Click Add Assignments
    • Click on No member selected
    • Search and select the Managed Identity
    • Click Next
    • Enter a Justification
    • Click Assign

    And the Azure AD role is assigned.

    Assign Graph API permissions to the Managed Identity

    We can also assign Graph API permissions to the Managed Identity.

    Via de Azure Portal, we can view the currently assigned API permissions, but not assign these permissions.

    To view the permissions via the Azure Portal, open the Enterprise Applications services.
    Select Managed Identities as the Application type.

    Open the previously created Managed Identity and on the Permissions tab, we find an overview of the assigned Graph API permissions.

    We can use PowerShell to assign Graph API permissions, for example with this small script from Aleksandar Stefanov.

    You only need to enter your tenant ID, displayname of the Managed Identity, and Permission name.

    Microsoft Graph API always has the appId that is: 00000003-0000-0000-c000-000000000000. No need to change that.

    In case you need to assign Windows Defender ATP API permissions, use appid fc780465-2017-40d4-a0c5-307022471b92.

    # Your tenant id (in Azure Portal, under Azure Active Directory -> Overview )
    $TenantID=""
    # Microsoft Graph App ID (DON'T CHANGE)
    $GraphAppId = "00000003-0000-0000-c000-000000000000"
    # Name of the manage identity (same as the Logic App name)
    $DisplayNameOfMSI="demoLogicApp" 
    # Check the Microsoft Graph documentation for the permission you need for the operation
    $PermissionName = "Domain.Read.All" 
    
    # Install the module (You need admin on the machine)
    Install-Module AzureAD 
    
    Connect-AzureAD -TenantId $TenantID 
    $MSI = (Get-AzureADServicePrincipal -Filter "displayName eq '$DisplayNameOfMSI'")
    Start-Sleep -Seconds 10
    $GraphServicePrincipal = Get-AzureADServicePrincipal -Filter "appId eq '$GraphAppId'"
    $AppRole = $GraphServicePrincipal.AppRoles | `
    Where-Object {$_.Value -eq $PermissionName -and $_.AllowedMemberTypes -contains "Application"}
    New-AzureAdServiceAppRoleAssignment -ObjectId $MSI.ObjectId -PrincipalId $MSI.ObjectId `
    -ResourceId $GraphServicePrincipal.ObjectId -Id $AppRole.Id

    After running the script, the assigned API permissions can be found in the overview.

    If you want to automate the deployment of the Managed Identity and Graph permissions, also have a look at this post by Luise Freese.

    That’s it for this post.
    We have walked through the basic steps of creating a Managed Identity and how we can assign different roles and permissions.

    And if you still wonder in which use case you can use a Managed Identity, have a look at the automation blog posts on my website.

    Thanks for reading!

    Dynamics 365 Logic Apps Power Automate Security
    Share. Facebook Twitter LinkedIn Email WhatsApp
    Peter Klapwijk
    • Website
    • X (Twitter)
    • LinkedIn

    Peter is a Security (Intune) MVP since 2020 and is working as Modern Workplace Engineer at Wortell in The Netherlands. He has more than 15 years of experience in IT, with a strong focus on Microsoft technologies like Microsoft Intune, Windows, and (low-code) automation.

    Related Posts

    Azure role-based access control – BitLocker Recovery Key Reader

    April 2, 2022

    Intune RBAC – Create country based device groups with Logic Apps

    March 24, 2022

    Import Windows Autopilot devices with Logic Apps

    March 27, 2021
    Add A Comment
    Leave A Reply Cancel Reply

    Peter Klapwijk

    Hi! Welcome to my blog post.
    I hope you enjoy reading my articles.

    Hit the About Me button to get in contact with me or leave a comment.

    Awards
    Sponsor
    Latest Posts

    Update Windows Defender during Windows Autopilot enrollments

    May 16, 2025

    Hide the “Turn on an ad privacy feature” pop-up in Chrome with Microsoft Intune

    April 19, 2025

    How to set Google as default search provider with Microsoft Intune

    April 18, 2025

    Using Windows Autopilot device preparation with Windows 365 Frontline shared cloud PCs

    April 13, 2025
    follow me
    • Twitter 4.8K
    • LinkedIn 6.1K
    • YouTube
    • Bluesky 1.5K
    Tags
    Administrative Templates Android Automation Autopilot Azure Azure AD Browser Conditional Access Edge EMS Exchange Online Feitian FIDO2 Flow Google Chrome Graph Graph API Identity Management Intune Intune Monitoring iOS KIOSK Logic Apps macOS MEM MEMMonitoring Microsoft 365 Microsoft Edge Microsoft Endpoint Manager Modern Workplace Office 365 OneDrive for Business Outlook Passwordless PowerApps Power Automate Security SharePoint Online Teams Windows Windows 10 Windows10 Windows 11 Windows Autopilot Windows Update
    Copy right

    This information is provided “AS IS” with no warranties, confers no rights and is not supported by the authors, or In The Cloud 24-7.

     

    Copyright © 2025 by In The Cloud 24-7/ Peter Klapwijk. All rights reserved, No part of the information on this web site may be reproduced or posted in any form or by any means without the prior written permission of the publisher.

    Shorthand; Don’t pass off my work as yours, it’s not nice.

    Recent Comments
    • Adam on Get notified on expiring Azure App Registration client secrets
    • Peter Klapwijk on Update Windows Defender during Windows Autopilot enrollments
    • Rob van de Ven on Add a certificate to the Trusted Publishers with Intune without reporting errors
    • Carl on Update Windows Defender during Windows Autopilot enrollments
    • Peter Klapwijk on The next step in a passwordless Windows experience
    most popular

    Application installation issues; Download pending

    October 1, 2024

    Restrict which users can logon into a Windows 10 device with Microsoft Intune

    April 11, 2020

    How to change the Windows 11 language with Intune

    November 11, 2022

    Update Microsoft Edge during Windows Autopilot enrollments

    July 9, 2024
    Peter Klapwijk – In The Cloud 24-7
    X (Twitter) LinkedIn YouTube RSS Bluesky
    © 2025 ThemeSphere. Designed by ThemeSphere.

    Type above and press Enter to search. Press Esc to cancel.

    Manage Cookie Consent
    To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
    Functional Always active
    The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
    Preferences
    The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
    Statistics
    The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
    Marketing
    The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
    Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
    View preferences
    {title} {title} {title}