为 Azure SQL 托管实例配置现有虚拟网络Configure an existing virtual network for Azure SQL Managed Instance

适用于: Azure SQL 托管实例

Azure SQL 托管实例必须仅部署在专用于托管实例的 Azure 虚拟网络和子网中。Azure SQL Managed Instance must be deployed within an Azure virtual network and the subnet dedicated for managed instances only. 如果现有虚拟网络和子网是根据 SQL 托管实例虚拟网络要求配置的,则可以使用现有虚拟网络和子网。You can use the existing virtual network and subnet if they're configured according to the SQL Managed Instance virtual network requirements.

如果存在以下情况,可以使用本文中所述的脚本来验证和修改网络:If one of the following cases applies to you, you can validate and modify your network by using the script explained in this article:

  • 仍未配置某个新子网。You have a new subnet that's still not configured.
  • 不确定该子网是否符合要求You're not sure that the subnet is aligned with the requirements.
  • 进行更改后想要检查子网是否仍符合网络要求You want to check that the subnet still complies with the network requirements after you made changes.

备注

只能在通过 Azure 资源管理器部署模型创建的虚拟网络中创建托管实例。You can create a managed instance only in virtual networks created through the Azure Resource Manager deployment model. 不支持通过经典部署模型创建的 Azure 虚拟网络。Azure virtual networks created through the classic deployment model are not supported. 根据确定 SQL 托管实例的子网大小一文中的指导计算子网大小。Calculate subnet size by following the guidelines in the Determine the size of subnet for SQL Managed Instance article. 在子网中部署资源后,无法调整子网大小。You can't resize the subnet after you deploy the resources inside.

创建托管实例后,不支持将实例或 VNet 移到另一个资源组或订阅。After the managed instance is created, moving the instance or VNet to another resource group or subscription is not supported.

验证并修改现有虚拟网络Validate and modify an existing virtual network

如果希望在现有子网内创建托管实例,建议使用以下 PowerShell 脚本来准备子网:If you want to create a managed instance inside an existing subnet, we recommend the following PowerShell script to prepare the subnet:

$scriptUrlBase = 'https://raw.githubusercontent.com/Microsoft/sql-server-samples/master/samples/manage/azure-sql-db-managed-instance/delegate-subnet'

$parameters = @{
    subscriptionId = '<subscriptionId>'
    resourceGroupName = '<resourceGroupName>'
    virtualNetworkName = '<virtualNetworkName>'
    subnetName = '<subnetName>'
    }

Invoke-Command -ScriptBlock ([Scriptblock]::Create((iwr ($scriptUrlBase+'/delegateSubnet.ps1?t='+ [DateTime]::Now.Ticks)).Content)) -ArgumentList $parameters

该脚本通过三个步骤来准备子网:The script prepares the subnet in three steps:

  1. 验证:根据 SQL 托管实例的网络要求验证所选虚拟网络和子网。Validate: It validates the selected virtual network and subnet for SQL Managed Instance networking requirements.
  2. 确认:向用户显示为 SQL 托管实例部署准备子网而需要执行的一组更改。Confirm: It shows the user a set of changes that need to be made to prepare the subnet for SQL Managed Instance deployment. 同时请求用户同意。It also asks for consent.
  3. 准备:正确配置虚拟网络和子网。Prepare: It properly configures the virtual network and subnet.

后续步骤Next steps