question

ChrisWork-9823 avatar image
0 Votes"
ChrisWork-9823 asked pituach answered

cant delete resource group due to master database

SQL server associated with it has already been removed when the delete resource group was run.

Db delete error

400 Client Error: Bad Request for url...

azure-sql-database
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Good day Chris

You question is very confusing and not clear

You use the tag "azure-sql-database" which is a database level service, but you speak about SQL Server which is on-premises Instance.

You claim that you "cant delete resource group due to master database". How did you came to this conclusion? What service/product are you using? Can you provide the exact error message which you get instead (or in addition) of your attempt to describe the error? In addition please provide screenshot

Thanks

0 Votes 0 ·

@pituach Sorry my bad, I did mean an Azure SQL server instance, forgot the azure at the beginning Within the resource group was an Azure SQL server instance with a single database. Using the Azure Management Portal, I selected all resources in the group and went through the process of selecting them for deletion, typing in yes when prompted and everything was cleaned up except the master database that was associated with the Azure SQL server.


On top of using the Azure Management Portal to delete the entire resource group, I have previously tried the following commands to get rid of the orphaned database; az sql db delete --ids "databaseID" az resource delete --ids "databaseID"


this was the error 400 Client Error: Bad Request for url: https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.Sql/servers//databases/master?api-version=2014-04-01 cli.azure.cli.core.util : Some resources failed to be deleted


0 Votes 0 ·
ManuPhilip avatar image
0 Votes"
ManuPhilip answered ManuPhilip commented

Hello @ChrisWork,


Connect Az with PowerShell and check the resources still presented in your tenant. If there are still connected resources, you can't delete the RG until the resources are being deleted. So, delete the associated resources and finally delete the RG


Get-AzResource -ResourceGroupName "RG Name" Get-AzResource -ResourceId "Resource ID" | Remove-AzResource


Finally remove the RG


Remove-AzResourceGroup "RG Name"




Please mark as "Accept the answer" if the above steps helps you. Others with similar issues can also follow the solution as per your suggestion


Regards,


Manu


· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@ManuPhilip I just ran the commands you suggested and got the following; Remove-AzResource: {"code":"40636","message":"Cannot use reserved database name \u0027master\u0027 in this operation.","target":null,"details":[{"code":"40636","message":"Cannot use reserved database name \u0027master\u0027 in this operation.","target":null,"severity":"16"}],"innererror":[]}


Here is what is returned when I run Get-AzResource -ResourceId "ResourceID" Name : master ResourceGroupName : "RG Name" ResourceType : Microsoft.Sql/servers/databases Location : australiaeast ResourceId : "Resource ID" Tags :


0 Votes 0 ·

Hi @ChrisWork, This says that your database removal is not completed successfully. How about dropping the database from SSMS


DROP DATABASE database_name;


Also note that in your last comment, full error details are missing


Thanks, Manu


0 Votes 0 ·

Here is my full error message;

Remove-AzResource: {"code":"40636","message":"Cannot use reserved database name \u0027master\u0027 in this operation.","target":null,"details":[{"code":"40636","message":"Cannot use reserved database name \u0027master\u0027 in this operation.","target":null,"severity":"16"}],"innererror":[]}
CorrelationId: af1f1e91-abe1-49cf-a09c-14db541dddb0

The database was orphaned when the Azure Management Portal did a clean up and removed the Azure SQL server it was attached to.
Can you give me instruction on how do I connect to the Azure SQL server, to drop a database, if it no longer exists?

Here is a screen grab of the resource group with only the master database left
9675-azure.jpg


0 Votes 0 ·
azure.jpg (73.8 KiB)
Show more comments
pituach avatar image
0 Votes"
pituach answered

Hi Chris

According to the entire information which you provided in the thread, it seems like your account have mishmash information. You should open a ticket from your subscription so the Azure support team will be able to examine your specific account. This is not a generic issue which we can probably solve in the forum but something which will require further information and probably manually fix.

More information...

You should not be able to create a database named master since there is already a database with this name which created for you in each logical server which you have.

You should not be able to see the master database in the portal since it is a system database and not user database.

If the image you provided shows all the resources in the resource group (assuming there no filter for example) then if there is any Azure SQL Database as we can see in the image then we should have seen the Azure SQL Server as well, but it is not there.

You should remember that the Azure SQL Server is not a real SQL Server instance but a logical entity which is managed by the Azure Engine which let you use it like a real master in a physical server instance.

It is possible that there is a mishmash with the logical entities as a result of a bug and therefore, you came to a strange situation like this. In order to examine the issue someone will probably need to examine your subscription in more deep.

You should probably open a support ticket from your subscription.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.