简体   繁体   English

Azure 专用端点到 azure sql 数据库

[英]Azure private endpoint to azure sql database

As a POC I'm trying to connect my VM machine with Azure SQL Database using private endpoint.作为 POC,我正在尝试使用私有端点将我的 VM 机器与 Azure SQL 数据库连接起来。 I've tried the tutorial found here: https://docs.microsoft.com/en-us/azure/private-link/create-private-endpoint-portal however I'm stuck at new private endpoint step.我已经尝试过这里的教程: https://docs.microsoft.com/en-us/azure/private-link/create-private-endpoint-portal但是我被困在新的私有端点步骤。

Please look at the following screen:请看下面的画面: 在此处输入图像描述

the "Resource type" dropdown those not show any items那些不显示任何项目的“资源类型”下拉列表

If I change the "Connection method" to "Connect to an Azure resource by resource ID or alias' and put the resource id of my sql server: /subscriptions/1efd84d6-173f-42cc-80db-7b2c17eb0edd/resourceGroups/eu_poland_general/providers/Microsoft.Sql/servers/plink-sql-server , I'm getting The resource type 'Microsoft.Sql/servers' is not a supported resource type. error:如果我将“连接方法”更改为“通过资源 ID 或别名连接到 Azure 资源”并将我的 sql 服务器的资源 ID: /subscriptions/1efd84d6-173f-42cc-80db-7b2c_reeuland7eb0ed/ Microsoft.Sql/servers/plink-sql-server ,我得到资源类型“Microsoft.Sql/servers”不是受支持的资源类型。错误: 在此处输入图像描述


I was able to overcome this issue with different approach.我能够用不同的方法克服这个问题。 These are steps I've made这些是我所做的步骤

  1. I created the VNET for my VM and private endpoint with default subnet我使用默认子网为我的 VM 和专用端点创建了 VNET
  2. I've disabled the disable network policies for private endpoints by AZURE CLI from this question Private endpoint in Azure我已经通过 AZURE CLI 从这个问题Private endpoint in Azure禁用了专用端点的禁用网络策略
  3. I've created virtual machine inside this vnet with rdp connection set up我已经在这个 vnet 中创建了虚拟机,并设置了 rdp 连接
  4. I've created Azure SQL server我已经创建了 Azure SQL 服务器
  5. I've created Azure SQL database under the Azure SQL Server that I've just created我已经创建了 Azure SQL 数据库在 Azure Z9778840A0100CB30C9828 下创建的服务器
    • During the creation of this database I've added a private endpoint in networking section.在创建此数据库期间,我在网络部分添加了一个私有端点。

At this point I've tried to connect to this database from VM I've created using the private address that was created by step 5.此时,我尝试从使用步骤 5 创建的私有地址创建的 VM 连接到该数据库。

I could not connect to database using private address (10.0.2.5), however I was able to connect to the sql server using the public address plink-sql-server.database.windows.net我无法使用私有地址 (10.0.2.5) 连接到数据库,但是我能够使用公共地址plink-sql-server.database.windows.net连接到 sql 服务器

I've also try to call nslookup on the server to see if the result are similar to the tutorial that I've mentioned at the beginning of this post however my answers are slightly different:我还尝试在服务器上调用 nslookup 以查看结果是否与我在本文开头提到的教程相似,但是我的答案略有不同: 在此处输入图像描述

Anybody knows what is going on?有人知道发生了什么吗?

Following that document , I can create a private endpoint for the Azure SQL server.根据该文档,我可以为 Azure SQL 服务器创建一个私有端点。

Please note that请注意

Private endpoint(s) are not permitted in conjunction with service endpoints in the same subnet!不允许私有端点与同一子网中的服务端点一起使用!

If you have subnet enabled service endpoints , you can remove it or create another subnet for your VM.如果您有启用子网的服务端点,您可以将其移除或为您的 VM 创建另一个子网。

For a test, I create all resources VM, SQL Server, etc are in the same region as the below steps:为了进行测试,我创建了所有资源 VM、SQL 服务器等与以下步骤位于同一区域:

  1. Create a VM in the subnet mysubnet without any service endpoints enabled.在未启用任何service endpoints的子网mysubnet中创建 VM。
  2. Create a SQL database server via select Create a resource > Databases > SQL database, then In Server, select Create new. Create a SQL database server via select Create a resource > Databases > SQL database, then In Server, select Create new.
  3. Create a private endpoint for the SQL server resource.为 SQL 服务器资源创建专用终结点。 In Private Link Center - Overview, on the option to Build a private connection to a service.在 Private Link Center - Overview 中,选择 Build a private connection to a service。 在此处输入图像描述
  4. RDP to that VM and access the SQL database server privately from the VM. RDP 到该 VM 并从 VM 私下访问 SQL 数据库服务器。 在此处输入图像描述

For the first issue, the manual case uses the resource types from the dropdown to validate that the ID you gave in the manual scenario is one of those types.对于第一个问题,手动案例使用下拉列表中的资源类型来验证您在手动方案中提供的 ID 是这些类型之一。 Since your resource type dropdown was empty, it probably wasn't going to like any ids you put in the manual case.由于您的资源类型下拉列表是空的,它可能不会喜欢您在手动案例中放置的任何 id。

For the second issue, make sure the vnet the private endpoint is associated to is linked to a private DNS zone named privatelink.database.windows.net with an A record named plink-sql-server that points to the private ip.对于第二个问题,请确保与专用端点关联的 vnet 链接到名为privatelink.database.windows.net的专用 DNS 区域,其中包含名为plink-sql-server的 A 记录,该记录指向专用 ip。 Also make sure you are trying to access the endpoint from the VM that is attached to the network interface created with the private endpoint.还要确保您尝试从连接到使用专用端点创建的网络接口的 VM 访问端点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM