AzureIntermediate

Azure Identity and Access Management: Best Practices Guide

8 min read

TL;DR

Master Azure Identity and Access Management with this comprehensive guide covering Azure AD implementation, RBAC, managed identities, and security best practices for enterprise environments.

Azure Identity and Access Management: Best Practices Guide

Executive Summary

Identity is the control plane for an Azure estate: nearly every serious cloud breach involves a credential or a permission that was broader than it needed to be. This guide covers the four mechanisms that decide who can do what in Azure — Microsoft Entra ID (formerly Azure Active Directory) for identities, Azure RBAC for resource permissions, managed identities for workload credentials, and Conditional Access for sign-in policy. After reading it you will be able to scope role assignments correctly, eliminate stored secrets for Azure-to-Azure calls, and put access reviews in place so permissions expire unless someone actively justifies them.

Why This Matters

Permissions in Azure accumulate. A contributor role granted for a migration is still there two years later; a service principal secret created for a proof of concept is still valid, stored in a pipeline variable nobody remembers. Attackers look for exactly this: a low-value compromised account with a standing path to production data. The failures are rarely exotic — they are flat group memberships, management-group-scope assignments nobody reviewed, and applications still authenticating with passwords where a managed identity would have removed the credential entirely. IAM work is unglamorous, but it is the control that determines how bad a bad day gets.

Core Concepts

The Identity Layer: Microsoft Entra ID

Entra ID holds the principals everything else refers to: users, groups, and service principals (the local representation of application registrations). Four components matter operationally:

ComponentPurpose
Users and groupsHuman identities and the group memberships that should drive all assignments
App registrations and service principalsIdentities for applications and automation
Conditional AccessPolicy evaluated at sign-in: user, device, location, and risk signals decide the controls applied
Identity ProtectionRisk detection on sign-ins and users, feeding Conditional Access and remediation workflows

One operational note: the legacy AzureAD PowerShell module used in older scripts has been retired in favour of the Microsoft Graph PowerShell SDK and the Graph API. The patterns below — create principals, assign roles, review risk — are unchanged; new automation should target Graph cmdlets rather than the retired module.

Azure RBAC: Scope Is the Decision

An Azure RBAC assignment is three things: a principal, a role definition, and a scope. Scope is where most mistakes happen. Assignments inherit downward, so a role granted at management-group or subscription scope applies to every resource beneath it. Assign at the narrowest scope that matches the job — resource group over subscription, resource over resource group.

Prefer built-in roles. When none fits, a custom role is an explicit allow-list of actions, with NotActions carving out specific operations:

{
    "Name": "Custom App Developer",
    "Description": "Can manage application resources",
    "Actions": [
        "Microsoft.Web/sites/*",
        "Microsoft.Resources/subscriptions/resourceGroups/read",
        "Microsoft.Resources/deployments/*",
        "Microsoft.Insights/components/*"
    ],
    "NotActions": [
        "Microsoft.Web/sites/Delete",
        "Microsoft.Web/sites/Stop/Action"
    ],
    "AssignableScopes": [
        "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>"
    ]
}

Assign roles to groups, not individuals. People change teams; group membership is the reviewable, automatable unit.

# Assign role to user
New-AzRoleAssignment `
    -SignInName "john.doe@contoso.com" `
    -RoleDefinitionName "Custom App Developer" `
    -ResourceGroupName "MyResourceGroup"

# Assign role to group
New-AzRoleAssignment `
    -ObjectId "<group-object-id>" `
    -RoleDefinitionName "Contributor" `
    -ResourceGroupName "MyResourceGroup"

For standing administrative access, use Privileged Identity Management (PIM) so powerful roles are eligible rather than active: the admin activates the role for a bounded window, with approval and justification, and it lapses automatically.

Managed Identities: Delete the Secret

Any workload running in Azure that calls Azure services should authenticate as a managed identity instead of with a stored credential. Azure issues and rotates the token; there is no secret in your code, configuration, or pipeline to leak.

A system-assigned identity is tied to one resource and deleted with it:

{
    "type": "Microsoft.Web/sites",
    "name": "[variables('webAppName')]",
    "apiVersion": "2021-02-01",
    "location": "[resourceGroup().location]",
    "identity": {
        "type": "SystemAssigned"
    }
}

A user-assigned identity is a standalone resource that can be shared by several workloads and survives them, which suits fleets of identical instances:

{
    "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
    "name": "[variables('identityName')]",
    "apiVersion": "2018-11-30",
    "location": "[resourceGroup().location]"
}

The identity still needs an RBAC assignment on the target resource — a managed identity with no role assignment can authenticate but do nothing, which is the correct default.

Conditional Access: Policy at Sign-In

Conditional Access evaluates signals at sign-in — user, group, application, device state, location, sign-in risk — and applies controls: require MFA, require a compliant device, or block. Sensible baseline policies include requiring MFA for all users, blocking legacy authentication protocols that cannot do MFA, and requiring stronger authentication for administrative roles. Roll policies out in report-only mode first and read the sign-in logs before enforcing; a misjudged policy locks out the people who would fix it.

# Create new policy
New-AzureADMSConditionalAccessPolicy `
    -DisplayName "Require MFA for all users" `
    -State "enabled" `
    -Conditions @{
        "Applications" = @{
            "IncludeApplications" = "All"
        }
        "Users" = @{
            "IncludeUsers" = "All"
        }
    } `
    -GrantControls @{
        "BuiltInControls" = @("mfa")
    }

