Azure CLI way to Create New Azure SQL Database

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…

Prerequisite

  • 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!

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.

Notes-

  • 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 ‘0.0.0.0’, 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.

Summary

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