Closed autocloudarc closed 2 months ago
I came across this one too.
You can't remove Custom Roles until you've removed all Permission Assignments. Unfortunately, some are against individual Subscriptions. Easiest way at the moment (until the guys look at this) is to remove all Assignments, then delete the custom roles from the Root Management Group.
Thanks for your response @richardf5 . My results are inconsistent. After removing these role assignments, I did get a couple deleted, but others for which I removed role assignments are unfortunately still un-deleteable.
Update: Upon further investigation, it turns out that only the outlined custom roles deployed in the image below are un-delete-able. :-0 These also don't have any role assignments. My only workaround I have right now is to rename these roles with simple numeric or alphabetic names like 2, 3 and b, d unless some hero can save us before (we - really, is it only me?) encounter the tenant limit of 100 custom roles. Ouch!
Hey @autocloudarc,
Have you ensured these roles are not assigned to anything at any scope?
By default they each get assigned at least once to the subscription (bootstrap_subscription_id
) you specific to host the runners for CI/CD, you should see assignments for each of the plan and apply User-Assigned Managed Identities on the sub - please delete these role assignments
You will also have them on the root parent management group (root_parent_management_group_id
) you specified, if you didnt it will be the tenant root management group in your tenant - please also remove these.
Once you have removed the assignments you should then be able to delete the role definitions.
If still no luck, can you please try deleting the role definitions and add either the -debug
or -verbose
switch parameters and sharing an output (redacting any sensitive information) with us here
Thanks
Jack
Hi @jtracey93 ,
Great suggestion! Yes, after digging into the hierarchy recursively, finding and removing other role assignments, I was able to delete all of them now. Thank you so much! You truly are a hero after-all! :-)
It really would be convenient though, if there was a way to cleanup these role assignment post ALZ deployments for those of us who are practicing, learning or for PoC, hackathon situations, etc, where we expect to repeatedly and iteratevely deploy the ALZ multiple times to the same tenant, but under slighty different conditions and with various solutions (Azure DevOps, GitHub Public, GitHub Enterprise, With Self-Hosted Runners, With GitHub runners, etc). Maybe someone can come up with a click button Azure Function to do that for these post-deployment cleanup operations? Anyway, thanks again @jtracey93 and team for all your hard work and community support.
@autocloudarc Running Deploy-Accelerator
with the -destroy
parameter will remove these role assignments and definitions. Run this after you have run the destroy CD pipeline to clean everything up.
You'll need to target the same output folder as it requires the Terraform state file generation from the initial deployment.
When I attempt to remove the custom roles staged a the tenant root from my destroy operation, I am unable to do so and receive no detailed information of the problem.
Expected Behavior
I should be able to remove custom roles deployed by the solution, otherwise, I will receive an error when I attempt to redploy if the custom roles already exist.
Current Behavior
I receive a message in the notification area which states: "Failed to remove role definition(s) Failed to remove role with name Azure Landing Zones Subscription Owner (alz-mgmt) : An error occurred. Please try again later."
Possible Solution
Steps to Reproduce
Alternatively, run this PowerShell script in the cloud shell:
Input file:
Context (Environment)
I am practicing the deployments and rollbacks to demonstrate the functionality for customers and during the Azure Landing Zone Deployment VBD engagements.
$PSVersionTable.OS
:$PSVersionTable.PSEdition
:PS /home/system> $PSVersionTable
Name Value
PSVersion 7.4.4 PSEdition Core GitCommitId 7.4.4 OS CBL-Mariner/Linux Platform Unix PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0
I can't delete custom roles deployed by this solution to clean up the tenant, which is a blocker for performing subsequent deployments, demonstrating for customer and for engagements.
Detailed Description
After running the "02 Azure Landing Zones Continuous Delivery " GitHub Actions workflow with the 'destroy' parameter to cleanup my previous deployments, I am unable to remove the custom roles from the tenant root. Deployment region is eastus2, although I don't believe roles are region specific resources. See screenshot below: