Azure Data Platform · Azure Services

PowerShell way to Create New Azure SQL Database

Programming is like any other sport. You might know the rules but you have to play to learn! – Zuckerberg

In this blogpost, we would see how to create New SQL Database in Azure through PowerShell 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 – PowerShell Way!

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

Choose PowerShell option.

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

PowerShell 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.

PowerShell Screen – before start

PowerShell Code

PowerShell Code

In the above code pic, we need to give our subscription id and 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.

PowerShell 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

If you are one who loves to do the same in Azure CLI(JSON) itself, Azure CLI way to Create New Azure SQL Database

To know more New-AzSqlServer related info, visit here.

To know more New-AzSqlDatabase related info, visit here.

Related blogs-


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

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


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

Leave a Reply

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

You are commenting using your 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