@onlyIfNotExists() doesn't check for existing role assignments
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 79
Description
**Is your feature request related to a problem? Please describe.**
We have written a bunch of Bicep code over the past 2 years and the one problem we consistently run into is conflicts on role assignments in our templates because the role assignment already exists. Many of these role assignments were created when the resource was created with ARM templates in the past. Now, when creating with our Bicep templates, the GUID is different and the deployment fails because their is a conflict on the role assignment. When I heard about @onlyIfNotExists(), I thought it was the solution to this problem but unfortunately after testing, it doesn't look like it works this way.
**Describe the solution you'd like**
We would like the @onlyIfNotExists() decorator to check if a role assignment already exists for the same identity, role, and scope as an existing role assignment. It would only deploy if it did not exist. This would make our deployments much smoother.
Contributor guide
Research direction
The issue names no files, tests, or entry points. Start by tracing how @onlyIfNotExists() handles Azure role assignments, then determine how identity, role, and scope should be compared; done means deployments skip an existing matching assignment while still creating one when no match exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100