Azure SQL Database 受控執行個體的管理 API 參考Managed API reference for Azure SQL Database Managed Instances

您可以使用 Azure 入口網站、PowerShell、Azure CLI、REST API 和 Transact-SQL,來建立及管理 Azure SQL Database 受控執行個體。You can create and manage Azure SQL Database Managed Instances using the Azure portal, PowerShell, Azure CLI, REST API, and Transact-SQL. 在本文中,您可以概略了解建立和設定受控執行個體的函式和 API。In this article, you can find an overview of functions and API that you can use to create and configure Managed Instance.

Azure 入口網站:建立受控執行個體Azure portal: Create a managed instance

如需示範如何建立 Azure SQL Database 受控執行個體的快速入門,請參閱快速入門:建立 Azure SQL Database 受控執行個體For a quickstart showing you how to create an Azure SQL Database Managed Instance, see Quickstart: Create an Azure SQL Database Managed Instance.

PowerShell:建立和管理受控執行個體PowerShell: Create and manage 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.

重要

Azure SQL Database,仍然支援 PowerShell 的 Azure Resource Manager 模組,但所有未來的開發是 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. 這些指令程式,請參閱 < 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 指令程式。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 Azure PowerShell module.

CmdletCmdlet 描述Description
New-AzSqlInstanceNew-AzSqlInstance 建立 Azure SQL Database 受控執行個體Creates an Azure SQL Database Managed Instance
Get-AzSqlInstanceGet-AzSqlInstance 傳回 Azure SQL Database 受控執行個體的資訊Returns information about Azure SQL Managed Instance
Set-AzSqlInstanceSet-AzSqlInstance 設定 Azure SQL Database 受控執行個體的屬性Sets properties for an Azure SQL Database Managed Instance
Remove-AzSqlInstanceRemove-AzSqlInstance 移除 Azure SQL Database 受控執行個體Removes an Azure SQL Managed Database Instance
New-AzSqlInstanceDatabaseNew-AzSqlInstanceDatabase 建立 Azure SQL Database 受控執行個體資料庫Creates an Azure SQL Database Managed Instance database
Get-AzSqlInstanceDatabaseGet-AzSqlInstanceDatabase 傳回 Azure SQL Database 受控執行個體的資料庫資訊Returns information about Azure SQL Managed Instance database
Remove-AzSqlInstanceDatabaseRemove-AzSqlInstanceDatabase 移除 Azure SQL Database 受控執行個體資料庫Removes an Azure SQL Managed Database Instance database
Restore-AzSqlInstanceDatabaseRestore-AzSqlInstanceDatabase 還原 Azure SQL Database 受控執行個體資料庫Restores an Azure SQL Managed Database Instance database

Azure CLI:建立和管理受控執行個體Azure CLI: Create and manage managed instances

若要使用 Azure CLI 建立和管理受控執行個體,請使用下列 Azure CLI SQL 受控執行個體命令。To create and manage managed instances with Azure CLI, use the following Azure CLI SQL Managed Instance commands. 使用 Cloud Shell 在您的瀏覽器中執行 CLI,或在 macOS、Linux 或 Windows 中安裝Use the Cloud Shell to run the CLI in your browser, or 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 取得受控執行個體的詳細資料Get 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 還原受控資料庫Restore a managed database
az sql midb deleteaz sql midb delete 移除受控資料庫Removes a managed database

Transact-SQL:建立和管理執行個體資料庫Transact-SQL: Create and manage instance databases

若要在建立受控執行個體後建立與管理執行個體資料庫,請使用下列 T-SQL 命令。To create and manage instance database after the Managed Instance is created, use the following T-SQL commands. 您可以使用 Azure 入口網站、SQL Server Management StudioAzure Data Studio 發出這些命令。You can issue these commands using the Azure portal, SQL Server Management Studio, Azure Data Studio. Visual Studio Code,或可以連接到 Azure SQL Database 伺服器並傳遞 TRANSACT-SQL 命令的其他任何程式。Visual Studio Code, or any other program that can connect to an Azure SQL Database server and pass Transact-SQL commands.

提示

如需快速入門顯示必須如何在 Microsoft Windows 上使用 SQL Server Management Studio 設定並連線到受控執行個體,請參閱快速入門:設定 Azure VM 以連線到 Azure SQL Database 受控執行個體快速入門:設定從內部部署連線至 Azure SQL Database 受控執行個體的點對站連線For quickstarts showing you have to configure and connect to a Managed Instance using SQL Server Management Studio on Microsoft Windows, see Quickstart: Configure Azure VM to connect to an Azure SQL Database Managed Instance and Quickstart: Configure a point-to-site connection to an Azure SQL Database Managed Instance from on-premises.

重要

您無法使用 Transact-SQL 建立或刪除受控執行個體。You cannot create or delete a Managed Instance using Transact-SQL.

命令Command 描述Description
CREATE DATABASECREATE DATABASE 建立新的受控執行個體資料庫。Creates a new Managed Instance database. 您必須連線到 master 資料庫才能建立新的資料庫。You must be connected to the master database to create a new database.
ALTER DATABASEALTER DATABASE 修改 Azure SQL Database 受控執行個體資料庫。Modifies an Azure SQL Managed Instance database.

REST API:建立和管理受控執行個體REST API: Create and manage managed instances

若要建立和管理受控執行個體,請使用下列 REST API 要求。To create and manage Managed Instances, use these REST API requests.

命令Command 描述Description
Managed Instances - Create Or UpdateManaged Instances - Create Or Update 建立或更新受控執行個體。Creates or updates a Managed Instance.
Managed Instances - DeleteManaged Instances - Delete 刪除受控執行個體。Deletes a Managed Instance.
Managed Instances - GetManaged Instances - Get 取得受控執行個體。Gets a Managed Instance.
Managed Instances - ListManaged Instances - List 傳回訂用帳戶之中受控執行個體的清單。Returns a list of Managed Instances in a subscription.
Managed Instances - List By Resource GroupManaged Instances - List By Resource Group 傳回資源群組之中受控執行個體的清單。Returns a list of Managed Instances in a resource group.
Managed Instances - UpdateManaged Instances - Update 更新受控執行個體。Updates a Managed Instance.

後續步驟Next steps