Configure PIM for Azure Resources

Earn 25 points (50 with Pro) in two steps

  1. ① Read through the lesson — each section gets a ✓ as you scroll through it.
  2. ② When every section has a ✓, tap Complete lesson.

0 of 9 read · keep scrolling

✦ See fewer ads and earn double points — 50 a lesson instead of 25 — with Pro

Lesson: Configure Privileged Identity Management (PIM) for Azure Resources

Introduction: The Philosophy of Least Privilege

In modern cloud environments, identity is the new perimeter. As organizations migrate infrastructure to the cloud, the traditional concept of a secure, physical office network is no longer sufficient to protect sensitive assets. One of the most significant risks in cloud administration is the "always-on" privileged account. When an administrator has permanent access to high-impact roles—such as Global Administrator, Owner, or Contributor—that account becomes a primary target for attackers. If that account is compromised, the entire cloud environment is exposed.

Privileged Identity Management (PIM) is a service within Microsoft Entra ID (formerly Azure Active Directory) that enables you to manage, control, and monitor access to important resources in your organization. Instead of granting permanent access, PIM allows you to provide "just-in-time" (JIT) access. This means that users only hold the permissions they need for the specific duration required to complete a task. Once the task is finished, the access is automatically revoked.

This lesson explores how to configure PIM for Azure resources. We will move beyond the basic setup and dive into the mechanics of role assignments, activation policies, access reviews, and the auditing capabilities that turn a reactive security posture into a proactive one. Whether you are managing a small subscription or a large multi-tenant environment, understanding PIM is foundational to maintaining a secure and compliant cloud footprint.


Not read yet

Understanding the Core Concepts of PIM

Before we dive into the configuration steps, it is essential to understand the terminology that PIM uses. These concepts form the architecture of how access is granted and governed.

1. Eligible vs. Active Assignments

In a standard Azure setup, you might assign someone as an "Owner" of a resource group, and that assignment stays until you manually remove it. In PIM, we distinguish between two states:

  • Eligible Assignment: The user is authorized to use the role but does not currently have the permissions. They must perform an "activation" process to receive the permissions.
  • Active Assignment: The user has the permissions immediately, without needing to perform an activation. This is typically reserved for permanent, high-trust roles where JIT is not feasible.

2. Just-In-Time (JIT) Access

JIT access is the heart of PIM. By requiring users to activate their roles, you force a request-approval workflow or a justification process. This ensures that every high-privilege action is documented, audited, and time-bound.

3. Access Reviews

PIM isn't just about granting access; it is about verifying that access is still necessary. Access reviews allow administrators to periodically audit who has access to which roles and whether that access should continue.

Callout: PIM vs. Standard RBAC Standard Role-Based Access Control (RBAC) is static. You assign a user a role, and they keep it indefinitely. PIM is dynamic. It wraps the RBAC system in a layer of governance, requiring activation, time limits, and multi-factor authentication (MFA) to ensure that the "who, what, and when" of access is strictly controlled.


Not read yet

Prerequisites for PIM Deployment

Before you can configure PIM for Azure resources, you must ensure your environment meets the necessary licensing and permission requirements. PIM is a premium feature, and it is not included in the basic tier of Entra ID.

  • Licensing: You must have a Microsoft Entra ID P2 license or a Microsoft Entra ID Governance license for the users who will be using PIM. This applies to both the users requesting access and the administrators managing the policies.
  • Permissions: You must be a Privileged Role Administrator or a Global Administrator to manage PIM settings. Additionally, for Azure resources, you need at least User Access Administrator or Owner permissions on the subscription or management group level to onboard the resources into PIM.

Note: PIM for Azure resources is different from PIM for Entra roles. While the interface looks similar, PIM for Azure resources specifically governs access to subscriptions, resource groups, and individual resources like Virtual Machines or SQL databases.


Not read yet

Step-by-Step: Configuring PIM for Azure Resources

To begin using PIM, you must first "onboard" your Azure resources. This process enables the PIM management interface to control access to those specific resources.

Step 1: Discovering and Onboarding Resources

  1. Navigate to the Microsoft Entra admin center.
  2. Search for Privileged Identity Management in the search bar.
  3. Under the Azure resources section on the left-hand menu, click Resources.
  4. You will see a list of your subscriptions. If a subscription is not yet managed by PIM, click on it and select Discover resources.
  5. Select the resources you want to manage (e.g., specific resource groups or the entire subscription) and click Manage resource.
  6. Once managed, you can now define policies for how roles are assigned and activated for these resources.

