Skip to content

Latest commit

 

History

History
66 lines (48 loc) · 4.15 KB

create-configure-managed-instance-powershell.md

File metadata and controls

66 lines (48 loc) · 4.15 KB
title titleSuffix description author ms.author ms.reviewer ms.date ms.service ms.subservice ms.topic ms.custom ms.devlang
PowerShell: Create a managed instance
Azure SQL Managed Instance
This article provides an Azure PowerShell example script to create a managed instance.
urosmil
urmilano
mathoma
02/26/2024
azure-sql-managed-instance
deployment-configuration
sample
devx-track-azurepowershell
powershell

Use PowerShell to create a managed instance

[!INCLUDEappliesto-sqldb]

This PowerShell script example creates a managed instance in a dedicated subnet within a new virtual network. It also configures a route table and a network security group for the virtual network. Once the script has been successfully run, the managed instance can be accessed from within the virtual network or from an on-premises environment. See Configure Azure VM to connect to Azure SQL Database Managed Instance and Configure a point-to-site connection to Azure SQL Managed Instance from on-premises.

Important

For limitations, see supported regions and supported subscription types.

[!INCLUDE cloud-shell-try-it.md]

If you choose to install and use PowerShell locally, this tutorial requires Azure PowerShell 1.4.0 or later. If you need to upgrade, see Install Azure PowerShell module. If you are running PowerShell locally, you also need to run Connect-AzAccount to create a connection with Azure.

Sample script

:::code language="powershell" source="~/../azure_powershell_scripts/azure-sql/managed-instance/create-and-configure-managed-instance.ps1":::

Clean up deployment

Use the following command to remove the resource group and all resources associated with it.

Remove-AzResourceGroup -ResourceGroupName $resourcegroupname

Script explanation

This script uses some of the following commands. For more information about used and other commands in the table below, click on the links to command specific documentation.

Command Notes
New-AzResourceGroup Creates a resource group in which all resources are stored.
New-AzVirtualNetwork Creates a virtual network.
Add-AzVirtualNetworkSubnetConfig Adds a subnet configuration to a virtual network.
Get-AzVirtualNetwork Gets a virtual network in a resource group.
Set-AzVirtualNetwork Sets the goal state for a virtual network.
Get-AzVirtualNetworkSubnetConfig Gets a subnet in a virtual network.
Set-AzVirtualNetworkSubnetConfig Configures the goal state for a subnet configuration in a virtual network.
New-AzRouteTable Creates a route table.
Get-AzRouteTable Gets route tables.
Set-AzRouteTable Sets the goal state for a route table.
New-AzSqlInstance Creates a managed instance.
New-AzSqlInstanceDatabase Creates a database for your managed instance.
Remove-AzResourceGroup Deletes a resource group, including all nested resources.

Next steps

For more information on Azure PowerShell, see Azure PowerShell documentation.

Additional PowerShell script samples for Azure SQL Managed Instance can be found in Azure SQL Managed Instance PowerShell scripts.