apex-azure-rbac
Skill216 starsChanged 2 months agoMITView on GitHub
**ANALYSIS SKILL** — Find the right Azure RBAC role for an identity with least-privilege access; generate CLI, Bicep, and Terraform code to assign it. WHEN: "what role should I assign", "least privilege role", "RBAC role for", "role for managed identity", "custom role definition", "assign role to identity". DO NOT USE FOR: deploying (apex-azure-deploy), security audits (apex-azure-compliance).
In this repository40 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .github/copilot-instructions.mdCopilot instructions
- apex-agent-authoringSkill
- apex-azure-adrSkill
- apex-azure-artifactsSkill
- apex-azure-bicep-patternsSkill
- apex-azure-cloud-migrateSkill
- apex-azure-complianceSkill
- apex-azure-computeSkill
- apex-azure-cost-optimizationSkill
- apex-azure-defaultsSkill
- apex-azure-deploySkill
- apex-azure-diagnosticsSkill
- apex-azure-governance-discoverySkill
- apex-azure-kubernetesSkill
- apex-azure-kustoSkill
- apex-azure-prepareSkill
- apex-azure-quotasSkill
- apex-azure-reliabilitySkill
- apex-azure-resourcesSkill
- apex-azure-storageSkill
- apex-azure-upgradeSkill
- apex-azure-validateSkill
- apex-context-managementSkill
- apex-entra-app-registrationSkill
- apex-github-operationsSkill
- apex-golden-principlesSkill
- apex-host-debug-log-exportSkill
- apex-host-git-commitSkill
- apex-host-workflow-startSkill
- apex-iac-commonSkill
- apex-mermaidSkill
- apex-microsoft-docsSkill
- apex-python-diagramsSkill
- apex-terraform-patternsSkill
- apex-terraform-search-importSkill
- apex-terraform-testSkill
- apex-unslopSkill
- apex-vendor-promptingSkill
- apex-workflow-engineSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 50
Check assignment scope/inheritance, conditions, deny assignments and active PIM state separately.
- Very specific: line 55
Use editing tools to create custom-role.json.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Azure RBAC Skill
Find the minimal built-in Azure role that grants the requested permissions to
an identity, then generate the az role assignment create CLI and a Bicep
Microsoft.Authorization/roleAssignments snippet. Custom roles only when no
built-in fits.
Rules
- Least privilege first — prefer the most narrowly-scoped built-in role that satisfies the permissions; only define a custom role when no built-in fits
- Role assignment scope matters — prefer resource-level or resource-group scope over subscription scope
- Discover roles via
mcp_azure-mcp_documentation— invoke withcommand: "microsoft_docs_search"to query for built-in role definitions before generating any CLI or Bicep - Verify with
az role definition list— cross-check the discovered role against the live Azure RBAC catalogue - Use
guid()in Bicep forMicrosoft.Authorization/roleAssignmentsnames so assignments are idempotent across re-deploys; setprincipalType: 'ServicePrincipal'for managed identities - Granting roles requires elevated permission — see Prerequisites for Granting Roles below
- Generate before executing — require explicit approval for the exact principal, role and scope; generic role guidance does not confer write permission for role creation or assignment
- Authentication is separate — use canonical auth guidance; Azure RBAC does not grant Microsoft Graph API consent
- Out of scope: deploying resources (use
apex-azure-deploy), security audits (useapex-azure-compliance)
Steps
- Identify the operation — what action does the identity need (read storage, manage keys, deploy resources, etc.)?
- Search Microsoft docs — invoke
mcp_azure-mcp_documentationwithcommand: "microsoft_docs_search"and a query such as"Azure built-in role <operation>"(e.g.,"Azure built-in role read blob storage"); collect candidate role names + role IDs Verify against the live catalogue — preserve every permission block and scope:
az role definition list --name "<RoleNameOrId>" --query "[].{name:roleName,id:name,permissions:permissions,assignableScopes:assignableScopes}" --output jsonEvaluate all
permissions[]:actionsminusnotActionsfor management-plane operations, anddataActionsminusnotDataActionsfor data-plane operations, with wildcard matching against the requested provider operation. Combine grants across blocks and applicable assignments; exclusions subtract only from their own grant, not other roles. Management*/readdoes not grant blob/secret data access. Check assignment scope/inheritance, conditions, deny assignments and active PIM state separately. A role definition alone does not prove effective access. Missing permissions or unavailable catalogue evidence means unverified, not granted.If no built-in fits — scaffold a custom role definition with only the required
actions/dataActions:Use editing tools to create
custom-role.json; generate the command separately.{ "Name": "<CustomRoleName>", "Description": "<purpose>", "Actions": ["<provider>/<resource>/<action>"], "NotActions": [], "DataActions": [], "NotDataActions": [], "AssignableScopes": ["/subscriptions/<sub-id>"] }az role definition create --role-definition custom-role.jsonGenerate the assignment CLI —
az role assignment create \ --assignee <objectId|appId> \ --role "<RoleName>" \ --scope <scope>Generate the IaC snippet —
Bicep (AVM, preferred): AVM resource modules accept a
roleAssignmentsarray, so assign the role where the module deploys the resource. Pin the module version per AVM modules.module storage 'br/public:avm/res/storage/storage-account:<version>' = { name: 'storage' params: { name: storageAccountName roleAssignments: [ { principalId: principalId roleDefinitionIdOrName: 'Storage Blob Data Reader' principalType: 'ServicePrincipal' } ] } }Bicep (raw resource on an existing target):
param principalId string param roleDefinitionGuid string param storageAccountName string resource targetResource 'Microsoft.Storage/storageAccounts@2023-05-01' existing = { name: storageAccountName } resource roleAssignment 'Microsoft.Authorization/roleAssignments@2022-04-01' = { name: guid(targetResource.id, principalId, roleDefinitionGuid) scope: targetResource properties: { roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', roleDefinitionGuid) principalId: principalId principalType: 'ServicePrincipal' } }Terraform (raw
azurerm_role_assignment):resource "azurerm_role_assignment" "this" { scope = azurerm_resource_group.target.id # or any resource ID role_definition_name = "<RoleName>" # e.g., "Storage Blob Data Reader" principal_id = azurerm_user_assigned_identity.app.principal_id principal_type = "ServicePrincipal" # For idempotent imports/refreshes, lock to the role definition GUID instead: # role_definition_id = "/subscriptions/${data.azurerm_subscription.current.subscription_id}/providers/Microsoft.Authorization/roleDefinitions/<role-id-guid>" }AVM-TF callers should prefer the
Azure/avm-res-authorization-roleassignmentmodule over rawazurerm_role_assignmentwhen available — it wraps the resource with the canonical AVM input/output contract.- Verify the caller has assignment permission — cross-check with Prerequisites for Granting Roles
Prerequisites for Granting Roles
To assign RBAC roles to identities, you need a role that includes the Microsoft.Authorization/roleAssignments/write permission. The most common roles with this permission are:
- User Access Administrator (least privilege - recommended for role assignment only)
- Owner (full access including role assignment)
- Custom Role with
Microsoft.Authorization/roleAssignments/write
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

