Allow permanent eligible assignment automation

Jomon Varghese 0 Reputation points
2023-04-01T08:48:26.0666667+00:00

How to configure Allow permanent eligible assignment to Yes via Azure policy?

To be applied at resource group level for contributor role

Do we have a resource provider to use?

Any sample Json code with IF statement?

Azure Policy
Azure Policy
An Azure service that is used to implement corporate governance and standards at scale for Azure resources.
1,014 questions
Microsoft Security | Microsoft Entra | Microsoft Entra ID
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Konstantinos Passadis 19,586 Reputation points MVP
    2023-04-01T08:53:54.5066667+00:00

    Hello @Jomon Varghese

    Can you try this JSON

    This policy definition uses an IF statement to check whether the value of the "allowPermanentEligibleAssignment" parameter is set to "Yes". If it is, the policy will modify the role assignment to enable "Allow permanent eligible assignment" for the Contributor role in the specified resource group.

    To apply this policy definition at the resource group level for the Contributor role, you can assign the policy to the resource group with the desired value for the "allowPermanentEligibleAssignment" parameter

    {
        "properties": {
            "displayName": "Allow permanent eligible assignment",
            "policyType": "BuiltIn",
            "mode": "All",
            "description": "This policy enables Allow permanent eligible assignment for the Contributor role in a resource group.",
            "metadata": {
                "category": "Access Control"
            },
            "parameters": {},
            "policyRule": {
                "if": {
                    "allOf": [
                        {
                            "field": "type",
                            "equals": "Microsoft.Authorization/roleAssignments"
                        },
                        {
                            "field": "Microsoft.Authorization/roleAssignments/memberType",
                            "equals": "User"
                        },
                        {
                            "field": "Microsoft.Authorization/roleAssignments/roleDefinitionId",
                            "equals": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]"
                        }
                    ]
                },
                "then": {
                    "effect": "modify",
                    "details": {
                        "roleDefinitionIds": [
                            "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]"
                        ],
                        "modifiableOnlyByAssignedIdentity": false,
                        "assignableScopes": [
                            "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name)]"
                        ],
                        "condition": {
                            "allOf": [
                                {
                                    "field": "Microsoft.Authorization/roleAssignments/elidable",
                                    "equals": true
                                },
                                {
                                    "field": "Microsoft.Authorization/roleAssignments/condition",
                                    "equals": "[if(equals(parameters('allowPermanentEligibleAssignment'), 'Yes'), 'true', 'false')]"
                                }
                            ]
                        }
                    }
                }
            }
        }
    }
    
    

    Kindly mark the answer as Accepted if it helped you !

    Thanks !


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.