azure-func-attach-user-mi
match
A conjunctive graph pattern. Variables (?x) bind node ids; every clause must hold.
where
?principal has EFFECTIVE Microsoft.
ManagedIdentity/userAssignedIdentities/assign/action on ?userMI
?principal has EFFECTIVE Microsoft.Web/sites/write on the target app (existing or new)
emit
| source type | Identity |
|---|---|
| target type | Compute |
| source | <principal> |
| target | <function app (existing or new)> |
| permissions | Microsoft.ManagedIdentity/userAssignedIdentities/assign/action Microsoft.Web/sites/write |
| conditions | role_compatibility |
Narrative
{principal.name} can attach user-assigned MI {userMI.name} to Function app {target.name} (assign/action + sites/write).
Raw rule rules/derived/azure/functions.yaml
id: azure-func-attach-user-mi
emits: CanAttachIdentity
match:
- - principal: null
- CanPassIdentity
- userMI: null
where:
- ?principal has EFFECTIVE Microsoft.ManagedIdentity/userAssignedIdentities/assign/action on ?userMI
- ?principal has EFFECTIVE Microsoft.Web/sites/write on the target app (existing or new)
emit:
source_type: Identity
target_type: Compute
source: <principal>
target: <function app (existing or new)>
permissions:
- Microsoft.ManagedIdentity/userAssignedIdentities/assign/action
- Microsoft.Web/sites/write
conditions:
- role_compatibility
false_positive_note: 'BOTH permissions are required: assign/action on the MI AND sites/write on the
app. Neither alone attaches the MI. Honor the assign/action resource scope.'
narrative: '{principal.name} can attach user-assigned MI {userMI.name} to Function app {target.name}
(assign/action + sites/write).'