Unable to create SQL database in Azure CLI

416 views Asked by At

I am trying to create a sql database using cloud shell

Note: I am able to create the sql database in the same resource group without any issues.

When i execute the command from the the cloud shell I get the following error message.

PS /home/xxx> az sql db create -g akshandsonlab -s aksdatabase -n mhcdb --service-objective S0
ResourceNotFoundError: The Resource 'Microsoft.Sql/servers/aksdatabase' under resource group 'akshandsonlab' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

I have followed the above link but I am reaching a dead end.

Can any one shed some light on this

Regards

Sudlo

2

There are 2 answers

1
Nancy On

You could check if you have selected the correct subscription when you create the SQL database via az account show.

If not, you could list the subscription(az account list) then set the subscription(az account set -s <subscriptionID>) that you want to create the resource.

If not, you could double-check the Resource name and Resource group name.

For more information, please refer to https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/error-not-found

0
Bhargavi Annadevara On

Note: I am able to create the sql database in the same resource group without any issues.

It looks like you want to create your database in a different resource group than that of your SQL server, which is not possible as of today. The SQL server and DB must exist in the same resource group.

This is most likely the reason you're seeing this error. Instead, run the command passing the resource group where your SQL server exists.

az sql db create -g <sql-server-resource-group> -s aksdatabase -n mhcdb --service-objective S0