Skip to content

Commit edc19a0

Browse files
authored
Merge pull request #49980 from srdan-bozovic-msft/sql-mi-vnet-configuration
sql mi vnet configuration article update
2 parents a6f3025 + 9b45992 commit edc19a0

File tree

1 file changed

+45
-64
lines changed

1 file changed

+45
-64
lines changed

articles/sql-database/sql-database-managed-instance-vnet-configuration.md

Lines changed: 45 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -34,22 +34,40 @@ Plan how you deploy a Managed Instance in virtual network using your answers to
3434
## Requirements
3535

3636
For Managed Instance creation you need to dedicate a subnet inside the VNet that conforms to the following requirements:
37-
- **Be empty**: The subnet must not contain any other cloud service associated to it, and it must not be Gateway subnet. You won’t be able to create Managed Instance in subnet that contains resources other than managed instance or add other resources inside the subnet later.
38-
- **No NSG**: The subnet must not have a Network Security Group associated with it.
37+
- **Dedicated subnet**: The subnet must not contain any other cloud service associated to it, and it must not be Gateway subnet. You won’t be able to create Managed Instance in subnet that contains resources other than managed instance or add other resources inside the subnet later.
38+
- **No NSG**: The subnet must not have a Network Security Group associated with it.
3939
- **Have specific route table**: The subnet must have a User Route Table (UDR) with 0.0.0.0/0 Next Hop Internet as the only route assigned to it. For more information, see [Create the required route table and associate it](#create-the-required-route-table-and-associate-it)
4040
3. **Optional custom DNS**: If custom DNS is specified on the VNet, Azure's recursive resolvers IP address (such as 168.63.129.16) must be added to the list. For more information, see [Configuring Custom DNS](sql-database-managed-instance-custom-dns.md).
41-
4. **No Service endpoint**: The subnet must not have a Service endpoint (Storage or Sql) associated to it. Make sure that Service Endpoints option is Disabled when creating VNet.
42-
5. **Sufficient IP addresses**: The subnet must have minimum of 16 IP addresses. For more information, see [Determine the size of subnet for Managed Instances](#determine-the-size-of-subnet-for-managed-instances)
41+
4. **No Service endpoints**: The subnet must not have a Service endpoint associated to it. Make sure that Service endpoints option is Disabled when creating VNet.
42+
5. **Sufficient IP addresses**: The subnet must have the bare minimum of 16 IP addresses (recommended minimum is 32 IP addresses). For more information, see [Determine the size of subnet for Managed Instances](#determine-the-size-of-subnet-for-managed-instances)
4343

4444
> [!IMPORTANT]
4545
> You won’t be able to deploy new Managed Instance if the destination subnet is not compatible with all of the preceding requirements. The destination Vnet and the subnet must be kept in accordance with these Managed Instance requirements (before and after deployment), as any violation may cause instance to enter faulty state and become unavailable. Recovering from that state requires you to create new instance in a VNet with the compliant networking policies, recreate instance level data, and restore your databases. This introduces significant downtime for your applications.
4646
47+
With introduction of _Network Intent Policy_, you can add a Network security group (NSG) on a Managed Instance subnet after the Managed Instance is created.
48+
49+
You can now use an NSG to narrow down the IP ranges from which applications and users can query and manage the data by filtering network traffic that goes to port 1433.
50+
51+
> [!IMPORTANT]
52+
> When you are configuring the NSG rules that will restrain access to port 1433, you also need to insert the highest priority inbound rules displayed in the table below. Otherwise Network Intent Policy blocks the change as non compliant.
53+
54+
| NAME |PORT |PROTOCOL|SOURCE |DESTINATION|ACTION|
55+
|------------|----------------------------|--------|-----------------|-----------|------|
56+
|management |9000, 9003, 1438, 1440, 1452|Any |Any |Any |Allow |
57+
|mi_subnet |Any |Any |MI SUBNET |Any |Allow |
58+
|health_probe|Any |Any |AzureLoadBalancer|Any |Allow |
59+
60+
The routing experiance has also been improved so that in addition to the 0.0.0.0/0 next hop type Internet route, you can now add UDR to route traffic towards your on-premises private IP ranges through virtual network gateway or virtual network appliance (NVA).
61+
4762
## Determine the size of subnet for Managed Instances
4863

49-
When you create a Managed Instance, Azure allocates a number of virtual machines depending on the tier size you select during provisioning. Because these virtual machines are associated with your subnet, they require IP addresses. To ensure high availability during regular operations and service maintenance, Azure may allocate additional virtual machines. As a result, the number of required IP addresses in a subnet is larger than the number of Managed Instances in that subnet.
64+
When you create a Managed Instance, Azure allocates a number of virtual machines depending on the tier you selected during provisioning. Because these virtual machines are associated with your subnet, they require IP addresses. To ensure high availability during regular operations and service maintenance, Azure may allocate additional virtual machines. As a result, the number of required IP addresses in a subnet is larger than the number of Managed Instances in that subnet.
5065

5166
By design, a Managed Instance needs a minimum of 16 IP addresses in a subnet and may use up to 256 IP addresses. As a result, you can use subnet masks /28 to /24 when defining your subnet IP ranges.
5267

68+
> [!IMPORTANT]
69+
> Subnet size with 16 IP addresses is the bare minimum with limited potential for the further Managed Instance scale out. Choosing subnet with the prefix /27 or below is highly recommended. 
70+
5371
If you plan to deploy multiple Managed Instances inside the subnet and need to optimize on subnet size, use these parameters to form a calculation:
5472

5573
- Azure uses five IP addresses in the subnet for its own needs
@@ -58,6 +76,9 @@ If you plan to deploy multiple Managed Instances inside the subnet and need to o
5876

5977
**Example**: You plan to have three General Purpose and two Business Critical Managed Instances. That means you need 5 + 3 * 2 + 2 * 4 = 19 IP addresses. As IP ranges are defined in power of 2, you need the IP range of 32 (2^5) IP addresses. Therefore, you need to reserve the subnet with subnet mask of /27.
6078

79+
> [!IMPORTANT]
80+
> Calculation displayed above will become obsolete with further improvements. 
81+
6182
## Create a new virtual network for Managed Instance using Azure Resource Manager deployment
6283

6384
The easiest way to create and configure virtual network is to use Azure Resource Manager deployment template.
@@ -79,59 +100,6 @@ The easiest way to create and configure virtual network is to use Azure Resource
79100

80101
You might change the names of VNet and subnets and adjust IP ranges associated to your networking resources. Once you press "Purchase" button, this form will create and configure your environment. If you don't need two subnets you can delete the default one.
81102

82-
## Create a new virtual network for Managed Instances using portal
83-
84-
Creating an Azure virtual network is a prerequisite for creating a Managed Instance. You can use the Azure portal, [PowerShell](../virtual-network/quick-create-powershell.md), or [Azure CLI](../virtual-network/quick-create-cli.md). The following section shows the steps using the Azure portal. The details discussed here apply to each of these methods.
85-
86-
1. Click **Create a resource** in the upper left-hand corner of the Azure portal.
87-
2. Locate and then click **Virtual Network**, verify the **Resource Manager** is selected as the deployment mode, and then click **Create**.
88-
89-
![virtual network create](./media/sql-database-managed-instance-tutorial/virtual-network-create.png)
90-
91-
3. Fill out the virtual network form with the requested information, in a manner like the following screenshot:
92-
93-
![virtual network create form](./media/sql-database-managed-instance-tutorial/virtual-network-create-form.png)
94-
95-
4. Click **Create**.
96-
97-
The address space and subnet are specified in CIDR notation.
98-
99-
> [!IMPORTANT]
100-
> The default values create subnet that takes all the VNet address space. If you choose this option, you can not create any other resources inside the virtual network other than Managed Instance.
101-
102-
The recommended approach would be the following:
103-
- Calculate subnet size by following [Determine the size of subnet for Managed Instance](#determine-the-size-of-subnet-for-managed-instances) section
104-
- Assess the needs for the rest of VNet
105-
- Fill in VNet and subnet address ranges accordingly
106-
107-
Make sure that Service endpoints option stays **Disabled**.
108-
109-
![virtual network create form](./media/sql-database-managed-instance-tutorial/service-endpoint-disabled.png)
110-
111-
### Create the required route table and associate it
112-
113-
1. Sign in to the Azure portal
114-
2. Locate and then click **Route table**, and then click **Create** on the Route table page.
115-
116-
![route table create form](./media/sql-database-managed-instance-tutorial/route-table-create-form.png)
117-
118-
3. Create a 0.0.0.0/0 Next Hop Internet route, in a manner like the following screenshots:
119-
120-
![route table add](./media/sql-database-managed-instance-tutorial/route-table-add.png)
121-
122-
![route](./media/sql-database-managed-instance-tutorial/route.png)
123-
124-
4. Associate this route with the subnet for the Managed Instance, in a manner like the following screenshots:
125-
126-
![subnet](./media/sql-database-managed-instance-tutorial/subnet.png)
127-
128-
![set route table](./media/sql-database-managed-instance-tutorial/set-route-table.png)
129-
130-
![set route table-save](./media/sql-database-managed-instance-tutorial/set-route-table-save.png)
131-
132-
133-
Once your VNet has been created, you are ready to create your Managed Instance.
134-
135103
## Modify an existing virtual network for Managed Instances
136104

137105
The questions and answers in this section show you how to add a Managed Instance to existing virtual network.
@@ -145,14 +113,27 @@ You can only create a Managed Instance in Resource Manager virtual networks.
145113
If you would like to create new one:
146114

147115
- Calculate subnet size by following the guidelines in the [Determine the size of subnet for Managed Instances](#determine-the-size-of-subnet-for-managed-instances) section.
148-
- Follow steps in [Add, change, or delete a virtual network subnet](../virtual-network/virtual-network-manage-subnet.md).
116+
- Follow the steps in [Add, change, or delete a virtual network subnet](../virtual-network/virtual-network-manage-subnet.md).
149117
- Create a route table that contains single entry, **0.0.0.0/0**, as the next hop Internet and associate it with the subnet for the Managed Instance.
150118

151-
In case you would like to create a Managed Instance inside an existing subnet:
152-
- Check if the subnet is empty - a Managed Instance cannot be created in a subnet that contains other resources including the Gateway subnet
153-
- Calculate subnet size by following the guidelines in the [Determine the size of subnet for Managed Instances](#determine-the-size-of-subnet-for-managed-instances) section and verify that it is sized appropriately.
154-
- Check that service endpoints are not enabled on the subnet.
155-
- Make sure that there are no network security groups associated with the subnet
119+
If you want to create a Managed Instance inside an existing subnet, we recommend the following PowerShell script to prepare the subnet.
120+
```powershell
121+
$scriptUrlBase = 'https://raw.githubusercontent.com/Microsoft/sql-server-samples/master/samples/manage/azure-sql-db-managed-instance/prepare-subnet'
122+
123+
$parameters = @{
124+
subscriptionId = '<subscriptionId>'
125+
resourceGroupName = '<resourceGroupName>'
126+
virtualNetworkName = '<virtualNetworkName>'
127+
subnetName = '<subnetName>'
128+
}
129+
130+
Invoke-Command -ScriptBlock ([Scriptblock]::Create((iwr ($scriptUrlBase+'/prepareSubnet.ps1?t='+ [DateTime]::Now.Ticks)).Content)) -ArgumentList $parameters
131+
```
132+
Subnet preparation is done in three simple steps:
133+
134+
- Validate - Selected virtual netwok and subnet are validated for Managed Instance networking requirements
135+
- Confirm - User is shown a set of changes that need to be made to prepare subnet for Managed Instance deployment and asked for consent
136+
- Prepare - Virtual network and subnet are configured properly
156137

157138
**Do you have custom DNS server configured?**
158139

0 commit comments

Comments
 (0)