Azure Data Platform · Azure Services

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

  • 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 AzureStuffs repos – https://github.com/Arulmouzhi/AzureStuffs

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

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.

Follow Blog and Show your Support for many more interesting upcoming Posts!

Advertisement

4 thoughts on “Azure CLI way to Create New Azure SQL Database

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s