Table of contents
1.
Introduction
2.
Create SQL Server on a Windows virtual machine in the Azure portal
2.1.
Select a SQL Server VM image
2.2.
Provide basic details
2.3.
SQL Server settings
2.4.
Create the SQL Server VM
2.5.
Connect to SQL Server
2.6.
Log in to the VM remotely.
3.
Create SQL Server on a Windows virtual machine with Azure PowerShell
3.1.
Configure PowerShell
3.2.
Create a resource group
3.3.
Configure network settings
3.4.
Create the SQL VM
3.5.
Register with SQL VM RP
3.6.
Remote desktop into the VM
3.7.
Connect to SQL Server
3.8.
Clean up resources
4.
Frequently Asked Questions
4.1.
Can I install SQL Server on Azure VM?
4.2.
Can I use my own SQL license in Azure?
4.3.
Is Azure SQL Database same as SQL Server?
5.
Conclusion
Last Updated: Aug 13, 2025

Azure SQL Virtual Machine

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Azure SQL virtual machines are lift-and-shift applications that require minimal or no changes to be migrated quickly to the cloud. For migration to Azure, SQL virtual machines offer full administrative control over SQL Server instances and underlying operating systems. In this article, we will learn how to create SQL Server on a Windows virtual machine in the Azure portal and with Powershell. Let us move further and look into the topic.

Create SQL Server on a Windows virtual machine in the Azure portal

The first thing to do is to take an Azure subscription. If you don't have one, create a free account before you begin.

Select a SQL Server VM image

  1. Sign in to your Azure account.
  2. Select Azure SQL present in the left-hand menu of the Azure portal. If it is not in the list, select All services and type Azure SQL in the search box.
  3. Choose +Add to open the Select SQL deployment options page. By choosing Show details on the SQL virtual machines, you can view additional information.
  4. Select one free SQL Server License version from the dropdown and select Create.

Provide basic details

On the Basics tab, provide the following information:

  1. Select your Azure subscription in the Project Details section and then select Create new to create a new resource group. Type SQLVM-RG for the name.

2. Under Instance details:

  1. Type SQLVM for the Virtual machine name.
  2. Choose a location for your Region.
  3. For this quickstart, leave Availability options set to No infrastructure redundancy required
  4. Select the image with the SQL Server version in the Image list you want. 
  5. Change size for the size of the virtual machine and select the A2 Basic offering. Clean up your resources once you're done with them to prevent unexpected charges.

 

3. Under the Administrator account, provide a username, such as azure user, and a password. 

4. Choose Allow selected ports and select RDP (3389) from the dropdown under Inbound port rules.

SQL Server settings

Configure the following options on the Sql Server settings tab:

  1. Select Public for SQL Connectivity under Security & Networking, and change the port to 1401. 
  2. Select Enable under SQL Authentication. The SQL login credentials are set to the same user name and password that you configured for the VM. Use the default setting for Azure Key Vault integration. 

3. Change other settings if needed, and then select Review + create.

Create the SQL Server VM

Review the summary on the Review + create tab, and select Create to create SQL Server, resource group, and resources specified for this VM.

The deployment can be monitored from the Azure portal. The Notifications button at the top screen shows the deployment's basic status. Deployment can take several minutes.

Connect to SQL Server

  1. In the portal, Search for the Public IP address of your SQL Server VM in the Overview section of your virtual machine's properties.
  2. On a different computer connected to the Internet, open SQL Server Management Studio (SSMS).
  3. In the Connect to Server or Database Engine dialog box, edit the Server name value. Enter your VM's public IP address. Then add a comma and the custom port (1401) you specified when configuring the new VM. For example, 11.22.33.444,1401.
  4. Select SQL Server Authentication in the Authentication box.
  5. Type the name of a valid SQL login in the login box.
  6. Type the password of the login in the Password box and select Connect.

Log in to the VM remotely.

The following steps can be used to connect to the SQL Server virtual machine with Remote Desktop:

  1. After the Azure VM is created and is running, click the Virtual Machines icon in the Azure portal to view your VMs.
  2. Click the ellipsis, ..., for your new VM and click Connect.
  3. Open the RDP file that your browser downloads for the VM.

  1. There is no way to identify the publisher of the Remote Desktop Connection. Click Connect to continue.
  2. Click Use a different account in the Windows Security dialog. You would have to click More choices to see this. Specify the user name and password you configured when creating the VM. 
  3. Click OK to connect.

Using your local administrator credentials, launch SQL Server Management Studio after connecting to the SQL Server virtual machine. You could use your SQL login and password to connect with SQL Server Authentication during provisioning.

It is possible to change the machine and SQL Server settings directly based on your requirements if you have access to the machine. For example, you can configure the firewall settings or change SQL Server configuration settings.

Create SQL Server on a Windows virtual machine with Azure PowerShell

The first thing to do is to take an Azure subscription. If you don't have one, create a free account before you begin.

Configure PowerShell

  1. Open PowerShell. Enter Connect-AzAccount command and establish access to your Azure account. 
   Connect-AzAccount

2. Enter your credentials as soon as you see the sign-in window. Using the same email and password, sign in to the Azure portal.

Create a resource group

  1. Define a variable by giving a unique resource group name. 
  $ResourceGroupName = "sqlvm1"

2. Define a location of a target Azure region for all VM resources.

  $Location = "East US"

3. Create the resource group.

   New-AzResourceGroup -Name $ResourceGroupName -Location $Location

Configure network settings

