【问题标题】:Restrict Access to Web Apis in Azure AppServices to Azure Function app, while allowing access to other web apis and web pages to other services将 Azure AppServices 中的 Web API 访问限制为 Azure Function 应用,同时允许其他 Web API 和网页访问其他服务
【发布时间】:2021-04-01 03:44:57
【问题描述】:

我有一个 Azure AppService,为网页和 web api 运行 ASP.NET Core。

目前,所有网页都是公开可用的,并且通过使用 Azure AD 登录受到限制。

目前,所有 Web API 都可以公开使用,并通过客户端登录凭据进行限制。这些可通过 3rd 方工具访问。

现在,新的 Azure Function 应用需要调用 Azure AppService 中的新 Web API。新的 Web API 必须仅对函数应用可用。新的 Function 应用与 AppService 托管在同一区域,并由同一团队管理。

有哪些限制方法?

https://docs.microsoft.com/en-us/azure/app-service/overview-managed-identity?tabs=dotnet

【问题讨论】:

    标签: azure asp.net-core asp.net-web-api azure-functions azure-web-app-service


    【解决方案1】:

    有两种方法可以做到这一点。但是,在这两种情况下,您都需要在函数应用上启用 Regional VNet Integration

    1. 在 Web Api 上,启用 Private Endpoints 功能。这将禁用所有公共访问并限制来自 VNET 的访问。此功能将需要一个未使用的子网,然后将其用于分配入站私有 IP 地址。使用 Vnet 集成的 Function App 可以访问 Web Api(使用 Private Endpoint)。

    注意:您需要创建 2 个子网,一个用于 Vnet 集成,另一个用于 另一个用于私有端点功能。最好把它们放进去 相同的 VNet。

    1. 在 Web Api 上,启用 access restrictions 并允许访问与 Function API 集成的子网。

    【讨论】:

      【解决方案2】:

      新的 Web API 必须仅适用于 Function 应用。

      根据你的需求,你可以使用azure VNET来实现,首先把你的Web API放到一个azure VNET中,然后这个API就不能被其他人访问了。之后,您的函数应用程序在 VNET 中。则只能通过 VNET 中的函数应用访问 WEB API。

      看看这个官方文档:

      https://docs.microsoft.com/en-us/azure/app-service/web-sites-integrate-with-vnet

      【讨论】:

      • 问题是新的 Web API 和现有的 Web API 和网页托管在同一个 App Service 中。
      猜你喜欢
      • 2021-05-03
      • 2011-04-16
      • 1970-01-01
      • 2018-12-03
      • 2022-09-28
      • 2013-07-09
      • 2019-11-05
      • 2016-01-04
      • 1970-01-01
      相关资源
      最近更新 更多