Remove onlyIfNotExists experimental feature#17996
Conversation
|
Test this change out locally with the following install scripts (Action run 17833942159) VSCode
Azure CLI
|
Dotnet Test Results 90 files - 45 90 suites - 45 38m 25s ⏱️ - 24m 17s Results for commit a2ba350. ± Comparison against base commit e350617. This pull request removes 1921 and adds 652 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
|
Is there any docs on |
|
@tsmallig33 / @anthony-c-martin - I've started getting the following error when trying to use the onlyIfNotExists decorator:
This occurs whether or not the following is present in my I'm running Bicep CLI version 0.38.5. Any thoughts? This decorator is extremely useful for role assignments and Key Vault secrets. |
@jcbartle Do you have a correlationId that you could share for the issue? |
|
Hi, @tsmallig33, and thank you for the quick response! Here's a correlation ID from one of the failed deployments which contained this error message: 05881dbb-a8d4-48b6-8173-60f51263672c Some good news. I actually just removed that decorator from my role assignment modules, and that obviously fixed the error I posted about above, but the code is no longer throwing the old RoleAssignmentAlreadyExists error we always used to get. Did the MS team finally fix the Bicep bug which erroneously threw that error? It seems like that may be the case (and that would be awesome). Of course, I still need to use this decorator for Key Vault secrets, so figuring out the error above will still be useful. Best, |
|
Hi @jcbartle, thank you for sharing. I don't see the InvalidDeployment error code mentioned in the logs for that correlationId - can you confirm the correlationId and location/environment where you are seeing the issue? |
|
Good morning, @tsmallig33. Here's a different correlation ID with the same errors: 05881dbb-a8d4-48b6-8173-60f51263672c This is in Azure Government. FYI, it appears that the RoleAssignmentExists error is still getting thrown - at least some of the time - in Azure Commercial. I just deployed a template which uses this feature, and I got the error throw on one of my role assignments even though the onIfNotExists decorator is present. Interestingly, I do NOT get the template version error we're talking about. |
|
@jcbartle the feature does not fix the problem with role assignments. The feature checks if the resource exists by name. When exists does not deploy it again and when it does not exists deploys it. The role assignment issue is because you cannot have the same role and principal role assignment deployed if such already exists by another name. |
|
@slavizh - I know that this PR doesn't address the RoleAssignmentExists issue. I was asking above if perhaps it had been fixed elsewhere. Also just highlighting the differences between environments (Commercial versus Government). |
|
@tsmallig33 - just ran one template using two parameter files, one in Commercial and one in Government. Can confirm that the Correlation ID: cf24425b-901e-4869-b1d7-88b3925ee62d |
|
Thanks for providing more details. As a temporary workaround in Government, you can either try to switch to bicep v0.37 or if you can edit the json template, you can set the languageVersion to 2.1-experimental. |
|
Hi @jcbartle - it is possible that there was an update that was not fully rolled out in Government. It is now showing as fully rolled out, so would it be possible for you to retry the deployment and share the correlationId once again? |
|
Hello, @tsmallig33. Thanks for the response. Reran a template back-to-back in Commercial and Government. Bicep CLI version 0.38.33 No errors related to template language version!!! So I think that part is fixed - thank you. In the Government deployment, I get no errors or strange behavior at all. In the Commercial deployment, it seems that the onlyIfNotExists decorator is getting ignored when applying a role assignment to a resource group. That's the only time I'm getting the erroneous "The role assignment already exists." error. Applying role assignments on other resource types does not throw this error. Correlation ID: 50f20a23-50f0-4f55-9291-1f9ca5f26d72 |
|
Hi @jcbartle, thanks for the update. For the deployment with correlationId 50f20a23-50f0-4f55-9291-1f9ca5f26d72, the role assignment that is failing is returning not found when searched for by name/id, so a create is attempted. During the create, we are receiving the "The role assignment already exists" conflict error which indicates there may be an existing role assignment with a different id or name which onlyIfNotExists will not fix. |
|
Content PR created - https://github.com/MicrosoftDocs/azure-docs-pr/pull/307308 |
Description
Remove onlyIfNotExists experimental feature to make decorator GA.
Updated EmitterSettings.cs to emit template language 2.0 when onlyIfNotExists() decorator is used.
Checklist
Microsoft Reviewers: Open in CodeFlow