How thedevopsjedi/azure-pim works
Project type and purpose
• This is a small automation/orchestration tool (a PowerShell script) that configures Azure Privileged Identity Management (PIM) for a given subscription and resource group.
• It’s intended to be run interactively or from an Azure DevOps pipeline to enable/disable role eligibility on Azure Resource Groups via the (undocumented) Azure PIM REST API.
File structure
• Top level contains:
• PIMConfigureEligibleAzureResource.ps1 – the single PowerShell script implementing the logic
• README.md – usage instructions and background
• .gitignore, LICENSE – project metadata
• No build system, no frontend/backend separation; this is a stand-alone script.
README for additional insights
• Authenticates using Connect-AzAccount (Azure PowerShell module).
• Uses raw HTTP calls to the Azure PIM API (because Terraform/AzCLI/PS modules don’t yet support PIM).
• Offers switches:
• ‑deleteAssignmentOnly (cleanup mode)
• ‑exportFiles (dump JSON before/after)
Main components and interactions
a. User / DevOps Pipeline
– Trigger: runs the PowerShell script with parameters
b. Authentication Layer
– Connect-AzAccount → Azure AD OAuth 2.0 endpoint
c. Script Core Logic (PIMConfigureEligibleAzureResource.ps1)
– Builds REST calls (role management policy, eligible assignment)
– Handles deletion-only and export-files modes
d. Azure PIM REST API
– Receives HTTP requests to assign/unassign eligible roles
– Returns JSON responses
e. Azure Resources
– Target Subscription → Resource Group(s)
– Azure AD group or service principal (memberObjectId)
f. Optional: Local File System (when ‑exportFiles)
– JSON before and after configuration
Architectural patterns and principles
• Single-entry automation script
• Clear separation of concerns:
1) Authentication
2) Request construction & API interaction
3) Optional export/persistence
• Idempotent design: can delete only or apply full config
– “Create/Update Role Management Policy”
– “Assign Eligible Role”
– “Delete Assignment (if cleanup mode)”
– Local (script + filesystem): green
– Trigger (user/pipeline): orange
– Azure cloud services: blue