|
| 1 | +--- |
| 2 | +title: Synchronize virtual network DNS servers setting on SQL Managed Instance virtual cluster |
| 3 | +description: Learn how synchronize virtual network DNS servers setting on SQL Managed Instance virtual cluster. |
| 4 | +services: sql-database |
| 5 | +ms.service: sql-managed-instance |
| 6 | +author: srdan-bozovic-msft |
| 7 | +ms.author: srbozovi |
| 8 | +ms.date: 01/17/2021 |
| 9 | +--- |
| 10 | + |
| 11 | +# Synchronize virtual network DNS servers setting on SQL Managed Instance virtual cluster |
| 12 | +[!INCLUDE[appliesto-sqlmi](../includes/appliesto-sqlmi.md)] |
| 13 | + |
| 14 | +This article explains when and how to synchronize virtual network DNS servers setting on SQL Managed Instance virtual cluster. |
| 15 | + |
| 16 | +## When do you need to synchronize DNS server settings on SQL Managed Instance virtual cluster |
| 17 | + |
| 18 | +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. In this case, you need to configure a custom DNS inside Azure. See [Configure a custom DNS for Azure SQL Managed Instance](custom-dns-configure.md) for details. |
| 19 | + |
| 20 | +If this change is implemented after [virtual cluster](connectivity-architecture-overview.md#virtual-cluster-connectivity-architecture) hosting Managed Instance is created you'll need to synchronize DNS servers setting on the virtual cluster with the virtual network configuration. |
| 21 | + |
| 22 | +> [!IMPORTANT] |
| 23 | +> Synchronizing DNS servers setting will affect all of the Managed Instances hosted in the virtual cluster. |
| 24 | +
|
| 25 | +## How to synchronize DNS servers setting on SQL Managed Instance virtual cluster |
| 26 | + |
| 27 | +### Azure RBAC permissions required |
| 28 | + |
| 29 | +User synchronizing DNS server configuration will need to have one of the following Azure roles: |
| 30 | + |
| 31 | +- Subscription Owner role, or |
| 32 | +- Managed Instance Contributor role, or |
| 33 | +- Custom role with the following permission: |
| 34 | + - `Microsoft.Sql/virtualClusters/updateManagedInstanceDnsServers/action` |
| 35 | + |
| 36 | +### Using PowerShell |
| 37 | + |
| 38 | +Get virtual network where DNS servers setting has been updated. |
| 39 | + |
| 40 | +```powershell |
| 41 | +$ResourceGroup = 'enter resource group of virtual network' |
| 42 | +$VirtualNetworkName = 'enter virtual network name' |
| 43 | +$virtualNetwork = Get-AzVirtualNetwork -$ResourceGroup $ResourceGrou -Name $VirtualNetworkName |
| 44 | +``` |
| 45 | +Use PowerShell command [Invoke-AzResourceAction](/powershell/module/az.resources/invoke-azresourceaction) to synchronize DNS servers configuration for all the virtual clusters in the subnet. |
| 46 | + |
| 47 | +```powershell |
| 48 | +Get-AzSqlVirtualCluster ` |
| 49 | + | where SubnetId -match $virtualNetwork.Id ` |
| 50 | + | select Id ` |
| 51 | + | Invoke-AzResourceAction -Action updateManagedInstanceDnsServers -Force |
| 52 | +``` |
| 53 | +## Next steps |
| 54 | + |
| 55 | +- Learn more about configuring a custom DNS [Configure a custom DNS for Azure SQL Managed Instance](custom-dns-configure.md). |
| 56 | +- For an overview, see [What is Azure SQL Managed Instance?](sql-managed-instance-paas-overview.md). |
0 commit comments