First of all.
This is more a question to see if we can just ignore this error because everything works perfectly except for the false error. (It took a few hours to realize this).
Scenario: We recover a .bak (located in a Storage Account) into a Azure Managed Instance for a legacy app that rarely needs consulting. The Managed Instance gets removed and re-deployed from scratch when needed.
During the recovery process we run into the following error but the recovery still succeeds.
Microsoft.Data.SqlClient.SqlError: Database already exists. Choose a different database name.
When running the following query 2 rows get returned.
One with error code 1801 - Database already exists.
One with no error code that says recovery completed.
SELECT *
FROM sys.dm_operation_status
WHERE resource_type_desc = 'DATABASE'
ORDER BY start_time DESC;
Find it a bit strange the error pops up but everything works perfectly.
The program connects to the database and all data is available.