Azure / Azure/bicep

Ability to generate the same GUID value the portal does for roleAssignments

Open
#5,694 29 comments 13 reactions 0 assignees View on GitHub
enhancement Needs: Upvote
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

It is very frustrating today because we cannot compute the same GUID value for the roleAssignment's name that the one created by ARM (Portal & PIM) for the same role assignment values. This makes porting back governance & permissions "as code" way more difficult. We need to delete the ones not created by ARM Templates/Bicep if we want to declare them "as code".

ARM gives me this error message if I try to declare the same roleAssignment in Bicep:
```
{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"Conflict","message":"{\r\n \"error\": {\r\n \"code\": \"RoleAssignmentExists\",\r\n \"message\": \"The role assignment already exists.\"\r\n }\r\n}"}]}}
```

I get that the name is not the same and the problem is there. I don't have any way to guess how to come up with the same GUID that is generated on the ARM side. Is there any way to dig this info from the platform?

1. I'd like to, know the inputs and in which order, to pass to the `guid()` function to come up with the same value as ARM does. I guess this will be hard to reproduce, if even possible.

1. If the above is not possible, could we expose a new function that would allow this?

We are close to idempotency here, it is only a matter of generating the same GUID value for the name property.

Not exactly the same ask as #5105 but closely related.

Contributor guide

Open the contributing guide

Research direction

Start by investigating how ARM, the Azure portal, and PIM generate role-assignment GUIDs, then compare those inputs with Bicep's guid() behavior. Done means either documenting a reproducible input order that generates matching names or defining and implementing a function that enables idempotent role assignments.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
authorization, cloud
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.