Azure CLI way to Create New Azure SQL Database

3 min readNov 21, 2020


Where there is a dev, there is a code!

Dev mostly loves coding way to do most of the things! In this blogpost, we would see how to create New SQL Database in Azure through Azure Command Line Interface(CLI) Way. We can do this way, to get benefit of source control processes as well as simple infrastructure as a code programming model, one another alternative instead of many UI clicks…


  • Active Azure Subscription. If you don’t have, create a free account.
  • Subscription Level Contributor access or Owner access. we can check our Access in Subscriptions–>Access Control (IAM)–>View my Access. (like below)
Type Subscriptions in Global Search Resources Text Box
Check our Access at Subscription level

Create Azure SQL DB — Azure CLI Way!

In Azure Portal, Click Cloud Shell icon, next to Global Search Resources Text Box.

Choose Bash option.

If No Storage Account is allocated there for Azure CLI yet, Choose the Subscription and Click Create Storage.

Azure CLI Setup

Then, the new Storage Account would be created with new Resource Group under selected subscription automatically. Once it gets successful and after connected terminal, below screen would come.

Azure CLI Screen — before start

Azure CLI Code

Azure CLI Code

In the above code pic, we can change our required location, unique name that helps appending random name with our resource group, server name and database name. we can also give our login as well as password, even firewall, kind of settings and options to create server as well as database etc.,

If you are interest to re-use the above code, visit Arulmouzhi/AzureStuffs GitHub repos.

Azure CLI Screen — After run

Just like above pic, we can simply copy and paste. once we understand and do code, we can re-use later whenever we want, even we can automate this as a flow also.


  • The admin login name can’t be changed after it has been created.
  • We can’t able to create an additional SQL login with full administrative permissions in SQL Database.
  • If both startIP and endIP is equal to ‘’, means ‘Allow Azure services and resources to access this server’ set to ‘Yes’.

If you are new/ non-tech persons or who loves to do the same in Portal/UI itself, Create New Azure SQL Database

To know more az sql server related CLI commands, visit here.

To know more az sql db related CLI commands, visit here.


Kudos, We have successfully created our Azure SQL DB through Azure CLI! Thus, we saw how to do Azure CLI way to create New SQL Database and other settings and options.




MCT | MCP | MCSA-DB Dev | Databricks & Azure Certified Data Engineer Associate | 10x Microsoft [6x Azure☁] + 6x Databricks⚡ Certified✅ | Sr. Data Engineer