Microsoft Azure

How to create a single Azure database using Azure PowerShell

Hi, I share a script to create a Single Azure Database using PowerShell commands


  • Azure account
  • Azure module for PowerShell (

Disclaimer: Due to the constant updating of Cloud Computing technologies some steps may be different when reading the article, I will make the effort to keep it updated, but there could be some differences between what is shown below and the Azure console at the time of the implementation.

#Parameters for SQL Azure Server
$subscriptionId = '<subscriptionid>'
$location="East US"
$cred = $(New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList 'sqladmindemo', $(ConvertTo-SecureString -String 'p@$$w0rddemo' -AsPlainText -Force))
$resourceGroup = "rg-vvillar"

#Parameters for Firewall rules
$fwRuleName = "AllowedIps"
$startIpAddress = ""
$endIpAddress = ""

#Parameters for Azure SQL Database

#Connect to the Azure subscription
Set-AzContext -SubscriptionId $subscriptionId

#Create a resource group
New-AzResourceGroup -Name $resourceGroup -Location $location

#Create the server
New-AzSqlServer -ServerName $serverName -Location $location -ResourceGroupName $resourceGroup -SqlAdministratorCredentials $cred

#Create the database
New-AzSqlDatabase -DatabaseName $dbName -ResourceGroupName $resourceGroup -ServerName $serverName -RequestedServiceObjectiveName $dbSize

#Enable firewall IP Addresses (All IP addresses just for testing/tutorial purposes)
New-AzureRmSqlServerFirewallRule -FirewallRuleName $fwRuleName -StartIpAddress $startIpAddress -EndIpAddress $endIpAddress -ResourceGroupName $resourceGroup -ServerName $serverName

#Get server name (FQDN) to connect
Get-AzSqlServer -ServerName $serverName -ResourceGroupName $resourceGroup | Select-Object FullyQualifiedDomainName
0 0 vote
Article Rating
Notify of
Inline Feedbacks
View all comments