Identity Best Practices: Security Hardening
The practices that keep your Azure identity secure โ least privilege, reviews, MFA, and proper delegation
๐ก Intermediate
โฑ 15 Minutes
๐ AZ-104 ยท Module 01
Why This Matters
Bad identity practices are how breaches happen. Weak passwords, unused accounts, overly permissive roles, missing audit trails โ these are the exploits hackers use. This doc covers the practices that keep your Azure identity secure: least privilege, regular reviews, MFA, and proper delegation.
Best Practice 1: Least Privilege Access
The Principle
Least Privilege = Give people only the minimum access they need, nothing more.
Wrong (Excessive Access)
Employee: "I need to deploy code"
Manager: "Okay, I'll give you Owner role on the subscription"
Result: Employee can delete EVERYTHING, including databases โ
Right (Least Privilege)
Employee: "I need to deploy code"
Manager: "Okay, I'll give you Container Registry Contributor (push images only)"
Result: Employee can only push to registry, can't delete other resources โ
Implementation
Step 1: Determine minimum needed
"What is the smallest role that lets them do their job?"
Step 2: Start with Reader
If you don't know, start with read-only, expand only if needed
Step 3: Remove over time
At end of project: "Do you still need Contributor?" โ Remove if not โ
Step 4: Review quarterly
Question every role: "Is this still necessary?"
Roles Ranked by Privilege (Most to Least)
1. Owner (everything, delete RGs)
โโ Give to: IT directors, cloud architects only
2. Contributor (create/modify, NOT delete RGs)
โโ Give to: Senior engineers, ops teams
3. Operator roles (specific operations like "start VMs")
โโ Give to: Support staff, automation accounts
4. Reader (read-only, no changes)
โโ Give to: Auditors, consultants, everyone else by default
5. Custom roles (exact permissions needed)
โโ Use when no built-in role fits
Best Practice 2: Regular Access Reviews
The Problem
Access Creep (Permissions grow over time):
Year 1: Employee hired โ assigned Contributor role
Year 2: Moves to different project โ keeps old Contributor role
Year 3: Gets promoted โ gets new role, doesn't lose old ones
Year 4: Employee leaves โ access not revoked for 6 months
Result: Former employee still has access โ
Implementation
Quarterly Access Review Checklist:
โโ Question 1: "Are they still in the role's group?"
โโ Question 2: "Does the job still require this role?"
โโ Question 3: "When was this role last used?"
โโ Question 4: "Has their responsibility changed?"
โโ Question 5: "Any unusual activity from this account?"
For YES answers โ Keep
For NO answers โ Remove (audit the removal)
Azure Policy to Help
Policy: "Inactive accounts get read-only access after 90 days"
Logic:
โโ If no sign-in in 90 days
โโ Remove Contributor role
โโ Keep Reader role (if absolutely needed)
โโ Send email asking "Can we disable this account?"
Result:
โโ Inactive accounts can't cause damage
โโ Budget impact reduced
โโ Security surface shrinks
Best Practice 3: Enable Multi-Factor Authentication (MFA)
The Problem
Weak Passwords Get Hacked:
Attacker gets password: P@ssw0rd123
โโ Without MFA: Logs in immediately โ
โโ With MFA: Can't log in (no phone/app) โ
Implementation
Option 1: Require for Admin Roles Only
โโ Conditional Access Policy
โโ If role is Global Admin โ Require MFA
โโ Balance: Moderate security + usability
Option 2: Require for All Users
โโ All users must register MFA method
โโ Highest security, impacts user experience
Option 3: Risk-Based (Conditional Access)
โโ Require MFA if:
โโ Sign-in from unusual location โ
โโ Sign-in from unfamiliar device โ
โโ Multiple failed login attempts โ
โโ Normal sign-in from known location โ No MFA needed โ
โโ Best balance of security + usability
MFA Methods (Order by Security)
1. Windows Hello / Biometric
โโ Most secure, works only on configured device
2. Microsoft Authenticator app
โโ Very secure, phone required
3. FIDO2 security key
โโ High security, requires special hardware
4. SMS/Text message
โโ Least secure (vulnerable to sim-jacking)
โโ Better than nothing, but don't use alone
Recommendation
Require Authenticator app or Windows Hello for admins.
Best Practice 4: Monitor Sign-in Activity
The Problem
Suspicious Activity = Breach in Progress:
Attacker steals password
โโ Signs in from China (your company is in US)
โโ Accesses data
โโ Deletes resources
โโ You don't notice for weeks โ
Implementation
Entra ID โ Monitoring โ Sign-in logs
What to Look For:
โโ Sign-in from unusual country
โโ Sign-in from unknown device
โโ Multiple failed sign-in attempts (password guessing)
โโ Sign-in outside business hours
โโ Bulk changes (deleting users, roles) by one person
โโ Access to sensitive data by unusual users
Set Up Alerts
Alert 1: Failed sign-in attempts
โโ If > 5 failed attempts in 5 minutes
โโ Email IT immediately
โโ Lock account for 15 minutes (Entra feature)
Alert 2: Sign-in from unusual location
โโ If user signed in from new country
โโ Require MFA re-verification
โโ Send notification to user
Alert 3: Unusual resource access
โโ If deleted users / roles changed by unusual person
โโ Flag for immediate investigation
โโ Require approval for such operations
Best Practice 5: Use Groups, Not Individual Assignments
The Problem
Individual Assignments Don't Scale:
Assign role to 50 individuals
โโ "sara@company.com" โ Contributor
โโ "mike@company.com" โ Contributor
โโ ... (48 more times)
โโ Someone leaves โ Did you remove all 12 of their roles?
โโ New person joins โ Did you add them to all required roles? โ
Implementation
Use groups instead:
โโ Create grp-engineering-contributors
โโ Add 50 people to the group
โโ Assign Contributor to the GROUP (once)
โโ Someone leaves โ remove from group, they lose all roles โ
โโ New person โ add to group, they get all roles โ
Policy: "All role assignments must be to groups, not individuals"
โโ Exception: Service principals can have individual roles
โโ Result: All human access is via groups, trackable, scalable
Best Practice 6: Separate Duty / Approval Required
The Problem
One Person Can Approve Themselves:
Alice wants Contributor role on Production
โโ Alice submits request
โโ Alice's manager approves (she IS the manager!)
โโ Alice approves her own request
โโ No one else reviews โ potential security risk โ
Implementation: Approval Chain
โโ Request: Employee submits (I need role X on resource Y)
โโ Approval 1: Manager (does this make sense for their job?)
โโ Approval 2: Security team (is the resource sensitive?)
โโ Approval 3: Resource owner (do you want this person?)
โโ Execution: IT provisions role only after all approvals โ
Exception: Same person cannot approve their own request
Azure Entitlement Management
Azure AD โ Identity Governance โ Entitlement Management
Setup:
โโ Create access package (e.g., "Production-Contributor")
โโ Define who can request (all employees)
โโ Define approval workflow (manager + security)
โโ Set expiration (roles auto-expire after 90 days)
โโ Auto-review (request approval before expiration)
Benefit:
โโ Formal audit trail โ
โโ Proper separation of duty โ
โโ Auto-cleanup (no orphaned roles) โ
โโ Full compliance evidence โ
Best Practice 7: Disable Unused Accounts Quickly
The Problem
Orphaned Accounts = Security Risk:
Employee leaves on Friday
โโ Managers forget to disable account
โโ Account still active Monday
โโ Credentials stolen/sold on dark web Tuesday
โโ Attacker has access Wednesday (nobody notices yet)
โโ Breach discovered 6 months later โ
Implementation
Offboarding Process
โโ Step 1: Day of departure โ Disable account in Entra ID
โโ Step 2: Revoke all role assignments
โโ Step 3: Remove from all groups
โโ Step 4: If not needed in 30 days โ Delete account
โโ Step 5: Audit: Search for old accounts, disable any orphaned ones
Automation & Verification
Automation:
โโ HR system โ Email IT when employee terminates
โโ IT runs script to:
โ โโ Disable account
โ โโ Remove from groups
โ โโ Send notification
โโ Manager confirms cleanup complete
Verification:
โโ Quarterly: Check for disabled accounts >90 days old, delete them
Best Practice 8: Use Service Principals with Passwords Only When Necessary
The Problem
Service Principals with Passwords = Shared Secrets:
App uses hardcoded password
โโ Password stored in code (bad!)
โโ Password stored in config files (bad!)
โโ Password rotated slowly/never (bad!)
โโ Password exposure = app compromise โ
Implementation
Bad: Service principal with password
app โ connects to Azure โ authenticates with password
โโ Password shared everywhere
Good: Service principal with certificate
app โ connects to Azure โ authenticates with certificate
โโ Certificate renewed automatically, harder to steal
Best: Managed Identity
app โ runs on Azure โ auto-authenticated (no credentials needed!)
โโ Azure manages all credential rotation internally โ
When Each Applies
Managed Identity (PREFERRED)
โโ Use when: App runs on Azure VM, App Service, Container, Function
โโ Benefit: Zero secrets to manage โ
Service Principal + Certificate
โโ Use when: App runs outside Azure, certificate can be renewed
โโ Benefit: More secure than passwords
Service Principal + Password (AVOID)
โโ Use only if: Certificate isn't possible (rare)
โโ Caveat: Must rotate password every 90 days minimum
Best Practice Checklist
โ Implement Least Privilege
โโ Audit: Are your lowest roles even lower than they need to be?
โ Quarterly Access Reviews
โโ Schedule: First Monday of each quarter
โโ Owner: IT security team
โ Require MFA for Admins
โโ Minimum: All roles with "Admin" in the name
โโ Better: Risk-based MFA for all users
โ Monitor Sign-in Logs
โโ Tool: Entra Sign-in logs
โโ Alert: Unusual geography, failed attempts, bulk changes
โ Use Groups Exclusively
โโ Audit: Do any role assignments exist to individual users?
โโ Policy: Enforce group-based assignments
โ Require Approval for Sensitive Roles
โโ Setup: Entitlement Management with approval workflow
โโ Sensitive roles: Owner, User Administrator, Global Admin
โ Offboard Quickly
โโ SLA: Disable account within 24 hours of departure
โโ Verify: Monthly audit of disabled accounts
โ Use Managed Identities
โโ Apps on Azure โ Managed Identity
โโ Apps off Azure โ Certificate or (rarely) password
How This Connects to Other Topics
Related to All Modules
- Every Azure operation goes through identity
- Policies enforce best practices (MFA, encryption, etc.)
- Audit logs prove compliance
See It In Action
Related labs:
Key Takeaways
๐ก Summary
- Least privilege = minimal access needed, nothing more
- Regular reviews = catch permission creep before it becomes a breach
- MFA = makes password theft much less valuable
- Groups = easier to manage than individual assignments
- Audit logs = prove who did what, when, for compliance
- Approval workflows = prevent unilateral access grants
- Quick offboarding = disable accounts before they become liabilities
- Managed identities = best-practice app authentication on Azure
Next Steps
- Review: Read this doc (you're here)
- Implement: Start with MFA and quarterly reviews
- Monitor: Set up sign-in alerts
- Audit: Migrate individual assignments to groups