如何创建可用于使用 SSMS 连接到 Azure SQL 托管实例的 Azure VM?

How to create Azure VM that could be used to connect to Azure SQL Managed Instance using SSMS?

我有一个放置在 VNet 中的 Azure SQL 托管实例,我需要使用 SSMS 创建一个 Azure VM 以连接到托管实例。

最简单的配置方法是什么?

如果您已经拥有放置实例的 VNet,则可以使用以下脚本:

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

$parameters = @{
    subscriptionId = '60d9f1df....'
    resourceGroupName = '<resource group where the VM will be placed>'
    virtualMachineName = '<name of the VM>'
    virtualNetworkName = '<Virtual network name where the VM will be placed>'
    subnetName = '<Name of the subnet where the VM will be placed>'
    administratorLogin  = '<RDP user for the VM>'
    administratorLoginPassword  = '<RDP password for the VM>'
}

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

参数subnetName是可选的,如果省略,脚本将创建新的子网。不要在放置托管实例的地方使用子网名称,因为托管实例和虚拟机不能混合在同一个子网中。

有关详细信息,请参阅 https://docs.microsoft.com/en-us/azure/sql-database/sql-database-managed-instance-configure-vm