gpt4 book ai didi

azure - 通过托管身份和私有(private)端点从 Azure WebApp 访问 Azure SQL

转载 作者:行者123 更新时间:2023-12-02 07:38:38 25 4
gpt4 key购买 nike

我有一个托管在 Linux Azure WebApp 上的 AspNetCore3.1 应用程序。我已启用相同的专用端点。一切都像魅力一样。现在,为了添加数据库交互,我为 Web 应用程序启用了系统分配的托管身份 (MI),并将其作为包含用户添加到我的 Azure SQL PaaS 中。但是,我在数据库连接时遇到错误:

Connection was denied since Deny Public Network Access is set to Yes(https://learn.microsoft.com/azure/azure-sql/database/connectivity-settings#deny-public-network-access).To connect to this server, use the Private Endpoint from inside yourvirtual network(https://learn.microsoft.com/azure/sql-database/sql-database-private-endpoint-overview#how-to-set-up-private-link-for-azure-sql-database).atMicrosoft.Data.ProviderBase.DbConnectionPool.CheckPoolBlockingPeriod(Exceptione)

也为 SQL DB 配置了专用端点。该子网与 webapp 的专用终结点位于不同的子网中,但位于同一 VNet 中。

-更新:我已验证即使我从 webApp 中删除专用端点,仍然会引发错误。

我在这里错过了什么?

最佳答案

该错误消息表明您正在尝试从 Web 应用程序通过公共(public)网络访问 SQL Server。您需要限制 VNet 中 Web 应用程序的传出流量,然后您可以使用 SQL Server 的专用终结点。阅读 using Private Endpoints for Azure Web App .

Private Endpoint is only used for incoming flows to your Web App.Outgoing flows will not use this Private Endpoint, but you can injectoutgoing flows to your network in a different subnet through the VNetintegration feature.

当您在 SQL Server 中添加专用端点连接时,您将看到 Microsoft.Sql 的服务端点和您为 SQL Server 创建专用端点的 VNet 中的专用端点。

通过专用链接将 Azure Web 应用程序访问专用网络内的 SQL Server。您需要启用VNet Integration for your web app在同一 VNet 中的另一个空子网中。默认情况下,你的应用程序无法与 Azure DNS 专用区域配合使用。要使用 Azure DNS 专用区域,您需要添加以下应用设置:

WEBSITE_DNS_SERVER with value 168.63.129.16
WEBSITE_VNET_ROUTE_ALL with value 1

native Windows 应用中的测试结果

使用上述两个应用设置 WEBSITE_DNS_SERVERWEBSITE_VNET_ROUTE_ALL 配置从 Web 应用到 SQL 数据库,它会解析为私有(private) IP 地址。

enter image description here

从 Web 应用到 SQL 数据库,应用设置 WEBSITE_DNS_SERVER 的值为 168.63.129.16,使用私有(private) DNS 区域且未配置 WEBSITE_VNET_ROUTE_ALL。它解析为公共(public) IP 地址。

enter image description here

关于azure - 通过托管身份和私有(private)端点从 Azure WebApp 访问 Azure SQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64901591/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com