{"id":14230,"date":"2020-06-02T05:56:56","date_gmt":"2020-06-02T03:56:56","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/"},"modified":"2025-10-01T11:45:05","modified_gmt":"2025-10-01T09:45:05","slug":"how-to-create-an-azure-sql-database-using-azure-powershell","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/","title":{"rendered":"How to create an Azure SQL Database using Azure PowerShell"},"content":{"rendered":"<p>In this blog post, I&#8217;ll go through the steps to create an Azure SQL Database using Azure PowerShell.<\/p>\n<h4><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AzureSQL_logo.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-40312 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AzureSQL_logo.png\" alt=\"\" width=\"300\" height=\"166\" \/><\/a><\/h4>\n<h4>Introduction to Azure SQL Database<\/h4>\n<p>The SQL database services provided by Microsoft on the cloud are now grouped under the name of <a href=\"https:\/\/azure.microsoft.com\/en-us\/services\/azure-sql\/\">Azure SQL<\/a>.<\/p>\n<p>The Azure SQL family contains services that I will briefly summarize;<\/p>\n<ul>\n<li>Azure SQL Database &#8211; DBaaS (Database-as-a-Service)<\/li>\n<li>Azure SQL Managed Instance &#8211; PaaS (Platform-as-a-Service)<\/li>\n<li>SQL Server on Azure VMs &#8211; IaaS (Infrastructure-as-a-Service)<\/li>\n<\/ul>\n<p>In this blog post, I will use <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-sql\/database\/sql-database-paas-overview\">Azure SQL Database<\/a>.<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AS2.png\"><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"wp-image-40315 size-large aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AS2.png\" alt=\"\" width=\"1024\" height=\"538\" \/><\/a><\/p>\n<p>Azure SQL Database offers the following deployment options:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-sql\/database\/single-database-overview\">Single database<\/a> &#8211; a fully-managed, isolated database<\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-sql\/database\/elastic-pool-overview\">Elastic pool<\/a> &#8211; a collection of single databases with a shared set of resources<\/li>\n<\/ul>\n<p>I will not describe in detail this service but basically, it is a fully managed SQL database similar to a <a href=\"https:\/\/docs.microsoft.com\/en-us\/sql\/relational-databases\/databases\/contained-databases?view=sql-server-ver15\">contained database<\/a> in SQL Server.<\/p>\n<p>All the steps below can be done on the <a href=\"https:\/\/portal.azure.com\/\">Azure Portal<\/a>. For this blog post, I&#8217;ll only use <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/azure\/?view=azps-4.1.0\">Azure PowerShell<\/a> which you can install on your operating system or use online with <a href=\"https:\/\/shell.azure.com\/powershell\">Azure Cloud Shell<\/a>.<\/p>\n<h4>1) Install and Import Az module<\/h4>\n<p>First, we need to <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/azure\/install-az-ps-msi?view=azps-4.1.0\">install Azure PowerShell<\/a> which provides a set of commands to manage your Azure resources from your favorite operating system; Windows, macOS, and Linux.<\/p>\n<div>\n<div id=\"highlighter_814060\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<div class=\"line number7 index6 alt2\">7<\/div>\n<div class=\"line number8 index7 alt1\">8<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell plain\">PS C:\\&gt; Install-Module Az<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"powershell plain\">PS C:\\&gt; <\/code><code class=\"powershell functions\">Get-InstalledModule<\/code> <code class=\"powershell color1\">-Name<\/code> <code class=\"powershell plain\">Az | select Name, Version<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"powershell plain\">Name Version<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"powershell plain\">---- -------<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"powershell plain\">Az\u00a0\u00a0 4.1.0<\/code><\/div>\n<div class=\"line number7 index6 alt2\"><\/div>\n<div class=\"line number8 index7 alt1\"><code class=\"powershell plain\">PS C:\\&gt; <\/code><code class=\"powershell functions\">Import-Module<\/code> <code class=\"powershell plain\">Az<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4><\/h4>\n<h4>2) Sign in to Azure<\/h4>\n<p>Connect to your Tenant using your Tenant ID.<br \/>\nYou can find your Tenant ID in the <a href=\"https:\/\/portal.azure.com\/\">Azure Portal<\/a> under &#8220;Azure Active Directory&#8221;.<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/4_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-40288\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/4_1.png\" alt=\"Azure Active Directory\" width=\"107\" height=\"50\" \/><\/a><\/p>\n<div>\n<div id=\"highlighter_190601\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<div class=\"line number7 index6 alt2\">7<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell plain\">PS C:\\&gt; <\/code><code class=\"powershell functions\">Connect-AzAccount<\/code> <code class=\"powershell color1\">-Tenant<\/code> <code class=\"powershell string single\">'b9c70123-xxx-xxx-xxx-xxxx'<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"powershell plain\">Account\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 SubscriptionName\u00a0\u00a0\u00a0\u00a0 TenantId\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Environment<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"powershell plain\">-------\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ----------------\u00a0\u00a0\u00a0\u00a0 --------\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 -----------<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"powershell plain\">my<\/code><code class=\"powershell variable\">@Email<\/code><code class=\"powershell plain\">.com\u00a0\u00a0\u00a0\u00a0\u00a0 Visual Studio Ent\u00a0\u00a0\u00a0 b9c70978-xxx-xxx-xxx-xxxx\u00a0\u00a0\u00a0\u00a0 AzureCloud<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"powershell plain\">PS C:\\&gt;<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Then, if you use <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/azure\/manage-subscriptions-azureps?view=azps-4.1.0\">multiple Azure subscriptions<\/a>, select the one you want to work with.<\/p>\n<div>\n<div id=\"highlighter_69838\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell plain\">PS C:\\&gt; <\/code><code class=\"powershell functions\">Set-AzContext<\/code> <code class=\"powershell color1\">-SubscriptionId<\/code> <code class=\"powershell string single\">'891f5acc-xxx-xxx-xxx-xxxx'<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4><\/h4>\n<h4>3) Create a Resource Group<\/h4>\n<p>Let&#8217;s start with creating a <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-resource-manager\/management\/overview#resource-groups\">Resource Group<\/a>. A resource group is a container that holds related resources for an Azure solution.<\/p>\n<div>\n<div id=\"highlighter_604389\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<div class=\"line number6 index5 alt1\">6<\/div>\n<div class=\"line number7 index6 alt2\">7<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell plain\">PS C:\\&gt; <\/code><code class=\"powershell functions\">New-AzResourceGroup<\/code> <code class=\"powershell color1\">-Name<\/code> <code class=\"powershell string single\">'SQLFailover-lab-rg'<\/code> <code class=\"powershell color1\">-Location<\/code> <code class=\"powershell string single\">'France Central'<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"powershell plain\">ResourceGroupName : SQLFailover-lab-rg<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"powershell plain\">Location\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : francecentral<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"powershell plain\">ProvisioningState : Succeeded<\/code><\/div>\n<div class=\"line number6 index5 alt1\"><code class=\"powershell plain\">Tags\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 :<\/code><\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"powershell plain\">ResourceId\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 : \/subscriptions\/891f5acc-xxx-xxx-xxx-xxxx\/resourceGroups\/SQLFailover-lab-rg<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>To list all your Resource Groups use the Get-AzResourceGroup command:<\/p>\n<div>\n<div id=\"highlighter_925775\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell functions\">Get-AzResourceGroup<\/code> <code class=\"powershell plain\">| select ResourceGroupName<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4><\/h4>\n<h4>4) Create an SQL Server<\/h4>\n<p>Create a <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-sql\/database\/logical-servers\">logical server<\/a> with a unique server name to host our SQL databases.<\/p>\n<div>\n<div id=\"highlighter_124881\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell functions\">New-AzSqlServer<\/code> <code class=\"powershell color1\">-ResourceGroupName<\/code> <code class=\"powershell string single\">'SQLFailover-lab-rg'<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-ServerName<\/code> <code class=\"powershell string single\">'snasqlsrv-lab-01'<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-Location<\/code> <code class=\"powershell string single\">'France Central'<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-SqlAdministratorCredentials<\/code> <code class=\"powershell plain\">$(<\/code><code class=\"powershell functions\">New-Object<\/code> <code class=\"powershell color1\">-TypeName<\/code> <code class=\"powershell plain\">System.Management.Automation.PSCredential<\/code> <code class=\"powershell color1\">-ArgumentList<\/code> <code class=\"powershell string\">\"LabSqlAdmin\"<\/code><code class=\"powershell plain\">, $(<\/code><code class=\"powershell functions\">ConvertTo-SecureString<\/code> <code class=\"powershell color1\">-String<\/code> <code class=\"powershell string\">\"MyPassword\"<\/code> <code class=\"powershell color1\">-AsPlainText<\/code> <code class=\"powershell color1\">-Force<\/code><code class=\"powershell plain\">))<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>The last parameter defines the credentials I will use to connect as an administrator to my SQL Database server.<br \/>\nOnce the server is created you get the FQDN that will be used for connections.<\/p>\n<div>\n<div id=\"highlighter_653474\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell plain\">PS C:\\&gt; <\/code><code class=\"powershell functions\">Get-AzSqlServer<\/code> <code class=\"powershell plain\">| select FullyQualifiedDomainName<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"powershell plain\">FullyQualifiedDomainName<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"powershell plain\">------------------------<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"powershell plain\">snasqlsrv-lab-01.database.windows.net<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4><\/h4>\n<h4>5) Create a Server Firewall Rule<\/h4>\n<p>To access the server and all the databases from my client computer I need to create a <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/azure-sql\/database\/firewall-configure\">server firewall rule<\/a>.<br \/>\nHere I use a WebRequest to get my public IP into a variable and then create the server firewall rule.<\/p>\n<div>\n<div id=\"highlighter_90715\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell variable\">$myIp<\/code> <code class=\"powershell plain\">= (<\/code><code class=\"powershell functions\">Invoke-WebRequest<\/code> <code class=\"powershell plain\">ifconfig.me\/ip).Content<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"powershell functions\">New-AzSqlServerFirewallRule<\/code> <code class=\"powershell color1\">-ResourceGroupName<\/code> <code class=\"powershell string single\">'SQLFailover-lab-rg'<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-ServerName<\/code> <code class=\"powershell string single\">'snasqlsrv-lab-01'<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-FirewallRuleName<\/code> <code class=\"powershell string\">\"AllowedIPs\"<\/code> <code class=\"powershell color1\">-StartIpAddress<\/code> <code class=\"powershell variable\">$myIp<\/code> <code class=\"powershell color1\">-EndIpAddress<\/code> <code class=\"powershell variable\">$myIp<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h4>6) Connect to the SQL Server from SSMS<\/h4>\n<p>The SQL Server is now accessible from my computer client on port 1433. I can connect to it using SSMS.<\/p>\n<p><a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/4_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-40291 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/4_2.png\" alt=\"ConnectSSMS\" width=\"383\" height=\"307\" \/><\/a><br \/>\n<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/4_3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-medium wp-image-40292 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/4_3.png\" alt=\"SSMS\" width=\"300\" height=\"190\" \/><\/a><\/p>\n<h4>7) Create a database<\/h4>\n<p>The following command will create a database named &#8220;DB01&#8221; with an S0 performance level and using the sample schema &#8220;AventureWorksLT&#8221;.<\/p>\n<div>\n<div id=\"highlighter_436930\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<div class=\"line number2 index1 alt1\">2<\/div>\n<div class=\"line number3 index2 alt2\">3<\/div>\n<div class=\"line number4 index3 alt1\">4<\/div>\n<div class=\"line number5 index4 alt2\">5<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell functions\">New-AzSqlDatabase<\/code>\u00a0 <code class=\"powershell color1\">-ResourceGroupName<\/code> <code class=\"powershell string single\">'SQLFailover-lab-rg'<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number2 index1 alt1\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-ServerName<\/code> <code class=\"powershell string single\">'snasqlsrv-lab-01'<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-DatabaseName<\/code> <code class=\"powershell string single\">'DB01'<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-RequestedServiceObjectiveName<\/code> <code class=\"powershell string\">\"S0\"<\/code> <code class=\"powershell plain\">`<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"powershell spaces\">\u00a0\u00a0\u00a0\u00a0<\/code><code class=\"powershell color1\">-SampleName<\/code> <code class=\"powershell string\">\"AdventureWorksLT\"<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>This is it. We just a created an Azure SQL Database with a few commands. <a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/4_4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-40295 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/4_4.png\" alt=\"\" width=\"228\" height=\"239\" \/><\/a><\/p>\n<h4>Bonus: Creating a Copy of the database<\/h4>\n<p>I just want to mention a nice T-SQL command with Azure SQL Database that doesn&#8217;t exist on-premise: &#8220;CREATE DATABASE AS A COPY&#8221;.<br \/>\nThis command creates a copy of a database with a new name. This replace the backup\/&#8221;restore with move&#8221; that we do sometimes on SQL Server.<a href=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/CreateAsCopy.png\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-40302 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/CreateAsCopy.png\" alt=\"\" width=\"260\" height=\"70\" \/><\/a><br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\" wp-image-40303 aligncenter\" src=\"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/CreateAsCopy_2.png\" alt=\"\" width=\"280\" height=\"197\" \/><\/p>\n<h4>Cleanup<\/h4>\n<p>When you&#8217;re done with your tests you can delete all resources in the resource group (firewall rules, server, databases) with a single command;<\/p>\n<div>\n<div id=\"highlighter_971267\" class=\"syntaxhighlighter  powershell\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"powershell plain\">PS C:\\&gt; <\/code><code class=\"powershell functions\">Remove-AzResourceGroup<\/code> <code class=\"powershell color1\">-ResourceGroupName<\/code> <code class=\"powershell string single\">'SQLFailover-lab-rg'<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>Written by <a href=\"https:\/\/www.linkedin.com\/in\/steven-naudet-aa540158\/\">Steven Naudet<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, I&#8217;ll go through the steps to create an Azure SQL Database using Azure PowerShell. Introduction to Azure SQL Database The SQL database services provided by Microsoft on the cloud are now grouped under the name of Azure SQL. The Azure SQL family contains services that I will briefly summarize; Azure SQL [&hellip;]<\/p>\n","protected":false},"author":26,"featured_media":14227,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3271,955,229,99],"tags":[1338,1974,2550],"type_dbi":[],"class_list":["post-14230","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-azure","category-cloud","category-database-administration-monitoring","category-sql-server","tag-azure","tag-sql-database","tag-sql-server-2"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to create an Azure SQL Database using Azure PowerShell - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create an Azure SQL Database using Azure PowerShell\" \/>\n<meta property=\"og:description\" content=\"In this blog post, I&#8217;ll go through the steps to create an Azure SQL Database using Azure PowerShell. Introduction to Azure SQL Database The SQL database services provided by Microsoft on the cloud are now grouped under the name of Azure SQL. The Azure SQL family contains services that I will briefly summarize; Azure SQL [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-06-02T03:56:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-10-01T09:45:05+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AzureSQL_logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"548\" \/>\n\t<meta property=\"og:image:height\" content=\"303\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Microsoft Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Microsoft Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/\"},\"author\":{\"name\":\"Microsoft Team\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\"},\"headline\":\"How to create an Azure SQL Database using Azure PowerShell\",\"datePublished\":\"2020-06-02T03:56:56+00:00\",\"dateModified\":\"2025-10-01T09:45:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/\"},\"wordCount\":540,\"commentCount\":0,\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/AzureSQL_logo.png\",\"keywords\":[\"Azure\",\"SQL Database\",\"SQL Server\"],\"articleSection\":[\"Azure\",\"Cloud\",\"Database Administration &amp; Monitoring\",\"SQL Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/\",\"name\":\"How to create an Azure SQL Database using Azure PowerShell - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/AzureSQL_logo.png\",\"datePublished\":\"2020-06-02T03:56:56+00:00\",\"dateModified\":\"2025-10-01T09:45:05+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/AzureSQL_logo.png\",\"contentUrl\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2022\\\/04\\\/AzureSQL_logo.png\",\"width\":548,\"height\":303},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/how-to-create-an-azure-sql-database-using-azure-powershell\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create an Azure SQL Database using Azure PowerShell\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/#\\\/schema\\\/person\\\/bfab48333280d616e1170e7369df90a4\",\"name\":\"Microsoft Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g\",\"caption\":\"Microsoft Team\"},\"url\":\"https:\\\/\\\/www.dbi-services.com\\\/blog\\\/author\\\/microsoft-team\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to create an Azure SQL Database using Azure PowerShell - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/","og_locale":"en_US","og_type":"article","og_title":"How to create an Azure SQL Database using Azure PowerShell","og_description":"In this blog post, I&#8217;ll go through the steps to create an Azure SQL Database using Azure PowerShell. Introduction to Azure SQL Database The SQL database services provided by Microsoft on the cloud are now grouped under the name of Azure SQL. The Azure SQL family contains services that I will briefly summarize; Azure SQL [&hellip;]","og_url":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/","og_site_name":"dbi Blog","article_published_time":"2020-06-02T03:56:56+00:00","article_modified_time":"2025-10-01T09:45:05+00:00","og_image":[{"width":548,"height":303,"url":"http:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AzureSQL_logo.png","type":"image\/png"}],"author":"Microsoft Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Microsoft Team","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/"},"author":{"name":"Microsoft Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4"},"headline":"How to create an Azure SQL Database using Azure PowerShell","datePublished":"2020-06-02T03:56:56+00:00","dateModified":"2025-10-01T09:45:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/"},"wordCount":540,"commentCount":0,"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AzureSQL_logo.png","keywords":["Azure","SQL Database","SQL Server"],"articleSection":["Azure","Cloud","Database Administration &amp; Monitoring","SQL Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/","url":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/","name":"How to create an Azure SQL Database using Azure PowerShell - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/#primaryimage"},"image":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/#primaryimage"},"thumbnailUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AzureSQL_logo.png","datePublished":"2020-06-02T03:56:56+00:00","dateModified":"2025-10-01T09:45:05+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/#primaryimage","url":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AzureSQL_logo.png","contentUrl":"https:\/\/www.dbi-services.com\/blog\/wp-content\/uploads\/sites\/2\/2022\/04\/AzureSQL_logo.png","width":548,"height":303},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/how-to-create-an-azure-sql-database-using-azure-powershell\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create an Azure SQL Database using Azure PowerShell"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/bfab48333280d616e1170e7369df90a4","name":"Microsoft Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/c44a1a792c059f24055763aa77d80a244467f6eef724a8bd13db8d4a350b7a4c?s=96&d=mm&r=g","caption":"Microsoft Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/microsoft-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/14230","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/26"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=14230"}],"version-history":[{"count":2,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/14230\/revisions"}],"predecessor-version":[{"id":40588,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/14230\/revisions\/40588"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media\/14227"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=14230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=14230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=14230"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=14230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}