An Azure relational database service.
Hi Jean,
If the database still returns CannotMoveOrDropSyncMetadataDatabase, then Azure SQL still has that database registered in the SQL Data Sync service metadata, even if the Data Sync schemas/tables/users were already removed from inside the database.
The important point is that deleting dss / TaskHosting objects from the database does not necessarily remove the Azure Data Sync resource registration. The sync groups, members, or agents must be removed from the Azure side.
Please check these items:
- Go to the database in Azure portal and check: SQL database > Data Sync > Sync Groups / Sync Agents If the portal blade is empty or stuck, try checking with PowerShell or REST API for any remaining sync groups/agents. If you find any sync groups, delete them first and wait for deletion to fully complete. If there are on-premises sync agents, make sure they are removed/unregistered as well. If an agent is offline, bring it online if possible and then remove the sync group/agent cleanly. Do not manually drop more Data Sync objects in the database at this point. The issue is likely the service-side registration, not remaining user tables.
If nothing is visible in the portal/PowerShell but the database still cannot be deleted, this is likely an orphaned SQL Data Sync metadata registration. In that case, Microsoft Support needs to clear/reset the backend Data Sync registration for the database.
Please open a support request and include:
Subscription ID
SQL server name
Database name
Region
Error code: CannotMoveOrDropSyncMetadataDatabase
Confirmation that the sync group was deleted
Any sync group/agent names, if known
Approximate time when Data Sync was removed
Docs:
SQL Data Sync troubleshooting: https://learn.microsoft.com/en-us/azure/azure-sql/database/sql-data-sync-troubleshoot
Sync Groups delete REST API: https://learn.microsoft.com/en-us/rest/api/sql/sync-groups/delete
Sync Agents delete REST API: https://learn.microsoft.com/en-us/rest/api/sql/sync-agents/delete
In short, this is usually not fixed by database cleanup scripts alone. If Azure still thinks the database is a sync metadata database, the remaining sync registration has to be removed from the SQL Data Sync service metadata, and Microsoft Support may need to do that if the objects are orphaned.