App Registrations, Service Principals, Managed Identities, and API Authentication
Introduction
When designing applications with Microsoft Entra ID, it is important to separate two fundamentally different questions:
- How do users or client applications authenticate to my application or API?
- How does my backend application authenticate to other resources?
These are separate authentication flows and often require separate identities.
Consider a solution consisting of:
- A React single-page application
- An ASP.NET Core Web API or Azure Function API
- Azure Key Vault
- Azure Storage
- Azure SQL Database
There are normally two authentication directions:
Inbound authentication
======================
User
|
v
React application
|
| Access token
v
Backend API
Outbound authentication
=======================
Backend API
|
| Workload identity
v
Azure Key Vault / Azure Storage / Azure SQL
The identity mechanism used for the outbound flow depends heavily on where the backend is hosted.
For workloads hosted in Azure, prefer Managed Identity for accessing Azure resources. For workloads outside Azure, use a Microsoft Entra application identity, represented in the tenant by a Service Principal, using a certificate or another supported credential mechanism.
1. The Core Microsoft Entra ID Concepts
Before examining the architectures, it is important to understand these concepts:
- App Registration
- Application Object
- Service Principal
- Enterprise Application
- Managed Identity
An App Registration is the Microsoft Entra administration experience through which an Application Object is created and configured.
2. App Registration and Application Object
When you create an App Registration in Microsoft Entra ID, an Application Object is created.
Microsoft Entra ID
|
v
App Registration
|
v
Application Object
The Application Object is the definition or blueprint of the application. It contains configuration such as:
- Application, or client, ID
- Redirect URIs
- Exposed API scopes
- App roles
- Certificates and client secrets
- Optional claims
- Required API permissions
- Token configuration
- Supported account types
For example:
App Registration
-----------------------------
Name: esign-api
Client ID: 1111-aaaa-...
Application ID URI: api://1111-aaaa-...
Delegated scopes:
- access_as_user
App roles:
- ESign.Admin
- ESign.Approver
The Application Object defines what the application is, how authentication should work, and which scopes or roles the application exposes.
However, it is generally not the security principal to which Azure role-based access control permissions are assigned.
3. Service Principal and Enterprise Application
When an application exists in a Microsoft Entra tenant, a Service Principal represents that application inside the tenant.
In the Azure portal or Microsoft Entra admin center, Service Principals normally appear under Enterprise applications.
Conceptually:
Application Object
|
| Instantiated in a tenant
v
Service Principal
|
v
Enterprise Application
An Enterprise Application is therefore primarily the portal representation of a Service Principal. It is not a separate identity type from the Service Principal.
Suppose an application has the following identifiers:
Application Client ID: 1111-aaaa
Application Object ID: 2222-bbbb
Service Principal Object ID: 3333-cccc
If the application must receive the Key Vault Secrets User Azure RBAC role, the authorized principal is the Service Principal:
Azure Key Vault
|
+-- Key Vault Secrets User
|
v
Service Principal
Object ID: 3333-cccc
The Service Principal Object ID, rather than the Application Object ID, identifies the tenant-local security principal for the RBAC assignment.
The Application Object defines the application. The Service Principal represents the application as a security identity within a particular tenant.
4. Managed Identity Is Backed by a Service Principal
Suppose an Azure Function App has its system-assigned Managed Identity enabled:
Azure Function App
|
+-- Identity
|
+-- System assigned: On
Azure creates an identity for the Function App in Microsoft Entra ID. Behind the scenes, this Managed Identity is represented by a Service Principal in the tenant.
Azure Function App
|
| System-assigned Managed Identity
v
Microsoft Entra ID
|
v
Service Principal
You do not manually create an App Registration for a system-assigned Managed Identity. Azure creates and manages the identity's lifecycle.
This provides several security advantages:
- No client secret needs to be stored in application settings.
- No certificate needs to be deployed solely for this identity.
- The application does not manage credential rotation.
- The identity is tied to the lifecycle of the Azure resource.
- Azure SDK credential chains can obtain tokens without embedding credentials.
A Managed Identity does not remove the Service Principal concept. It provides an Azure-managed workload identity that is represented in Microsoft Entra ID by a Service Principal.
5. Azure Function Accessing Azure Resources
Suppose an Azure Function must access:
- Azure Key Vault
- Azure Storage
- Azure SQL Database
The recommended approach is to enable a Managed Identity on the Function App and authorize that identity on each required resource.
Microsoft Entra ID
|
Managed Identity
Service Principal
|
+-------------+-------------+
| | |
v v v
Key Vault Azure SQL Storage
At runtime, the Function obtains Microsoft Entra access tokens using its Managed Identity.
Azure Function
|
| Request token for Key Vault
v
Microsoft Entra ID
|
| Access token
v
Azure Function
|
| Authorization: Bearer <token>
v
Azure Key Vault
Azure Key Vault evaluates whether the principal represented by the token has the required authorization.
For example, with Azure RBAC enabled on the Key Vault, the Managed Identity might receive:
Role: Key Vault Secrets User
Principal: Azure Function Managed Identity
Scope: The Key Vault resource
When the portal shows the Managed Identity as the role-assignment member, the underlying principal is the Service Principal representing that Managed Identity.
Therefore:
When we give a Function App's Managed Identity permission, we are ultimately assigning permission to the Service Principal that represents the Managed Identity.
6. Managed Identity Principal ID
The relationship is visible when using Azure CLI.
$miObjectId = az functionapp identity show `
--name $func `
--resource-group $rg `
--query principalId `
-o tsv
The returned principalId is the Object ID of the Service Principal representing the Function App's Managed Identity.
It can be used in an Azure RBAC assignment:
az role assignment create `
--assignee-object-id $miObjectId `
--assignee-principal-type ServicePrincipal `
--role "Key Vault Secrets User" `
--scope $keyVaultResourceId
Conceptually:
Function App
|
+-- Managed Identity
|
+-- principalId
|
v
Service Principal
|
v
RBAC Assignment
A system-assigned Managed Identity also has a clientId, but role assignment normally targets its principal or Object ID.
7. User Authentication Is a Separate Requirement
Now consider a different requirement:
User
|
v
React application
|
v
Azure Function API
The Function App's Managed Identity does not authenticate the user and does not define how the React application may call the API.
The Managed Identity answers:
Who is the Function App when it calls another protected resource?
The incoming user authentication design must answer:
Who is the user, which client is requesting the token, and is that client allowed to request access to this API?
This normally requires separate App Registrations for the React client and backend API.
8. App Registration for the Backend API
Create an App Registration representing the backend API.
App Registration
----------------
Name: esign-api
Under Expose an API, configure an Application ID URI, for example:
api://<esign-api-client-id>
Then expose a delegated permission such as:
access_as_user
Conceptually:
esign-api
|
+-- Expose an API
|
+-- api://<API-CLIENT-ID>
|
+-- access_as_user
The access_as_user scope means that an authorized client application can request a delegated access token for this API on behalf of a signed-in user.
The API must validate the incoming access token, including relevant properties such as:
- Signature
- Issuer (
iss) - Audience (
aud) - Expiration (
exp) - Delegated scopes (
scp) - Application roles (
roles), when app roles are used - Tenant and caller claims where required by the authorization model
9. App Registration for the React Application
The React application is a separate client application, so it should have its own App Registration.
App Registration
----------------
Name: esign-web
Platform: Single-page application
Redirect URI: https://app.example.com
The React App Registration is then granted delegated permission to the API:
API permissions
|
+-- esign-api
|
+-- access_as_user
The relationship becomes:
Microsoft Entra ID
|
+-- App Registration: esign-web
| React SPA client
|
+-- App Registration: esign-api
Backend API
|
+-- Exposes access_as_user
The React App Registration and API App Registration should be kept separate because they represent different application roles in OAuth 2.0:
- React is a public client.
- The backend is a resource server, or protected API.
A React SPA must not contain a client secret because browser-delivered code cannot keep secrets confidential.
10. User Sign-In and API Call Flow
The runtime flow is approximately:
User
|
| Sign in
v
React application
|
| Authorization request with PKCE
v
Microsoft Entra ID
|
| Authenticate user
| Issue access token
| aud = esign-api
| scp includes access_as_user
v
React application
|
| Authorization: Bearer <access-token>
v
Azure Function API
|
| Validate signature, issuer, audience and lifetime
| Verify required scope or role
v
API logic
This is the inbound authentication and authorization flow.
The Function App's Managed Identity does not participate in this user sign-in flow.
The React application should normally use the Microsoft Authentication Library for JavaScript, such as @azure/msal-browser or @azure/msal-react, with the authorization code flow and Proof Key for Code Exchange.
11. One Azure Function, Two Identity Responsibilities
The same Azure Function API can therefore have two different identity concepts:
Azure Function API
|
+-----------+-----------+
| |
v v
API App Registration Managed Identity
| |
| |
v v
Users and client Azure Key Vault,
apps call the API Storage and SQL
API App Registration
Answers:
Who can request a token for my API, and which scopes or roles can the caller receive?
Managed Identity
Answers:
Who is my Function App when it accesses Azure resources?
These are independent responsibilities and should not be confused.
12. Complete Azure-Hosted Architecture
Microsoft Entra ID
+----------------+----------------+
| |
v v
React App Registration API App Registration
|
+-- access_as_user
User
|
| Sign in
v
React application
|
| Access token for API
v
Azure Function API
|
| System-assigned or user-assigned
| Managed Identity
v
Managed Identity Service Principal
|
+------------+-------------+-------------+
| | | |
v v v v
Key Vault Azure SQL Storage Other Azure
resources
There are two separate security boundaries:
User to backend
React App Registration
+
API App Registration
+
Delegated scope such as access_as_user
Backend to Azure resources
Managed Identity
+
Azure RBAC or resource-specific authorization
13. What Changes for an On-Premises Backend?
Now consider an ASP.NET Core API running on-premises:
On-premises server
|
v
ASP.NET Core API
An on-premises server cannot ordinarily use an Azure resource's system-assigned Managed Identity, because that identity is tied to a supported Azure resource.
Instead, create or use an App Registration for the backend workload.
Microsoft Entra ID
|
v
App Registration: onprem-api
|
v
Application Object
|
v
Service Principal
Enterprise Application
The backend authenticates as the application using its Service Principal identity. Common credential approaches include:
- Certificate credentials, generally preferred over client secrets for traditional confidential-client authentication.
- Client secrets, which require secure storage, expiration monitoring, and rotation.
- Workload identity federation, where a supported external identity provider can establish trust without storing a long-lived secret.
A certificate is not automatically secure merely because it is a certificate. Its private key must still be protected, access-controlled, rotated, and monitored.
14. Giving an On-Premises Application Access to Azure Resources
Suppose the on-premises API needs access to Azure Key Vault.
Assume its identifiers are:
Application Client ID: 1111-aaaa
Application Object ID: 2222-bbbb
Service Principal Object ID: 3333-cccc
The Azure RBAC assignment is made to the Service Principal:
Azure Key Vault
|
+-- Access control (IAM)
|
+-- Key Vault Secrets User
|
v
Service Principal
Object ID: 3333-cccc
At runtime:
On-premises ASP.NET Core API
|
| Client ID plus certificate,
| secret, or federated assertion
v
Microsoft Entra ID
|
| Access token for Key Vault
v
On-premises API
|
| Authorization: Bearer <token>
v
Azure Key Vault
Azure Key Vault authorizes the Service Principal represented by the access token.
15. User Authentication for an On-Premises API
Suppose users access the on-premises API through React:
User
|
v
React application
|
v
On-premises API
The interactive user authentication pattern remains essentially the same:
- The React SPA has an App Registration.
- The API has an App Registration.
- The API exposes a delegated scope, such as
access_as_user. - The React App Registration receives delegated API permission for that scope.
- React requests an access token for the API.
- The API validates the token and applies authorization.
Separately, when the on-premises API accesses Azure resources, it authenticates as its workload identity:
On-premises API
|
| Application authentication
v
Microsoft Entra ID
|
| Access token
v
Azure Key Vault / Storage / SQL
Once again, inbound user authentication and outbound workload authentication are separate flows.
16. Azure-Hosted and On-Premises Comparison
| Requirement | Azure-hosted API | On-premises API |
|---|---|---|
| Users authenticate through React | App Registration | App Registration |
| Backend API represented in Entra | API App Registration | API App Registration |
API exposes access_as_user
|
Yes, when delegated user access is required | Yes, when delegated user access is required |
| React has its own App Registration | Yes | Yes |
| Backend accesses Azure resources | Managed Identity preferred | Service Principal/workload identity |
| Static credential normally required | No for Managed Identity | Usually a certificate or secret, unless federation is available |
| Azure RBAC principal | Managed Identity's Service Principal | Application's Service Principal |
| Credential lifecycle | Managed by Azure | Managed by the organization or external federation |
The user-authentication architecture is essentially the same in both hosting models.
The major difference is how the backend authenticates itself when accessing downstream Azure resources.
17. Application Object ID, Client ID, and Service Principal Object ID
These identifiers are frequently confused.
Application or Client ID
Example:
11111111-1111-1111-1111-111111111111
The Client ID identifies the application definition during authentication and configuration.
It may appear in values such as:
api://11111111-1111-1111-1111-111111111111
It is also used by client applications when requesting tokens.
Application Object ID
Example:
22222222-2222-2222-2222-222222222222
This identifies the Application Object inside Microsoft Entra ID.
It is useful when querying or modifying the App Registration itself, but it is not normally the principal identifier used for Azure RBAC.
Service Principal Object ID
Example:
33333333-3333-3333-3333-333333333333
This identifies the Service Principal representing the application in a particular tenant.
It is typically the correct identifier when assigning Azure RBAC directly to the application identity.
az role assignment create `
--assignee-object-id "33333333-3333-3333-3333-333333333333" `
--assignee-principal-type ServicePrincipal `
--role "Key Vault Secrets User" `
--scope $resourceId
A concise mental model is:
Client ID
= Which application definition?
Application Object ID
= Which Application Object in the directory?
Service Principal Object ID
= Which tenant-local security principal?
18. Where Permissions Are Actually Assigned
Azure resource permissions are assigned to a security principal, not to the Application Object definition itself.
For a Managed Identity:
Managed Identity
|
v
Service Principal
|
v
Azure RBAC assignment
For a traditional application identity:
App Registration
|
v
Service Principal
|
v
Azure RBAC assignment
In both cases, Azure authorization eventually involves a Service Principal.
The difference is how the workload identity is created, authenticated, and managed:
| Identity approach | Creation and lifecycle | Runtime credential |
|---|---|---|
| System-assigned Managed Identity | Created and removed with the Azure resource | Managed by Azure |
| User-assigned Managed Identity | Separate Azure resource that can be attached to supported workloads | Managed by Azure |
| App Registration and Service Principal | Created and governed in Microsoft Entra ID | Certificate, secret, or federation |
19. Scopes and App Roles Are Defined on the Application
Although Azure RBAC is assigned to a Service Principal, application authorization definitions such as scopes and app roles are defined on the Application Object.
API App Registration
|
+-- Exposed scopes
| |
| +-- access_as_user
|
+-- App roles
|
+-- Admin
+-- Approver
+-- Reader
These definitions belong to the application blueprint. Their tenant-specific grants and assignments involve Service Principals, users, or groups.
A more precise rule is therefore:
The Application Object defines what the application is and which scopes or roles it exposes. Service Principals participate in tenant-specific consent, assignments, and resource authorization.
20. Delegated Permissions and Application Permissions
Delegated permission
A delegated permission is used when an application calls an API on behalf of a signed-in user.
User
|
v
React client
|
| access_as_user
v
Backend API
The access token normally contains an scp claim:
{
"aud": "<api-client-id>",
"scp": "access_as_user"
}
This is appropriate for an interactive React SPA calling a protected API.
Application permission
Application permissions are used for non-interactive service-to-service communication when there is no signed-in user.
Service A
|
| Application identity
v
Service B
The access token normally contains a roles claim rather than an scp claim:
{
"aud": "<service-b-client-id>",
"roles": [
"Documents.Read.All"
]
}
The receiving API must explicitly authorize the expected scope or application role. Successfully validating a token is necessary, but it is not a replacement for authorization.
21. Do Not Confuse Azure RBAC with API Permissions
Two different authorization systems may exist in the same architecture.
Azure RBAC
Used for Azure resource authorization, for example:
Function Managed Identity
|
+-- Key Vault Secrets User
+-- Storage Blob Data Contributor
API permissions, scopes, and app roles
Used for OAuth-protected APIs, for example:
React client
|
+-- Delegated scope: access_as_user
v
Backend API
or:
Daemon Service Principal
|
+-- Application role: Documents.Read.All
v
Backend API
An Azure RBAC role does not automatically grant an OAuth scope, and an OAuth scope does not automatically grant Azure RBAC access.
22. Can the Same API App Registration Be Used for Outbound Authentication?
For an on-premises API, its App Registration and corresponding Service Principal may be used both to:
- Represent the API that receives user access tokens.
- Authenticate the backend as a confidential client when it calls Azure resources or other APIs.
This is technically possible, but the two responsibilities should still be understood separately.
In security-sensitive environments, separate identities may be preferable when:
- Different teams own inbound and outbound configuration.
- Different credential lifecycles are required.
- Least privilege is easier to enforce with separate principals.
- Auditing must distinguish API exposure from downstream access.
- Compromise of one responsibility should not expose the other.
The correct design depends on governance and operational requirements, but the inbound and outbound flows must remain conceptually distinct.
23. Recommended Azure-Hosted Architecture
For a React application calling an Azure Function API that accesses Azure resources:
Microsoft Entra ID
+--------------------------------------+
| |
React App Registration API App Registration
| |
| exposes access_as_user
| |
+------------------+-------------------+
|
v
User --> React ----------> Azure Function API
|
| Managed Identity
v
Microsoft Entra ID
|
+-------------+-------------+
| | |
v v v
Key Vault Storage Azure SQL
Recommended practices:
- Use a separate App Registration for the React SPA.
- Use a separate App Registration for the protected API.
- Use delegated scopes for user-delegated access.
- Use app roles when role-based application authorization is required.
- Use Managed Identity for Azure-to-Azure access whenever supported.
- Grant the Managed Identity only the minimum required Azure roles.
- Avoid storing client secrets in the Function App merely to access Azure resources.
- Validate both the token and the required authorization claim in the API.
24. Recommended On-Premises Architecture
For a React application calling an on-premises ASP.NET Core API that accesses Azure resources:
Microsoft Entra ID
+--------------------------------------+
| |
React App Registration API App Registration
| |
| exposes access_as_user
| |
+------------------+-------------------+
|
v
User --> React ----------> On-Premises API
|
| Service Principal
| certificate, secret,
| or federation
v
Microsoft Entra ID
|
v
Key Vault / Storage / SQL
Recommended practices:
- Use a separate App Registration for the React SPA.
- Expose a delegated API scope from the API App Registration.
- Do not place confidential credentials in the React application.
- Prefer certificate authentication or workload identity federation over long-lived client secrets where feasible.
- Protect and rotate any private keys or secrets.
- Assign Azure RBAC roles to the Service Principal Object ID.
- Apply least privilege and scope role assignments as narrowly as practical.
25. Common Mistakes
Mistake 1: Using the Application Object ID for Azure RBAC
Azure RBAC expects a security principal. The relevant identifier is normally the Service Principal Object ID, or the Managed Identity principalId.
Mistake 2: Assuming Managed Identity authenticates users
Managed Identity identifies the Azure workload when it calls another resource. It does not replace the React and API App Registrations required for user authentication.
Mistake 3: Giving the React SPA a client secret
Browser applications are public clients. Any secret shipped to the browser can be extracted and must not be treated as confidential.
Mistake 4: Checking only whether a token is valid
The API must verify that the token is intended for the API and contains the required scope or role. Signature validation alone is insufficient.
Mistake 5: Treating scopes and Azure RBAC roles as the same thing
OAuth scopes and app roles protect APIs. Azure RBAC roles protect Azure resources. They are different authorization systems.
Mistake 6: Using broad permissions at subscription scope unnecessarily
A Function that only reads secrets from one Key Vault should not automatically receive broad Contributor access at the resource-group or subscription level.
Mistake 7: Confusing an Enterprise Application with a separate application definition
The Enterprise Application is the tenant-local Service Principal. The App Registration is the application definition.
26. Final Mental Model
APP REGISTRATION / APPLICATION OBJECT
"What is this application?"
|
v
Defines:
- Client ID
- Redirect URIs
- API scopes
- App roles
- Credentials and token configuration
|
v
SERVICE PRINCIPAL / ENTERPRISE APPLICATION
"Who is this application in this tenant?"
|
v
Receives tenant-specific permissions,
consent, assignments, and Azure RBAC roles
For Managed Identity:
AZURE RESOURCE
|
v
MANAGED IDENTITY
|
v
SERVICE PRINCIPAL
|
v
AZURE RBAC PERMISSIONS
For an Azure-hosted workload:
Function App / App Service / supported Azure workload
|
+-- Managed Identity
|
+-- Service Principal
|
+-- Azure RBAC
For an on-premises workload:
On-premises application
|
+-- App Registration
|
+-- Service Principal
|
+-- Certificate, secret,
| or federation
|
+-- Azure RBAC
For a user-facing React application:
User
|
v
React App Registration
|
| access_as_user
v
API App Registration
|
v
Backend API
27. Key Takeaways
- An App Registration creates and configures an Application Object.
- A Service Principal represents the application inside a tenant.
- Enterprise Application is the portal view commonly used to manage the Service Principal.
- A Managed Identity is represented in Microsoft Entra ID by a Service Principal.
- Azure RBAC permissions are assigned to a security principal, commonly identified by the Service Principal Object ID.
- For Azure-hosted workloads, use Managed Identity for Azure resource access whenever supported.
- For on-premises workloads, use a Service Principal with certificate authentication, a secret, or workload identity federation.
- React and the backend API normally need separate App Registrations.
- Expose a delegated scope such as
access_as_userfrom the API and grant it to the React client. - Inbound user authentication and outbound workload authentication are separate security flows.
The simplest rule to remember is:
App Registrations define applications. Service Principals represent application identities in a tenant. Managed Identities are Azure-managed workload identities represented by Service Principals.
Top comments (0)