Least privilege for service identities in Azure means scoping service principals and retiring their secrets
Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.
Service identities in Azure are service principals created from app registrations, used by pipelines, scripts and applications. Microsoft's documentation, read 16 Nov 2026, covers credentials, Conditional Access for workload identities and Defender for Cloud recommendations. This guide gives the steps, the roles to avoid and what to measure.
Open the calculator ยท All guides
A service principal is the tenant-local identity of an app registration and carries its own role assignments
Microsoft's documentation defines an application object as the global representation of an app and a service principal as its local representation in a specific tenant. The service principal defines what the app can do in that tenant and what resources it can access. Microsoft names three types: application, managed identity and legacy.
After app registration you can add secrets or certificates to make the app work. Microsoft's workload identity overview says a workload may deal with multiple credentials to access different resources, those credentials must be stored securely, and it is hard to track when a workload identity is created or when it should be revoked.
Permissions come from Azure RBAC role assignments to the service principal, and for Microsoft Graph and other APIs from consented application permissions. This guide covers the first; the second follows the same logic of requesting only what the app calls.
Managed identities are a special type of service principal and are covered in the workload identities guide. The remaining service principals are the ones that hold secrets, and they carry most of the exposure.
Microsoft's tools for service principals are Conditional Access, ID Protection and Defender for Cloud
Microsoft Entra Workload ID supports Conditional Access policies for service principals owned by your organization, and continuous access evaluation for workload identities. Microsoft says Microsoft Entra ID Protection can detect risks such as leaked credentials for workload identities.
Defender for Cloud assesses service principals, groups, managed identities and service accounts for excessive, unused or misconfigured permissions, according to Microsoft. It lists right-sizing recommendations for overprovisioned identities based on actual usage and attack path analysis that can show lateral movement from an overprivileged service principal.
Microsoft's RBAC best practices apply to service principals as they do to users: narrow scope, no wildcard custom roles, and a condition when the role can create role assignments. Microsoft's privileged roles reference lists Owner, User Access Administrator and Role Based Access Control Administrator among the roles to treat as privileged administrator roles.
Access reviews in Entra include role assignments as a review type, and the routes page shows where provider tools stop and other routes begin.
Steps to bring service principals to least privilege
- List all service principals with Azure role assignments, with owner, creation date, credential type and credential expiry.
- Identify service principals that run on Azure compute and replace them with managed identities, which remove stored credentials.
- For pipelines outside Azure, replace secrets with workload identity federation where the platform supports it (see the workload guide).
- For the service principals that must keep a credential, prefer certificates to secrets, set the shortest expiry the owner can support and record the owner.
- Replace Owner, Contributor and User Access Administrator assignments with the narrowest built-in role at resource group or resource scope.
- Where a service principal can create role assignments, add a condition so it can assign only the roles you list.
- Apply Conditional Access for workload identities to service principals that sign in from known locations.
- Delete service principals with no sign-in activity after a notice period, and repeat quarterly.
Roles and credentials to avoid on service principals
| Role or credential | Documented reason (Microsoft, read 16 Nov 2026) | Use instead |
|---|---|---|
| Owner on a subscription | Microsoft describes it as full access including the ability to assign roles in Azure RBAC. | A narrow built-in role at resource group scope. |
| Contributor on a subscription | Microsoft describes it as full access to manage all resources; Microsoft advises avoiding privileged administrator roles where a job-function role can be used. | A resource-specific role such as a data or deployment role. |
| User Access Administrator | Microsoft describes it as letting you manage user access to Azure resources. | Role Based Access Control Administrator with a condition on the roles it may assign. |
| Client secrets with no owner or expiry plan | Microsoft says credentials need secure storage and that it is hard to track when to revoke a workload identity. | Managed identity or federated credential; otherwise a certificate with a recorded owner. |
| Wildcard custom roles | Microsoft says wildcards can grant future Actions or DataActions that you did not intend. | Explicit Actions and DataActions. |
Measure service principals by credential age, scope and used permissions
Count service principals that hold a secret, the share that have an owner, and the share whose credentials expire within a set period. Count service principals with Owner, Contributor or User Access Administrator, and the share assigned at subscription or management group scope.
For the used side, track the Defender for Cloud right-sizing recommendations that name service principals, and sign-in activity from the Entra sign-in logs for service principals. A principal with a broad role and no sign-in in the review window is the first deletion candidate. The principle of least privilege explains why an idle principal still counts.
Related guides: AWS service identities and Google Cloud service identities.
Related pages
Sources
- Microsoft Learn: Application and service principal objects, read 16 Nov 2026
- Microsoft Learn: Workload identities, read 16 Nov 2026
- Microsoft Learn: Best practices for Azure RBAC, read 16 Nov 2026
- Microsoft Learn: Azure built-in roles for Privileged, read 16 Nov 2026
- Microsoft Learn: Permissions management (CIEM) in Defender for Cloud, read 16 Nov 2026
- Microsoft Learn: What are access reviews, read 16 Nov 2026
Last reviewed 16 Nov 2026.