在 SQL 托管实例虚拟群集上同步虚拟网络 DNS 服务器设置Synchronize virtual network DNS servers setting on SQL Managed Instance virtual cluster

适用于: Azure SQL 托管实例

本文介绍何时以及如何在 SQL 托管实例虚拟群集上同步虚拟网络 DNS 服务器设置。This article explains when and how to synchronize virtual network DNS servers setting on SQL Managed Instance virtual cluster.

何时同步 DNS 设置When to synchronize the DNS setting

有几个方案(如数据库邮件,将服务器链接到云或混合环境中的其他 SQL Server 实例)需要从 SQL 托管实例解析专用主机名。There are a few scenarios (for example, db mail, linked servers to other SQL Server instances in your cloud or hybrid environment) that require private host names to be resolved from SQL Managed Instance. 在这种情况下,需要在 Azure 中配置自定义 DNS。In this case, you need to configure a custom DNS inside Azure. 有关详细信息,请参阅为 Azure SQL 托管实例配置自定义 DNSSee Configure a custom DNS for Azure SQL Managed Instance for details.

如果在创建托管托管实例的虚拟群集之后实施此更改,则需要将虚拟群集上的 DNS 服务器设置与虚拟网络配置同步。If this change is implemented after virtual cluster hosting Managed Instance is created you'll need to synchronize DNS servers setting on the virtual cluster with the virtual network configuration.

重要

同步 DNS 服务器设置将影响虚拟群集中托管的所有托管实例。Synchronizing DNS servers setting will affect all of the Managed Instances hosted in the virtual cluster.

如何同步 DNS 设置How to synchronize the DNS setting

所需的 Azure RBAC 权限Azure RBAC permissions required

用户同步 DNS 服务器配置时需要以下 Azure 角色之一:User synchronizing DNS server configuration will need to have one of the following Azure roles:

  • “订阅所有者”角色或Subscription Owner role, or
  • “托管实例参与者”角色或Managed Instance Contributor role, or
  • 具有以下权限的自定义角色:Custom role with the following permission:
    • Microsoft.Sql/virtualClusters/updateManagedInstanceDnsServers/action

使用 Azure PowerShellUse Azure PowerShell

获取已更新 DNS 服务器设置的虚拟网络。Get virtual network where DNS servers setting has been updated.

$ResourceGroup = 'enter resource group of virtual network'
$VirtualNetworkName = 'enter virtual network name'
$virtualNetwork = Get-AzVirtualNetwork -ResourceGroup $ResourceGroup -Name $VirtualNetworkName

使用 PowerShell 命令 Invoke-AzResourceAction 为子网中的所有虚拟群集同步 DNS 服务器配置。Use PowerShell command Invoke-AzResourceAction to synchronize DNS servers configuration for all the virtual clusters in the subnet.

Get-AzSqlVirtualCluster `
    | where SubnetId -match $virtualNetwork.Id `
    | select Id `
    | Invoke-AzResourceAction -Action updateManagedInstanceDnsServers -Force

使用 Azure CLIUse the Azure CLI

获取已更新 DNS 服务器设置的虚拟网络。Get virtual network where DNS servers setting has been updated.

$resourceGroup="auto-failover-group"
$virtualNetworkName="vnet-fog-chinaeast"
$virtualNetwork=$(az network vnet show -g $resourceGroup -n $virtualNetworkName --query "id" -otsv)

使用 Azure CLI 命令 az resource invoke-action 为子网中的所有虚拟群集同步 DNS 服务器配置。Use Azure CLI command az resource invoke-action to synchronize DNS servers configuration for all the virtual clusters in the subnet.

az sql virtual-cluster list --query "[? contains(subnetId,'$virtualNetwork')].id" -o tsv \
    | az resource invoke-action --action updateManagedInstanceDnsServers --ids @-

后续步骤Next steps