The Resource database under the resource group was not found

In this article, we will discuss how to fix the error “The Resource database under the resource group was not found” which I came ecross while working with a PowerShell script to rename the Azure SQL database.

The Resource database under the resource group was not found

Recently, I was working on a PowrShell script to rename the Azure SQL database. After executing the PowerShell script I got this error.

Below is the PowerShell script that I was using here.

Set-AzSqlDatabase -DatabaseName 'TsInfoSQLOld' -NewName 'TsInfoSQLNewDB' -ServerName 'tsinfo.database.windows.net' -ResourceGroupName 'DEMORG1'


After executing the above script I got the below error, This is the complete error message that I got.

Set-AzSqlDatabase : The Resource ‘Microsoft.Sql/servers/tsinfo.database.windows.net’
under resource group ‘DEMORG1’ was not found. For more details please go to
https://aka.ms/ARMResourceNotFoundFix

At line:1 char:1

Set-AzSqlDatabase -DatabaseName ‘TsInfoSQLOld’ -NewName ‘TsInfoSQLNew …

~~~~~~~~~~~~~~~~~

CategoryInfo : CloseError: (:) [Set-AzSqlDatabase], CloudException

FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.Database.Cmdlet.SetAzureSq
lDatabase

You can see the error here

The Resource database under the resource group was not found

Let’s discuss how did I fixed this error

The Resource database under the resource group was not found [Solved]

To fixed this error what we need to do is you need to provide the sever name correctly instead of specifying the commplete servername.

For example, if you wil see the below script. The server name specified is ServerName ‘tsinfo.database.windows.net’.

Set-AzSqlDatabase -DatabaseName 'TsInfoSQLOld' -NewName 'TsInfoSQLNewDB' -ServerName 'tsinfo.database.windows.net' -ResourceGroupName 'DEMORG1'

But, instead of the complete name you just need to mention the server name as “tsinfo” meaning just the first part. So, the script will be like below.

Set-AzSqlDatabase -DatabaseName 'TsInfoSQLOld' -NewName 'TsInfoSQLNewDB' -ServerName 'tsinfo' -ResourceGroupName 'DEMORG1'

Now, after executing the above script, I got the expected output without any issue

The Resource was not found in Azure SQL database

You may also like following the below articles

Wrapping Up

Well, in this article, we discussed how to fix the error “The Resource database under the resource group was not found” in Azure SQL. Hope it helps to fix the same issue that you might came across. Thanks for reading this article !!!