Azure SQL 托管实例的托管 API 参考Managed API reference for Azure SQL Managed Instance

适用于:是Azure SQL 托管实例 APPLIES TO: yesAzure SQL Managed Instance

可以使用 Azure 门户、PowerShell、Azure CLI、REST API 和 Transact-SQL 创建和配置 Azure SQL 托管实例的托管实例。You can create and configure managed instances of Azure SQL Managed Instance using the Azure portal, PowerShell, Azure CLI, REST API, and Transact-SQL. 在本文中,你可以找到可用于创建和配置托管实例的函数和 API 的概述。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 门户:创建托管实例Azure portal: Create a managed instance

有关演示如何创建托管实例的快速入门,请参阅快速入门:创建托管实例For a quickstart showing you how to create a managed instance, see Quickstart: Create a managed instance.

PowerShell:创建和配置托管实例PowerShell: Create and configure managed instances

备注

本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

重要

PowerShell Azure 资源管理器模块仍受 Azure SQL 数据库的支持,但所有未来的开发都是针对 Az.Sql 模块的。The PowerShell Azure Resource Manager module is still supported by Azure SQL Database, but all future development is for the Az.Sql module. 若要了解这些 cmdlet,请参阅 AzureRM.SqlFor these cmdlets, see AzureRM.Sql. Az 模块和 AzureRM 模块中的命令参数大体上是相同的。The arguments for the commands in the Az module and in the AzureRM modules are substantially identical.

若要使用 Azure PowerShell 创建并管理托管实例,请使用以下 PowerShell cmdlet。To create and manage managed instances with Azure PowerShell, use the following PowerShell cmdlets. 如果需要安装或升级 PowerShell,请参阅安装 Azure PowerShell 模块If you need to install or upgrade PowerShell, see Install the Azure PowerShell module.

提示

有关 PowerShell 示例脚本,请参阅快速入门脚本:使用 PowerShell 库创建托管实例For PowerShell example scripts, see Quickstart script: Create a managed instance using a PowerShell library.

CmdletCmdlet 说明Description
New-AzSqlInstanceNew-AzSqlInstance 创建托管实例。Creates a managed instance.
Get-AzSqlInstanceGet-AzSqlInstance 返回有关托管实例的详细信息。Returns information about a managed instance.
Set-AzSqlInstanceSet-AzSqlInstance 设置托管实例的属性。Sets properties for a managed instance.
Remove-AzSqlInstanceRemove-AzSqlInstance 删除托管实例。Removes a managed instance.
New-AzSqlInstanceDatabaseNew-AzSqlInstanceDatabase 创建 SQL 托管实例数据库。Creates a SQL Managed Instance database.
Get-AzSqlInstanceDatabaseGet-AzSqlInstanceDatabase 返回有关 SQL 托管实例数据库的信息。Returns information about a SQL Managed Instance database.
Remove-AzSqlInstanceDatabaseRemove-AzSqlInstanceDatabase 删除 SQL 托管实例数据库。Removes a SQL Managed Instance database.
Restore-AzSqlInstanceDatabaseRestore-AzSqlInstanceDatabase 还原 SQL 托管实例数据库。Restores a SQL Managed Instance database.

Azure CLI:创建和配置托管实例Azure CLI: Create and configure managed instances

要使用 Azure CLI 创建和配置托管实例,请使用以下用于 SQL 托管实例的 Azure CLI 命令To create and configure managed instances with Azure CLI, use the following Azure CLI commands for SQL Managed Instance commands. 可以在 macOS、Linux 或 Windows 上安装它。You can install it on macOS, Linux, or Windows.

提示

有关 Azure CLI 快速入门,请参阅使用 Azure CLI 处理 SQL 托管实例For an Azure CLI quickstart, see Working with SQL Managed Instance using Azure CLI.

CmdletCmdlet 说明Description
az sql mi createaz sql mi create 创建托管实例。Creates a managed instance.
az sql mi listaz sql mi list 列出可用的托管实例。Lists available managed instances.
az sql mi showaz sql mi show 获取托管实例的详细信息。Gets the details for a managed instance.
az sql mi updateaz sql mi update 更新托管实例。Updates a managed instance.
az sql mi deleteaz sql mi delete 删除托管实例。Removes a managed instance.
az sql midb createaz sql midb create 创建托管数据库。Creates a managed database.
az sql midb listaz sql midb list 列出可用的托管数据库。Lists available managed databases.
az sql midb restoreaz sql midb restore 还原托管数据库。Restores a managed database.
az sql midb deleteaz sql midb delete 删除托管数据库。Removes a managed database.

Transact-SQL:创建和配置实例数据库Transact-SQL: Create and configure instance databases

要在创建托管实例后创建和配置实例数据库,请使用以下 T-SQL 命令。To create and configure instance databases after the managed instance is created, use the following T-SQL commands. 可以使用 Azure 门户、SQL Server Management StudioAzure Data StudioVisual Studio Code 或可以连接到服务器并传递 Transact-SQL 命令的其他任何程序来发出这些命令。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.

提示

有关介绍如何使用 Microsoft Windows 上的 SQL Server Management Studio 配置和连接到托管实例的快速入门,请参阅快速入门:配置 Azure VM 以连接到 Azure SQL 托管实例快速入门:配置从本地到 Azure SQL 托管实例的点到站点连接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.

重要

无法使用 Transact-SQL 创建或删除托管实例。You cannot create or delete a managed instance using Transact-SQL.

命令Command 说明Description
CREATE DATABASECREATE DATABASE 在 SQL 托管实例中创建新的实例数据库。Creates a new instance database in SQL Managed Instance. 必须连接到 master 数据库才能新建数据库。You must be connected to the master database to create a new database.
ALTER DATABASEALTER DATABASE 修改 SQL 托管实例中的实例数据库。Modifies an instance database in SQL Managed Instance.

REST API:创建和配置托管实例REST API: Create and configure managed instances

要创建和配置托管实例,请使用以下 REST API 请求。To create and configure managed instances, use these REST API requests.

命令Command 说明Description
托管实例 - 创建或更新Managed Instances - Create Or Update 创建或更新托管实例。Creates or updates a managed instance.
托管实例 - 删除Managed Instances - Delete 删除托管实例。Deletes a managed instance.
托管实例 - 获取Managed Instances - Get 获取托管实例。Gets a managed instance.
托管实例 - 列表Managed Instances - List 返回订阅中的托管实例列表。Returns a list of managed instances in a subscription.
托管实例 - 按资源组列出Managed Instances - List By Resource Group 返回资源组中的托管实例列表。Returns a list of managed instances in a resource group.
托管实例 - 更新Managed Instances - Update 更新托管实例。Updates a managed instance.

后续步骤Next steps