The starting point was a single subscription that held all of our Terraform backend storage accounts. We maxed out Azure's 4,000 role assignment quota on that subscription. That problem is what first led me to write the weekly quota monitor. Moving the storage accounts into other subscriptions was the longer-term fix: better isolation, and a chance to apply the settings we wanted, including RBAC, disabled access keys, and private endpoints.

I designed and built the migration tool. A Function App API, running Python under a managed identity, did the Azure operations, tracked progress, and reapplied RBAC, network, and storage settings after each move. A web frontend let operators on the Cloud Platform team work by scope. Account tags identified owners and grouped notifications by system ID. After an account validated, the tool opened a pull request in Azure DevOps to update the landing-zone configuration.

Terraform did not follow the move

The part that was not obvious until we tried it was Terraform state.

After an Azure resource move, Terraform did not see the storage account in its new location, even with the azurerm provider pointed at the target subscription. It would try to create the account again. RBAC assignments also don't travel with a moved resource, so they have to be reapplied, which creates new role assignment IDs. If those assignments were originally managed in the same workspace, Terraform would try to reapply the old IDs.

So the Python scripts in the Function App updated state and code together. I call that state surgery because that's what it was: rewriting the state so it matched reality, including the new role assignment IDs.

During development this broke constantly. Pipelines failed. The tool would attempt duplicate deployments and duplicate RBAC assignments. Every move broke the Terraform code until we imported the resources, and imports aren't practical at this scale. That is why the automation had to do the state work.

How we batched the work

We grouped dev, test, and staging together per application and system ID.

The "hundreds of engineering hours saved" figure is an estimate, not a timesheet. Doing this by hand would have been at least five minutes per batch to move the storage, plus about 20 minutes per lifecycle, times four lifecycles, to import the RBAC assignments and the storage resource. It took longer when several accounts lived in one configuration.

Development and migration ran over multiple months. Once the tooling covered the scenarios we needed, we didn't have failed migrations.