Step 2: Configuring Role Settings

Once your resource is onboarded, you need to define the rules for how users activate their roles. These are called "Role Settings."

  1. In the PIM blade for your resource, select Settings.
  2. You will see a list of all available roles (Owner, Contributor, Reader, etc.). Click on a role to edit its settings.
  3. Activation Maximum Duration: Set the maximum time a user can hold the role before it expires. For high-risk roles, keep this short (e.g., 2 hours).
  4. Require Approval: You can choose to require a specific set of approvers to authorize the activation request.
  5. Activation Requirements: Ensure that "Require Multi-Factor Authentication" is checked. This is a non-negotiable best practice.
  6. Justification: Require the user to provide a ticket number or a business reason for the activation.

Tip: When setting the "Maximum Duration," consider the actual time required to perform common tasks. If a typical maintenance task takes 30 minutes, setting a 4-hour limit is reasonable. If you set it to 24 hours, you are essentially granting a full day of elevated access, which increases the window of risk.


Not read yet

Practical Examples of PIM Workflows

Let’s look at a real-world scenario. Imagine you have a team of cloud engineers who need to perform maintenance on a production SQL database.

The Scenario: Just-in-Time Access for Maintenance

Without PIM, these engineers would likely have "Contributor" access to the SQL server 24/7. If their credentials are stolen, the attacker has immediate access to the database.

With PIM implemented:

  1. Preparation: The administrator assigns the engineers as "Eligible" for the "SQL DB Contributor" role on the production resource group.
  2. Request: When an engineer needs to perform maintenance, they log into the PIM portal, find the "SQL DB Contributor" role, and click Activate.
  3. Verification: The system prompts the engineer for MFA. The engineer enters a business justification (e.g., "Applying security patch for ticket #1234").
  4. Activation: If configured for auto-approval, the role is activated immediately for 2 hours.
  5. Expiration: After 2 hours, the system automatically removes the role. The engineer is back to having no special permissions.

Code Snippet: Automating PIM Assignments via PowerShell

While the portal is great for setup, automation is key for scaling. You can use the Microsoft.Graph PowerShell module to manage eligible assignments.

# Connect to your tenant
Connect-MgGraph -Scopes "RoleManagement.ReadWrite.Directory"

# Define the user and the role
$userId = "user-guid-here"
$roleDefinitionId = "role-guid-here"
$resourceId = "/subscriptions/sub-id/resourceGroups/rg-name"

