如何使用点到站点连接 (P2S) 从我的笔记本电脑连接到 VNet 中的 Azure Sql 托管实例?

How to connect to Azure Sql Managed Instance in VNet from my laptop using point to site connection (P2S)?

Azure SQL 托管实例放置在具有私有 IP 地址的私有 Azure VNet 中。

如何直接从本地 machine/laptop 连接到实例?如何使用点到站点连接将我的机器连接到放置实例的 VNet?

您可以运行以下脚本并填充订阅 ID、放置 VNet 的资源组名称和虚拟网络名称:

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

$parameters = @{
    subscriptionId = '<subscription id>'
    resourceGroupName = '<resource group name>'
    virtualNetworkName = '<virtual network name>'
    certificateNamePrefix  = '<name prefix of the automatically generated certificate>'
}

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

此脚本将创建用于连接到 VNet 的证书。然后你需要找到一个网关,下载并安装 VPN 客户端并连接到 VNet。然后您将能够从您的计算机连接到实例。

如果您在 Azure 门户中打开实例的详细信息,您将在快速入门部分看到预填充的值。

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