So you want to do a clean-up exercise in Azure and remove some databases. You go to delete a database that is no longer required (as shown below).
But you get an error code 400 – Failed to delete the database: ElasticMain.
ErrorCode: 400: ErrorMessage: The database ElasticMain on server smarties is used by job account elasdba. Database cannot be deleted or renamed while associated with job account.
What is going on? This is not an ordinary database. This is the control database (see this link for more details https://docs.microsoft.com/en-us/azure/sql-database/sql-database-elastic-jobs-overview) that stores all the metadata for when elastic jobs have been setup. (Which I totally forgot about).
Well as the message states you have to remove the job agent before deleting the database that used to be associated with the control database.
So navigate to elastic job agents and then click delete. Then you will be able to remove the database.