# Create an eligible assignment
New-MgRoleManagementDirectoryRoleAssignment -PrincipalId $userId `
    -RoleDefinitionId $roleDefinitionId `
    -DirectoryScopeId $resourceId `
    -Schedule @{
        StartDateTime = (Get-Date).ToString("yyyy-MM-ddTHH:mm:ssZ")
        Expiration = @{
            Type = "AfterDuration"
            EndDateTime = $null
            Duration = "P30D" # Valid for 30 days
        }
    }

Explanation: This script creates an eligible assignment for a user. Note that P30D represents an ISO 8601 duration, meaning the eligibility lasts for 30 days. This does not mean they have the role for 30 days; it means they are allowed to request the role for the next 30 days.


Not read yet

Best Practices and Industry Standards

Implementing PIM is not a "set it and forget it" task. To maintain a high security posture, follow these industry-standard practices.

1. Enforce MFA at All Times

Never allow a user to activate a privileged role without a strong MFA prompt. This protects against password-only compromises. Even if an attacker has a password, they cannot activate the role without the second factor.

2. Limit the Number of Global Admins

The number of users with permanent Global Administrator or Owner roles should be as close to zero as possible. If you must have permanent admins, consider using "Break-glass" accounts—highly secured, non-federated accounts that are only used in absolute emergencies.

3. Review Access Regularly

PIM provides an "Access Review" feature. Use this to conduct quarterly reviews where managers must verify whether their employees still need the access they have been granted. If a manager does not respond, you can configure the system to automatically remove the access.

4. Audit Everything

PIM logs are sent to the Entra ID audit logs. Use these logs to monitor for suspicious patterns, such as a user who activates a role every single day at 3:00 AM, or a user who consistently requests the maximum duration for every task.

Warning: Be cautious about "Auto-approval." While it is convenient to set up, it defeats the purpose of the security check. Only use auto-approval for low-risk roles where the justification is the primary goal, rather than the permission of a human approver.


Not read yet

Comparison Table: PIM Configurations

Feature Active Assignment Eligible Assignment
Access State Always enabled Enabled upon activation
Security Risk High (Permanent access) Low (Just-in-time)
MFA Required Recommended/Policy-based Mandatory for activation
Audit Trail Minimal High (Request/Justification)
Use Case Break-glass accounts Standard admin tasks

Common Pitfalls and How to Avoid Them

Pitfall 1: Over-permissioning the "Approver"

A common mistake is assigning the same user as both the requester and the approver for a role. This renders the approval workflow useless. Always ensure that the person approving the request is a different individual, preferably a manager or a security lead.

Pitfall 2: Neglecting "Break-Glass" Accounts

If you set up PIM and then disable all permanent administrative access, you might lock yourself out if the PIM service itself encounters an issue or if you misconfigure a policy. Always maintain at least two cloud-only, permanent administrator accounts that are excluded from conditional access policies and PIM restrictions, stored in a physical safe.

Pitfall 3: Not Monitoring the Audit Logs

Many organizations set up PIM and never look at the logs. The true value of PIM is the visibility it provides. If you aren't reviewing who is requesting what, you are missing out on the ability to detect insider threats or credential misuse.

Pitfall 4: Misunderstanding "Scope"

PIM for Azure resources is scoped. If you assign someone as an "Eligible" Contributor to a resource group, they cannot automatically activate that role for a different resource group. Ensure that you are applying the assignment at the correct level of the hierarchy (Management Group vs. Subscription vs. Resource Group).


Not read yet

Advanced Governance: Access Reviews

Access reviews are the final piece of the PIM puzzle. While PIM handles the request phase, access reviews handle the maintenance phase.

Setting up an Access Review

  1. In the PIM portal, navigate to Azure resources.
  2. Select Access reviews from the menu.
  3. Click New.
  4. Define the scope (e.g., all users assigned the "Owner" role).
  5. Set the frequency (e.g., monthly, quarterly).
  6. Select the reviewers (usually the resource owner or the user's manager).

When the review begins, the assigned reviewer will receive an email notification. They will see a list of users and their roles, and they must click "Approve" or "Deny" for each. If they deny, the access is automatically removed. This is a powerful mechanism for preventing "permission creep," where users accumulate access over time as they move through different projects.


Frequently Asked Questions (FAQ)

Q: Can I use PIM for non-Azure resources? A: Yes, PIM also supports Microsoft Entra roles (like Global Admin, Security Admin). The configuration steps for those are under the "Entra ID Roles" section of the PIM portal rather than the "Azure Resources" section.

Q: Does PIM work with Guest users? A: Yes, you can assign PIM eligibility to guest users in your directory. This is excellent for external consultants who need temporary access to your environment.

Q: What happens if a user's activation expires while they are in the middle of a task? A: The user will lose their permissions immediately. They will need to perform the activation process again to regain access. This is why it is important to set reasonable activation durations.

Q: Can I integrate PIM requests with ITSM tools like ServiceNow? A: Yes, through the Microsoft Graph API, you can integrate PIM requests with external ticketing systems. This allows you to automatically create a request in PIM when a ticket is opened in your ITSM tool.


Not read yet

Summary of Key Takeaways

  1. Identity is the Perimeter: In the cloud, controlling who has access to what is the most important security control you have. PIM is the primary tool for this.
  2. Shift from Static to Dynamic: Move away from permanent "Active" assignments. Embrace "Eligible" assignments that require justification, MFA, and approval.
  3. The Power of JIT: Just-in-Time access drastically reduces your attack surface. By keeping privileges "off" until they are needed, you significantly limit the impact of a compromised account.
  4. Governance is Continuous: Implementation is only the start. Use Access Reviews to ensure that permissions are cleaned up regularly and that only the right people have access to the right resources.
  5. Audit for Insight: Use the audit logs to gain visibility into your environment. Understanding how your team uses their privileges helps you refine your policies and detect anomalies early.
  6. Plan for the Worst: Always maintain "Break-glass" accounts that are exempt from your standard PIM policies to ensure you are never locked out of your own management plane.
  7. Automation is Essential: As your environment grows, use PowerShell or the Microsoft Graph API to manage assignments at scale, ensuring consistency across hundreds or thousands of resources.

By following these principles and implementing PIM systematically, you move your organization toward a Zero Trust architecture. You aren't just making it harder for an attacker to get in; you are fundamentally changing the nature of how your administrators interact with your cloud assets, making the environment more secure, more transparent, and more manageable.

Not read yet

Each section gets a ✓ as you scroll through it. Tap the button to jump to the next one.