An Azure relational database service.
Treat an HTTP 404 from az sql db rename as an indeterminate outcome: query both the old and new database names, accept the rename if the new name exists and the old name does not, and retry only after the old name is confirmed to exist and the destination name is confirmed absent.
Recommended cutover sequence
Azure SQL Database rename changes the database resource identifier and is not documented as idempotent; therefore, immediately repeating a failed request could target a name that no longer exists. The supported CLI operation is az sql db rename --name ... --new-name ....^1^
- Wait for the temporary copy to become
Online.
A copy is not ready merely because the destination resource appears. During seeding,sys.databases.state_descisCOPYING; completion is represented byONLINE. The copy must not still be in progress when renamed.^2^ - Allow preceding configuration updates to settle.
Poll both reporting and temporary databases until their control-plane status is stable. Do not overlap scaling, auto-pause configuration, copy completion, delete, and rename requests. - Stop reporting connections before each rename.
Azure SQL Database cannot rename a database while users are connected. It also cannot rename one participating in active geo-replication or still creating a database copy.^3^ - Rename, then reconcile names before deciding whether to retry.
az sql db rename -g $rg -s $server -n $oldName --new-name $newName
$old = az sql db show -g $rg -s $server -n $oldName `
--query status -o tsv 2>$null
$new = az sql db show -g $rg -s $server -n $newName `
--query status -o tsv 2>$null
if ($new -and -not $old) { "Rename completed" }
elseif ($old -and -not $new) { throw "Safe to retry after bounded backoff" }
elseif ($old -and $new) { throw "Destination collision; do not retry" }
else { throw "Indeterminate state; stop and escalate" }
For a retryable state, use a small bounded retry count with exponential backoff and jitter. Azure Resource Manager explicitly recommends checking the operation or final resource state before resubmitting an interrupted asynchronous operation; its usual transient candidates are 408 and 5xx, not every 404.^4^
Interpreting the Activity Log
The documented rename REST operation is a control-plane POST to the source database’s /move endpoint with the target database resource ID in the request body.^5^ This establishes that rename changes the resource identity, but the public documentation does not specify that the exact update/delete records you observed are guaranteed internal sub-operations of rename.
Accordingly:
- The
Microsoft.Sqlcontrol-plane identity and close correlation in time are consistent with service-managed processing, but are not enough to conclusively classify those events. - A
204delete followed by updates can be compatible with an identity-changing operation, but it does not prove that the parent request completed correctly. - The rename can have changed the final resource state even when the client received an error. Resource Manager warns not to assume an interrupted management operation failed; inspect final state first.^4^
- A
ResourceNotFoundmeans Resource Manager could not retrieve the resource identified by that request. Verify the exact subscription, resource group, server, and database names recorded in the failed operation.^6^
Use the Activity Log correlation ID to group the events and preserve the full error response, caller, resource ID, operation name, timestamps, and client request ID. Azure SQL Activity Log events can be queried through the AzureActivity table.^7^
Serverless considerations
No published Microsoft documentation identifies intermittent rename 404s as a known General Purpose Serverless defect. Serverless auto-resume commonly takes about one minute, but its documented first-connection symptom is database-unavailable error 40613, not a control-plane ResourceNotFound response.^8^
Since auto-pause is already disabled in this workflow, focus on overlapping control-plane operations, copy completion, open connections, and post-error reconciliation rather than repeating that configuration step.
Alternative refresh methods
Your database-copy approach is the strongest full-database refresh mechanism listed here: it creates a transactionally consistent copy that becomes an independent database and includes database users, permissions, schema, stored procedures, and data.^2^ The remaining risk is the name-swap cutover, so harden that stage rather than replacing the copy.
If a slower, file-based refresh is acceptable, SqlPackage can export schema and user data to a BACPAC and import it as a new database. BACPAC files are compressed but not encrypted and must be protected appropriately.^9^ It still does not provide an atomic replacement of an existing database name.
If the failure remains reproducible after serialized operations and state-aware reconciliation, open an Azure support request and provide both successful and failed correlation IDs, full Activity Log JSON, exact CLI version/command output, database operation timestamps, and the old/new resource IDs. That evidence is required to determine whether the observed update/delete sequence came from Microsoft.Sql rename processing.
References
- az sql db rename
- Copy a transactionally consistent copy of a database in Azure SQL Database
- Modifiable configuration reference for Azure SQL Database
- Reliability in Azure Resource Manager
- Databases - Rename - REST API (Azure SQL Database) | Microsoft Learn
- Resolve errors for resource not found
- Azure SQL Database monitoring data reference
- Auto-pause and auto-resume in the serverless compute tier for Azure SQL Database
- SqlPackage