First published on MSDN on Oct 26, 2018
How to connect with an existing VM to your Managed Instance Vnet
This guide assumes you already have a deployment of a Managed instance in your subscription
Problem summary:
Initially, you might
not
want to deploy a new machine using the script in the
Getting Started
section in your Managed Instance to connect, because you already have several deployed VMs and you don't want to deploy a new Virtual Machine and incur in additional costs. In this case, we could suggest you to peer your existing Virtual networks to your Managed Instance Virtual network, taking into account that you already have an existing Virtual network in the same regions as the one where your Managed Instance was deployed to.
Explanation of this guide:
This guide was designed to guide our customers to be able to connect to their Managed Instance from a
Virtual Machine
from a different
Virtual Network
to their Managed Instance. The solution to this problem is by creating
Virtual Network Peerings
. Why the peering needs to be both ways? Well, by design, network peering will only go A -->
B if you set it this way. If you don’t set B -->
A, then no response will be received resulting in several connectivity errors such as
SNI timeouts
and
connection timeouts
. Why? Well, if you think of it in terms of connectivity, we send some pre-login packets to the resource (Managed Instance); taking into consideration that the flow is from A
-->B, B will not have a way to send back packets to A, therefore this would cause a loss in connectivity at the pre-login phase. Therefore, the
Virtual Network Peering
must be set both ways A -->
B and B -->
A.
On your portal, create a new Virtual network.
-
It doesn’t matter if the Virtual network or the VM is in another resource group.
-
It is essential that you create this new virtual network and the VM in the same region as your Managed Instance.
Create a new VM and attach it to this new Virtual network (ToMIVnet)
Once the VM is created and attached to the new virtual network, we will proceed to configure the Peerings between the two virtual networks.
Setting A --> B
-
Click on +Add
-
Add a name to the peering
-
Choose the virtual network you are going to peer it to
-
Hit the OK button.
Setting A <-- B
-
Do the same as you did with A, but in B.
-
Now, fire up your new VM in the external virtual network that is now peered to your Managed Instance Virtual network, install SQL Server Management Studio and try to connect to your Managed Instance.
-
Now, at this step, you should be able to connect to your Managed Instance and manage it!