Create Azure SQL Managed Instance

In this comprehensive article, I’ll walk you through everything you need to know how to create Azure SQL managed instance, covering multiple methods and best practices to ensure a smooth deployment.

Create Azure SQL Managed Instance

Prerequisites

Before you start, ensure you have the following:

  • An active Azure subscription.
  • Necessary Azure permissions (Owner or Contributor role on the subscription or resource group).
  • An existing or planned Azure Virtual Network (VNet) configured with subnet(s) that meet Azure SQL MI requirements.
  • Basic knowledge of Azure Portal, PowerShell, or Azure CLI.

Different Methods

There are three primary ways to create an Azure SQL Managed Instance:

  1. Using the Azure Portal
  2. Using Azure PowerShell
  3. Using Azure CLI

Each method suits different user preferences and automation needs. I’ll guide you through all three.

Approach 1: Using the Azure Portal

To create Azure SQL Managed Instance, follow the steps below

1. Log in to the Azure portal (https://portal.azure.com/)

2. Search for the Azure SQL and select the Azure SQL option.

create sql managed instance

3. Click on the + Add button on the Azure SQL window.

Create SQL managed instance in azure

4. On the select SQL deployment option window, click the Create button from the SQL managed instances section.

sql managed instance

5. The Create Azure SQL Database Managed Instance window will open now. Fill out the mandatory information required on the Basics tab.

  • Subscription: Choose your correct subscription.
  • Resource group: You can choose an existing resource group or create a new one by clicking the “Create new” link.
  • Managed Instance name: Provide a name for the managed instance.
  • Region: Select the region you belong to.
  • Compute + storage: Select the default or configure a new one by clicking on the Configure Manage Instance link per your business needs.
  • Managed Instance admin login: Provide a username for the login.
  • Password: Provide a password as per the password policy
  • Confirm Password: Confirm the same Password.

Click the Next: Networking > button to go to the Networking tab.

how to create azure sql managed instance
azure sql mi

6. On the Networking tab, fill in the optional options as per the business need.

  • Virtual network: Select a valid virtual network, create a new one, or select the default one.
  • Connection type: You can choose a proxy(Default) option or a redirect connection type.
  • Public endpoint (data): Select the Enable option here.

Click on the Next: Additional settings > button to navigate to the Additional settings tab.

azure sql database managed instance
azure sql managed instance

7. Fill in the optional options per the business need on the Additional Settings tab.

  • Collation: Select the desired collation for your managed instance. You can click on ‘Find a Collation’ to choose a new one, or you can keep the default one as well.
  • Time zone: Select the time zone you belong to.
  • Use as failover secondary: Choose Yes for this option.

Now click the Next: Tags button to go to the Tags tab.

azure sql managed instance analysis services

8. On the tags tab, you can keep the default option. Click on the Next: Review + Create > button.

azure sql managed instance monitoring

9. Finally, click on the Create button.

How to create SQL managed instance in azure

As you can see, the deployment has been successful.

create SQL managed instance in azure

Now, to verify if the Azure SQL-managed instance has been created, you can open your resource group as shown in the screenshot below.

azure managed database

Approach 2: Using Azure PowerShell

Step 1: Open PowerShell and Log in

Connect-AzAccount

Step 2: Define Variables

$resourceGroup = "myresgrp"
$location = "East US"
$miName = "azurelessonsmi"
$vnetName = "azurelessons-vnet"
$subnetName = "azurelessons-subnet"
$adminLogin = "sqladmin"
$adminPassword = ConvertTo-SecureString "Password@1234" -AsPlainText -Force

Step 3: Create Resource Group (if needed)

New-AzResourceGroup -Name $resourceGroup -Location $location

Step 4: Create Virtual Network and Subnet

$vnet = New-AzVirtualNetwork -ResourceGroupName $resourceGroup -Location $location -Name $vnetName -AddressPrefix "10.0.0.0/16"
Add-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix "10.0.1.0/24" -VirtualNetwork $vnet
$vnet | Set-AzVirtualNetwork

Step 5: Create Managed Instance

New-AzSqlManagedInstance -Name $miName `
    -ResourceGroupName $resourceGroup `
    -Location $location `
    -SubnetId $vnet.Subnets[0].Id `
    -AdministratorLogin $adminLogin `
    -AdministratorLoginPassword $adminPassword `
    -SkuName "GP_Gen5_4" `
    -StorageSizeInGB 512

After executing the above PowerShell script, the Azure SQL managed instance was created successfully, as shown in the screenshot below.

how to create azure sql managed instance

Approach 3: Using Azure CLI

Step 1: Log in to Azure CLI

az login

Step 2: Set Variables

RESOURCE_GROUP="azurelessons-RG"
LOCATION="eastus"
MI_NAME="azurelessonsmi"
VNET_NAME="azurelessons-vnet"
SUBNET_NAME="azurelessons-subnet"
ADMIN_USER="sqladmin"
ADMIN_PASS="Password@1234!"

Step 3: Create Resource Group

az group create --name $RESOURCE_GROUP --location $LOCATION

Step 4: Create Virtual Network and Subnet

az network vnet create --resource-group $RESOURCE_GROUP --name $VNET_NAME --address-prefix 10.0.0.0/16
az network vnet subnet create --resource-group $RESOURCE_GROUP --vnet-name $VNET_NAME --name $SUBNET_NAME --address-prefix 10.0.1.0/24 --delegations Microsoft.Sql/managedInstances

Step 5: Create Managed Instance

az sql mi create --name $MI_NAME --resource-group $RESOURCE_GROUP --location $LOCATION --admin-user $ADMIN_USER --admin-password $ADMIN_PASS --vnet-name $VNET_NAME --subnet $SUBNET_NAME --sku-name GP_Gen5_4 --storage 512

Conclusion

In this Azure tutorial, we discussed

  • How to create Azure SQL managed instance

Whether you prefer the Azure Portal, PowerShell, or Azure CLI, the process is simple and straightforward as mentioned in this article.

I hope you have enjoyed this article !!!

You may like following Azure tutorials

Azure Virtual Machine

DOWNLOAD FREE AZURE VIRTUAL MACHINE PDF

Download our free 25+ page Azure Virtual Machine guide and master cloud deployment today!