Named break-glass accounts, excluded from Conditional Access and monitored aggressively, are the standard safety valve against policy lockout.

Monitoring, Risk, and Access Reviews

Sign-in and audit logs are where IAM problems become visible. Export them to Log Analytics so they outlive the portal's retention window and can be alerted on.

# Get sign-in logs
Get-AzureADAuditSignInLogs `
    -Filter "createdDateTime ge 2024-01-01" `
    | Where-Object { $_.Status.ErrorCode -ne 0 } `
    | Select-Object UserPrincipalName, AppDisplayName, Status, Location

Identity Protection scores sign-ins and users for risk — impossible travel, leaked credentials, anomalous behaviour — and risky users can be confirmed compromised and forced through password reset and re-registration of MFA:

# Get risky users
Get-AzureADRiskyUser `
    | Where-Object { $_.RiskLevel -eq "High" } `
    | Select-Object UserPrincipalName, RiskLevel, RiskState

# Confirm compromise
Confirm-AzureADRiskyUser `
    -UserIds "<user-id>" `
    -RiskState "confirmedCompromised"

Access reviews close the loop on group memberships and role assignments: on a schedule, reviewers must attest that each membership is still needed, and non-responses can be configured to remove access automatically.

{
    "displayName": "Quarterly Access Review",
    "scope": {
        "query": "/groups/<group-id>/members"
    },
    "reviewers": [
        {
            "query": "/users/<reviewer-id>"
        }
    ],
    "settings": {
        "mailNotificationsEnabled": true,
        "reminderNotificationsEnabled": true,
        "justificationRequired": true,
        "autoApplyDecisionsEnabled": false
    }
}

Decision Framework

SituationRecommendation
Human needs ongoing access to resourcesRBAC assignment to a security group at resource-group scope or narrower
Human needs occasional administrative accessPIM eligibility with time-bound activation, not a standing assignment
Azure workload calls Azure servicesManaged identity plus a scoped RBAC assignment; no stored secrets
Non-Azure workload or CI pipeline calls AzureWorkload identity federation where supported; otherwise a service principal with a certificate, short-lived and inventoried
Sign-in policy for the whole tenantConditional Access in report-only first, then enforce: MFA for all, block legacy auth
Verifying permissions are still neededScheduled access reviews with auto-apply for non-responses

Implementation Checklist

  • [ ] All role assignments made to groups, not individual users, with any exceptions inventoried
  • [ ] No standing Owner or Contributor assignments at management-group or subscription scope without a documented reason
  • [ ] PIM enabled for privileged roles; activations require justification and expire
  • [ ] Conditional Access baseline enforced: MFA for all users, legacy authentication blocked, break-glass accounts excluded and alerted on
  • [ ] Every Azure-hosted workload uses a managed identity; a scan finds no service-principal secrets in app settings or pipeline variables
  • [ ] Sign-in and audit logs exported to Log Analytics with alerts on failed sign-ins and role changes
  • [ ] Access reviews scheduled for privileged groups and application owners
  • [ ] Custom roles reviewed: wildcard actions justified, NotActions tested
  • Trade-offs

    Least privilege has an operational cost: narrow scopes mean more assignments to manage and more requests when someone's job crosses a boundary. PIM adds friction to administration — deliberately — but activation delays during an incident are real, so emergency procedures need to be rehearsed rather than assumed. Conditional Access interacts with everything, including service accounts and legacy clients that cannot satisfy modern controls; finding those dependencies is part of the rollout, and report-only mode exists precisely because the blast radius of a wrong policy is the whole tenant.

    When Not to Use

  • Custom roles are the wrong default when a built-in role is close enough; every custom role is a definition you must maintain as Azure adds services. Use built-ins first, customise only for a demonstrated gap.
  • Service principal secrets are the wrong choice for anything running in Azure — a managed identity removes the credential entirely. Secrets are also the wrong choice for CI pipelines that can use workload identity federation instead.
  • Standing privileged access is the wrong choice for humans even in small teams; if PIM licensing is genuinely out of reach, the fallback is separate admin accounts with MFA and alerting, not daily-driver accounts with permanent rights.
  • Conclusion

    Azure IAM reduces to a few disciplines applied consistently: assign permissions to groups at the narrowest scope, make privileged access just-in-time, let workloads authenticate with managed identities instead of secrets, and review everything on a schedule. None of these controls is individually difficult. Their value comes from coverage — the one unreviewed group or forgotten service principal is the one that matters.

    Why This Matters

    Understanding the business and technical context helps you make informed decisions rather than blindly following patterns.

    Trade-offs to Consider

    Every architectural decision involves trade-offs. Consider your specific requirements, team expertise, and scale when evaluating options.

    When NOT to Use This

    Knowing when a solution doesn't apply is as valuable as knowing when it does. Consider alternatives for your specific situation.

    Decision Framework

    Use this framework to evaluate whether this approach is right for your use case based on your specific constraints and requirements.

    Share this articleShare on XShare on LinkedIn

    Keep the decision frameworks coming

    One practical architecture guide a week — patterns, trade-offs, and when not to use them. No spam, unsubscribe anytime.