How to Assign API Permissions to a Managed Identity in Azure using PowerShell

How to Assign API Permissions to a Managed Identity in Azure using PowerShell

Overview

In Azure environments, assigning API permissions to managed identities is a key step when enabling secure and automated access to services like Microsoft Graph or Microsoft Defender for Endpoint. This blog post walks you through assigning app role permissions (like SecurityAlert.ReadWrite.All) to a managed identity using PowerShell and Azure AD.

đź”§ Prerequisites

  • Global Administrator access in Azure AD
  • AzureAD PowerShell module installed (Install-Module AzureAD)
  • Managed Identity object ID
  • App ID of the target Azure service (e.g., Microsoft Graph, Microsoft Threat Protection)

đź›  PowerShell Script to Assign API Permission

Below is the PowerShell script you can use. Replace the placeholder values with your actual Managed Identity Object ID and App ID.

📝 Notes

  • You can use different app IDs depending on whether you’re working with Microsoft Graph, Defender ATP, or another API.
  • Make sure the managed identity is already created and correctly scoped.
  • These roles are app-level permissions .

âś… Summary

This script allows you to assign app role permissions like SecurityAlert.ReadWrite.All to an Azure managed identity. It’s especially useful for automated workflows using Logic Apps, Azure Functions, or other services relying on secure and permissioned access to APIs.

Leave a Comment

Your email address will not be published. Required fields are marked *