Azure Web App VNet 与私有存储帐户的集成 Link
Azure Web App VNet integration to Storage account with Private Link
我在 Azure 应用服务 (S1) 上有一个 API,我在上面配置了 VNet 集成(子网 10.240.0.32/27)。我还有一个存储帐户,我在其中配置了一个私有 Link(子网 10.240.0.0/27
并获得了 IP 10.240.0.4
)。但是它不起作用我收到以下错误:
StorageException: This request is not authorized to perform this operation.
有谁知道我是否需要配置其他任何东西才能正常工作?
这 doc 说明我不必更改任何连接字符串。在配置私有 link.
之前连接有效
更新
我也尝试过使用 Azure SQL 数据库。在与存储子网相同的子网中部署了一个 Private Link 到 SQL。这里也没有太多运气。出现以下错误:
SqlException: Reason: An instance-specific error occurred while
establishing a connection to SQL Server. The public data endpoint on
this server is not accessible. To connect to this server, use the
Private Endpoint from inside your virtual network.
当我将 WEBSITE_VNET_ROUTE_ALL
(使所有传出流量通过虚拟网络而不仅仅是私有 IP)添加到 Web 应用程序并将其设置为 1
时,我收到以下错误:
SqlException: A network-related or instance-specific error occurred
while establishing a connection to SQL Server. The server was not
found or was not accessible. Verify that the instance name is correct
and that SQL Server is configured to allow remote connections.
(provider: TCP Provider, error: 0 - A non-recoverable error occurred
during a database lookup.)
然后我在与私有 links 相同的子网中创建了一个 VM。从那个虚拟机,我可以 运行 这个命令很好地 returns 使用正确的 IP:
.\psping.exe azurenetworking.database.windows.net:1433
2020 年 4 月 2 日更新
今天与微软通了电话。事实证明,应用服务目前无法使用私有 DNS 区域。因此,您现在需要设置自己的 DNS 服务器。它将被修复,但他们无法给我预计到达时间。所以现在它要么是自定义 DNS 服务器,要么使用服务端点。当这发生变化时我会更新这个问题
6 月 2 日更新
相关详细信息已添加到文档中:https://docs.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet#azure-dns-private-zones
归结为:
要使用 Azure DNS 私有区域,您需要添加以下应用设置:
WEBSITE_DNS_SERVER
值为 168.63.129.16
WEBSITE_VNET_ROUTE_ALL
值为 1
我为任何对完整示例感兴趣的人写了一篇关于它的博客:https://erwinstaal.nl/posts/securing-your-azure-db-connection-using-azure-private-link/
当您通过 public 端点访问 blob 存储但启用存储帐户的 VNet 防火墙设置时,可能会发生错误。
在 App VNet 集成到存储帐户连接的情况下,您可以使用 service endpoint instead of private endpoint. To use service endpoints with your app, use regional VNet Integration 连接到选定的虚拟网络。然后在您用于集成的子网上配置服务端点 Microsoft.Storage
。
如果您仍想使用专用端点,恐怕您需要使用您的 own DNS server for name resolution from an Azure App Service (Web App, Function, or Bot) using virtual network integration to role instances or VMs in the same virtual network. See Name resolution for resources in Azure virtual networks。
使用私有 link,blob 存储 DNS 名称解析为 public IP 地址,而不是来自应用服务控制台的私有终结点 IP 地址。从应用服务访问时,您似乎正在通过 public 端点访问 VNet 外部的 blob 存储。同时,它可以从与专用端点位于同一子网中的 VM 解析为专用端点 IP。参见 DNS changes for private endpoints。
我在使用应用服务与私有 sql 端点通信时遇到了这个问题,这条评论让系统开始为我工作:
Today, I set up the following four points and tried them
- Create a Private DNS Zone and connect it to VNET(privatelink.blob.core.windows.net)
- Set the VNET DNS to 168.63.129.16
- Configure WebApps to Regional VNET Integration
- Set WEBSITE_VNET_ROUTE_ALL of WebApps to 1
I got PrivateIP from KUDU(nameresolver xxxx.blob.core.windows.net) I
was also able to access it from the PrivateIP side using curl in KUDU.
It seems to be important to set both 2 and 4
然后我在 kudu 命令行环境中使用 nameresolver 来查看解析到哪些 IP 地址。我的一个环境仍然无法正常工作,但我认为它已经更改了很多次,以至于进入了某种奇怪的状态。设置 VNET DNS 是拼图的最后一块
希望对您有所帮助
我在 Azure 应用服务 (S1) 上有一个 API,我在上面配置了 VNet 集成(子网 10.240.0.32/27)。我还有一个存储帐户,我在其中配置了一个私有 Link(子网 10.240.0.0/27
并获得了 IP 10.240.0.4
)。但是它不起作用我收到以下错误:
StorageException: This request is not authorized to perform this operation.
有谁知道我是否需要配置其他任何东西才能正常工作?
这 doc 说明我不必更改任何连接字符串。在配置私有 link.
之前连接有效更新
我也尝试过使用 Azure SQL 数据库。在与存储子网相同的子网中部署了一个 Private Link 到 SQL。这里也没有太多运气。出现以下错误:
SqlException: Reason: An instance-specific error occurred while establishing a connection to SQL Server. The public data endpoint on this server is not accessible. To connect to this server, use the Private Endpoint from inside your virtual network.
当我将 WEBSITE_VNET_ROUTE_ALL
(使所有传出流量通过虚拟网络而不仅仅是私有 IP)添加到 Web 应用程序并将其设置为 1
时,我收到以下错误:
SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A non-recoverable error occurred during a database lookup.)
然后我在与私有 links 相同的子网中创建了一个 VM。从那个虚拟机,我可以 运行 这个命令很好地 returns 使用正确的 IP:
.\psping.exe azurenetworking.database.windows.net:1433
2020 年 4 月 2 日更新
今天与微软通了电话。事实证明,应用服务目前无法使用私有 DNS 区域。因此,您现在需要设置自己的 DNS 服务器。它将被修复,但他们无法给我预计到达时间。所以现在它要么是自定义 DNS 服务器,要么使用服务端点。当这发生变化时我会更新这个问题
6 月 2 日更新
相关详细信息已添加到文档中:https://docs.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet#azure-dns-private-zones
归结为:
要使用 Azure DNS 私有区域,您需要添加以下应用设置:
WEBSITE_DNS_SERVER
值为 168.63.129.16
WEBSITE_VNET_ROUTE_ALL
值为 1
我为任何对完整示例感兴趣的人写了一篇关于它的博客:https://erwinstaal.nl/posts/securing-your-azure-db-connection-using-azure-private-link/
当您通过 public 端点访问 blob 存储但启用存储帐户的 VNet 防火墙设置时,可能会发生错误。
在 App VNet 集成到存储帐户连接的情况下,您可以使用 service endpoint instead of private endpoint. To use service endpoints with your app, use regional VNet Integration 连接到选定的虚拟网络。然后在您用于集成的子网上配置服务端点 Microsoft.Storage
。
如果您仍想使用专用端点,恐怕您需要使用您的 own DNS server for name resolution from an Azure App Service (Web App, Function, or Bot) using virtual network integration to role instances or VMs in the same virtual network. See Name resolution for resources in Azure virtual networks。
使用私有 link,blob 存储 DNS 名称解析为 public IP 地址,而不是来自应用服务控制台的私有终结点 IP 地址。从应用服务访问时,您似乎正在通过 public 端点访问 VNet 外部的 blob 存储。同时,它可以从与专用端点位于同一子网中的 VM 解析为专用端点 IP。参见 DNS changes for private endpoints。
我在使用应用服务与私有 sql 端点通信时遇到了这个问题,这条评论让系统开始为我工作:
Today, I set up the following four points and tried them
- Create a Private DNS Zone and connect it to VNET(privatelink.blob.core.windows.net)
- Set the VNET DNS to 168.63.129.16
- Configure WebApps to Regional VNET Integration
- Set WEBSITE_VNET_ROUTE_ALL of WebApps to 1
I got PrivateIP from KUDU(nameresolver xxxx.blob.core.windows.net) I was also able to access it from the PrivateIP side using curl in KUDU.
It seems to be important to set both 2 and 4
然后我在 kudu 命令行环境中使用 nameresolver 来查看解析到哪些 IP 地址。我的一个环境仍然无法正常工作,但我认为它已经更改了很多次,以至于进入了某种奇怪的状态。设置 VNET DNS 是拼图的最后一块
希望对您有所帮助