How to rename an Azure SQL database using Azure CLI

Oct 14, 2019 · 1 min read · Post a comment
How to rename an Azure SQL database using Azure CLI

As a part of an Azure SQL Database administration series, this post will be a follow up from the last one, where i will write about renaming Azure SQL database, which is kind of a common scenario for those who work as a DevOps / SysOps cloud engineer.

There are currently three ways to rename an Azure SQL database, as far as i know.

  1. The first one is using TSQL, that requires SQL Server Management Studio. Run the following query:
    ALTER DATABASE [dbname] MODIFY NAME = [newDBname]
  2. Rename using the SQL Server Management Studio GUI. Just right click on the database name and click Rename.
  3. Rename using the Azure CLI, which will be explained in details in the next steps.


  • Azure subscription
  • Azure SQL database

Rename an Azure SQL database

Step 1. Open Terminal and login to the Azure Portal.

az login

It will open a new window using the default browser where you will be prompted for email and password.

Step 2. Rename the database using the following command:

az sql db rename --name "myfirstazuresqldb" --new-name "new-database-name" --resource-group "azure-sql-db-rg" --server "devcoopsdbserver"


You could even write the command in a bash script that will accept input parameter, for instance:

./ --name "new-name-db"

Feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.