Skip to content

Instantly share code, notes, and snippets.

@alfespa17
alfespa17 / gist:a2b49608a990399519bc0d77e439c231
Created April 27, 2026 20:29
Add app role to managed identity service principal
$payload = @{
appRoleId = "6195ee1a-0073-41e1-85c5-5b2e046a174d" # App role id from app registration manifest
principalId = "65ed2d02-c88f-423f-be4c-c6a5322171a5" # Object Id from managed identity enterprise application
resourceId = "2472d3cf-3fbe-421d-892b-5f54910880aa" # Object Id from enterprise application in app registration where role is defined
}
$payload | ConvertTo-Json | Out-File "tmp_payload.json" -Encoding utf8
az rest --method post `
--uri "https://graph.microsoft.com/v1.0/servicePrincipals/65ed2d02-c88f-423f-be4c-c6a5322171a5/appRoleAssignments" `
--body "@tmp_payload.json" `
--headers "Content-Type=application/json"
{
"openapi": "3.0.1",
"info": {
"title": "Elide Service"
},
"servers": [
{
"url": "/api/v1"
}
],