Managed API reference for Azure SQL Managed Instance

Applies to: Azure SQL Managed Instance

You can create and configure managed instances of Azure SQL Managed Instance using the Azure portal, PowerShell, Azure CLI, REST API, and Transact-SQL. In this article, you can find an overview of the functions and the API that you can use to create and configure managed instances.

Azure portal: Create a managed instance

For a quickstart showing you how to create a managed instance, see Quickstart: Create a managed instance.

PowerShell: Create and configure managed instances

Note

This article uses the Azure Az PowerShell module, which is the recommended PowerShell module for interacting with Azure. To get started with the Az PowerShell module, see Install Azure PowerShell. To learn how to migrate to the Az PowerShell module, see Migrate Azure PowerShell from AzureRM to Az.

Important

The PowerShell Azure Resource Manager module is still supported by Azure SQL Database, but all future development is for the Az.Sql module. For these cmdlets, see AzureRM.Sql. The arguments for the commands in the Az module and in the AzureRM modules are substantially identical.

To create and manage managed instances with Azure PowerShell, use the following PowerShell cmdlets. If you need to install or upgrade PowerShell, see Install the Azure PowerShell module.

Cmdlet Description
New-AzSqlInstance Creates a managed instance.
Get-AzSqlInstance Returns information about a managed instance.
Set-AzSqlInstance Sets properties for a managed instance.
Remove-AzSqlInstance Removes a managed instance.
Get-AzSqlInstanceOperation Gets a list of management operations performed on the managed instance or specific operation.
Stop-AzSqlInstanceOperation Cancels the specific management operation performed on the managed instance.
New-AzSqlInstanceDatabase Creates a SQL Managed Instance database.
Get-AzSqlInstanceDatabase Returns information about a SQL Managed Instance database.
Remove-AzSqlInstanceDatabase Removes a SQL Managed Instance database.
Restore-AzSqlInstanceDatabase Restores a SQL Managed Instance database.

Azure CLI: Create and configure managed instances

To create and configure managed instances with Azure CLI, use the following Azure CLI commands for SQL Managed Instance. Use Azure Cloud Shell to run Azure CLI in your browser, or install it on macOS, Linux, or Windows.

Tip

For an Azure CLI quickstart, see Working with SQL Managed Instance using Azure CLI.

Cmdlet Description
az sql mi create Creates a managed instance.
az sql mi list Lists available managed instances.
az sql mi show Gets the details for a managed instance.
az sql mi update Updates a managed instance.
az sql mi delete Removes a managed instance.
az sql mi op list Gets a list of management operations performed on the managed instance.
az sql mi op show Gets the specific management operation performed on the managed instance.
az sql mi op cancel Cancels the specific management operation performed on the managed instance.
az sql midb create Creates a managed database.
az sql midb list Lists available managed databases.
az sql midb restore Restores a managed database.
az sql midb delete Removes a managed database.

Transact-SQL: Create and configure instance databases

To create and configure instance databases after the managed instance is created, use the following T-SQL commands. You can issue these commands using the Azure portal, SQL Server Management Studio, Azure Data Studio, Visual Studio Code, or any other program that can connect to a server and pass Transact-SQL commands.

Tip

For quickstarts showing you how to configure and connect to a managed instance using SQL Server Management Studio on Microsoft Windows, see Quickstart: Configure Azure VM to connect to Azure SQL Managed Instance and Quickstart: Configure a point-to-site connection to Azure SQL Managed Instance from on-premises.

Important

You cannot create or delete a managed instance using Transact-SQL.

Command Description
CREATE DATABASE Creates a new instance database in SQL Managed Instance. You must be connected to the master database to create a new database.
ALTER DATABASE Modifies an instance database in SQL Managed Instance.

REST API: Create and configure managed instances

To create and configure managed instances, use these REST API requests.

Command Description
SQL Managed Instance - Create Or Update Creates or updates a managed instance.
SQL Managed Instance - Delete Deletes a managed instance.
SQL Managed Instance - Get Gets a managed instance.
SQL Managed Instance - Stop Stops a managed instance.
SQL Managed Instance - Start Starts a managed instance
SQL Managed Instance - List Returns a list of managed instances in a subscription.
SQL Managed Instance - List By Resource Group Returns a list of managed instances in a resource group.
SQL Managed Instance - Update Updates a managed instance.
SQL Managed Instance operations - List By Managed Instance Gets a list of management operations performed on the managed instance.
SQL Managed Instance operations - Get Gets the specific management operation performed on the managed instance.
SQL Managed Instance operations - Cancel Cancels the specific management operation performed on the managed instance.
SQL Managed Instance - Start/stop schedule- Create Or Update Creates or updates a start and stop managed instance schedule.
SQL Managed Instance - Start/stop schedule - Get Gets an existing start and stop managed instance schedule.
SQL Managed Instance - Start/stop schedule - Delete Deletes an existing start and stop managed instance schedule.

Next steps