You can assign Business Central (and other) API permissions to managed identities. Use the Microsoft Graph PowerShell module and then create an Entra Application record in Business Central for the client id of the managed identity (without the need for a separate app registration).
I’ve said it before and I’ll say it again. The best thing about blogging now and then is that when people find a better way to do the things you’re blogging about they sometimes tell you. Thanks to Arthur De Craemer for pointing me in the right direction for managed identities.
This is a continuation of the topic that I started here: Calling Business Central APIs Without a Client Secret. The goal is to have an Azure resource (Azure function in my case) able to call into Business Central without having to create, store and rotate a client secret.
In the previous post I described how you can use federated credentials to get a token for an app registration which has rights in Business Central. That’s all true, you can. But you don’t need to.
It turns out you can assign the appropriate permissions to the managed identity directly and bypass the need for an app registration.
The overview picture instead looks more like this. I (wrongly) assumed that because you can’t assign API Permissions to the Managed Identity in the Azure Portal UI that it wasn’t possible.
It is possible, but you have to do it through PowerShell instead using the Microsoft.Graph module.
# replace these placeholders as appropriate
$managedIdentityDisplayName = '<Managed_Identity_Display_Name>'
$roles = ('API.ReadWrite.All','app_access')
$tenantId = '<Azure_Tenant_Id>'
# login to Azure
Connect-MgGraph -Scopes Application.Read.All, AppRoleAssignment.ReadWrite.All -TenantId $tenantId
# get the service principal details for your MI and for BC
$managedIdentityServicePrincipal = Get-MgServicePrincipal -Filter "displayName eq '$managedIdentityDisplayName'"
$businessCentralServicePrincipal = (Get-MgServicePrincipal -Filter "displayName eq 'Dynamics 365 Business Central'")
# find the AppRoles to be assigned and then assign them
$roles | ForEach-Object {
$appRole = $businessCentralServicePrincipal.AppRoles | Where-Object Value -eq $_
Write-Host "Assigning $($appRole.Value)"
New-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $managedIdentityServicePrincipal.Id `
-PrincipalId $managedIdentityServicePrincipal.Id `
-ResourceId $businessCentralServicePrincipal.Id `
-AppRoleId $appRole.Id
}
This script uses the Microsoft Graph PowerShell module to:
API.ReadWrite.All
and app_access
in my case)Somewhat confusingly (at least to me!), you still can’t see the permissions that have been granted from the Managed Identity overview, but you can from Enterprise applications. Or, use PowerShell:
Get-MgServicePrincipalAppRoleAssignment -ServicePrincipalId $managedIdentityServicePrincipal.Id
Now that we’ve assigned the BC roles directly to the managed identity we don’t need to mess about with the federated credential and token exchange in the middle (as fun as it was). We can now create an Entra Application record in Business Central using the client id of the managed identity, no need for an app registration.
Check james’s original post https://jpearson.blog/2025/07/18/calling-business-central-directly-from-a-managed-identity/ on jpearson.blog which was published 2025-07-18 12:54:00