1. Make a virtual network, subnet, and public IP address. These resources provide network connectivity to the virtual machine and connect it to the Internet.

$SubnetName = $ResourceGroupName + "subnet" $VnetName = $ResourceGroupName + "vnet" $PipName = $ResourceGroupName + $(Get-Random) # Create a subnet configuration $SubnetConfig = New-AzVirtualNetworkSubnetConfig -Name $SubnetName -AddressPrefix 192.168.1.0/24 # Create a virtual network $Vnet = New-AzVirtualNetwork -ResourceGroupName $ResourceGroupName -Location $Location ` -Name $VnetName -AddressPrefix 192.168.0.0/16 -Subnet $SubnetConfig # Create a public IP address and specify a DNS name $Pip = New-AzPublicIpAddress -ResourceGroupName $ResourceGroupName -Location $Location ` -AllocationMethod Static -IdleTimeoutInMinutes 4 -Name $PipName

2. Create a network security group. Configure rules to allow remote desktop (RDP) and SQL Server connections.

# Rule to allow remote desktop (RDP) $NsgRuleRDP = New-AzNetworkSecurityRuleConfig -Name "RDPRule" -Protocol Tcp ` -Direction Inbound -Priority 1000 -SourceAddressPrefix * -SourcePortRange * ` -DestinationAddressPrefix * -DestinationPortRange 3389 -Access Allow #Rule to allow SQL Server connections on port 1433 $NsgRuleSQL = New-AzNetworkSecurityRuleConfig -Name "MSSQLRule" -Protocol Tcp ` -Direction Inbound -Priority 1001 -SourceAddressPrefix * -SourcePortRange * ` -DestinationAddressPrefix * -DestinationPortRange 1433 -Access Allow # Create the network security group $NsgName = $ResourceGroupName + "nsg" $Nsg = New-AzNetworkSecurityGroup -ResourceGroupName $ResourceGroupName ` -Location $Location -Name $NsgName ` -SecurityRules $NsgRuleRDP,$NsgRuleSQL

3. Create the network interface.

$InterfaceName = $ResourceGroupName + "int"
$Interface = New-AzNetworkInterface -Name $InterfaceName `
   -ResourceGroupName $ResourceGroupName -Location $Location `
   -SubnetId $VNet.Subnets[0].Id -PublicIpAddressId $Pip.Id `
   -NetworkSecurityGroupId $Nsg.Id

Create the SQL VM

1. To sign in to the VM, define your credentials. The username is "azureadmin". Change <password> before running the command.

# Define a credential object
$SecurePassword = ConvertTo-SecureString '<password>' `
   -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential ("azureadmin", $securePassword)

2. Create a virtual machine configuration object and then create the VM. 

# Create a virtual machine configuration
$VMName = $ResourceName + "VM"
$VMConfig = New-AzVMConfig -VMName $VMName -VMSize Standard_V2 |
   Set-AzVMOperatingSystem -Windows -ComputerName $VMName -Credential $ -ProvisionVMAgent -EnableAutoUpdate |
   Set-AzVMSourceImage -PublisherName "MicrosoftSQLServer" -Offer "SQL2017-WS2016" -Skus "SQLDEV" -Version "latest" |
   Add-AzVMNetworkInterface -Id $Interface.Id
# Create the VM
New-AzVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $VMConfig

Register with SQL VM RP

You must register with the SQL IaaS Agent extension to get portal integration and SQL VM features. You need to register with the extension in full mode to get full functionality. Otherwise, register in lightweight mode.

Remote desktop into the VM

1. Use the following command to retrieve the public IP address for the new VM.

Get-AzPublicIpAddress -ResourceGroupName $ResourceGroupName | Select IpAddress

2. Pass the returned IP address as a command-line parameter to mstsc to start a Remote Desktop session into the new VM.

mstsc /v:<publicIpAddress>

3. Enter credentials for a different account when prompted for credentials. Enter the username with a preceding backslash and the password you set in this quickstart.

Connect to SQL Server

  1. Launch SQL Server Management Studio 2017 from the start menu after signing in to the Remote Desktop session
  2. Keep the defaults in the Connect to Server dialog box. Select Connect.

You will be connected to SQL Server locally. You should configure connectivity from the Azure portal.

Clean up resources

You can avoid unnecessary charges by stopping it when not in use if you don't need the VM to run continuously.

Stop-AzVM -Name $VMName -ResourceGroupName $ResourceGroupName

If you want to permanently delete all resources associated with the virtual machine use the Remove-AzResourceGroup command.

Frequently Asked Questions

Can I install SQL Server on Azure VM?

Yes, provided there is a default instance on the VM.

Can I use my own SQL license in Azure?

Azure Hybrid Benefit allows you to use your own SQL Server license with a VM that's running SQL Server.

Is Azure SQL Database same as SQL Server?

Since Azure SQL is based on SQL Server, they share many similarities but they are not the same.

Conclusion

In this article, we have extensively discussed how to create SQL Server on a Windows virtual machine in the Azure portal and with Powershell. Having gone through this article, I am sure you must be excited to read similar blogs. Coding Ninjas has got you covered. Here are some similar blogs to redirect:  We hope this blog has helped you enhance your knowledge, and if you wish to learn more, check out our Coding Ninjas Blog site and visit our Library. You can also consider our Online Coding Courses such as the Machine Learning Course to give your career an edge over others.

Do upvote our blog to help other ninjas grow.

Happy Learning!

Live masterclass