本文介绍了使用虚拟网络从 Azure 应用服务访问 Blob 存储的防火墙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最初我尝试使用 IP 地址限制从应用服务对 blob 存储的访问,但结果证明您只能使用虚拟网络执行此操作:从 Azure 应用服务到 blob 存储的防火墙访问

Originally I tried to restrict access from an app service to blob storage using IP addresses, however it turned out that you can only do this using a Virtual Network: Firewall access from Azure app service to blob storage

我希望能够在不设置点到站点 VPN 的情况下实现这一目标.我在 Azure 中设置虚拟网络的步骤如下:

I want to be able to achieve this without setting up a point-to-site VPN. The steps I have taken to set up a virtual network in Azure are as follows:

  • 创建网络安全组securitygroup-frontend",添加自定义名为 Web 的入站规则,源:服务标签,源服务标签:Internet,源端口范围:*,目标:任意,目标端口范围:80、443,协议:任何,操作:允许,优先级:100
  • 创建了虚拟网络,地址空间为 192.168.0.0/23,子网称为前端地址范围 192.168.0.0/26,网络安全组:securitygroup-frontend 和子网委托给 Microsoft.Web/serverFarms 和服务端点 Microsoft.Storage
  • 转到应用服务 -> 网络 -> 配置 VNet 集成 ->添加 VNet 预览并选择您创建的子网
  • 进入存储 -> 防火墙和虚拟网络 -> 配置 VNet 集成 -> 选择选定网络"并添加刚刚创建的虚拟网络和子网.

我不得不将 Azure 诊断和日志(例如密钥保管库、服务总线和 sql azure)移动到它自己的 Blob 存储中,因为这些需要在虚拟网络之外进行 Blob 存储,并且无法在内部工作.该应用程序服务在标准计划中.应用服务、blob 存储和虚拟网络都在同一个区域.

I have had to move Azure diagnostics and logs such as for key vault, service bus and sql azure to its own blob storage as these require blob storage outside of a virtual network and can't be made to work inside. The app service is in the Standard plan. The app service, blob storage and virtual network are all in the same region.

此问题和答案不提供任何见解:https://social.msdn.microsoft.com/Forums/azure/en-US/9f4d8aeb-68a6-4ec1-9e11-bee2d1301792/allow-access-to-azure-storage-account-only-from-an-app-service?forum=windowsazurewebsitespreview

This question and answer does not provide any insights: https://social.msdn.microsoft.com/Forums/azure/en-US/9f4d8aeb-68a6-4ec1-9e11-bee2d1301792/allow-access-to-azure-storage-account-only-from-an-app-service?forum=windowsazurewebsitespreview

上述步骤虽然阻止了应用服务对 blob 存储的访问,但其中的任何资产都会返回错误:(403) Forbidden.如果我从 blob 存储中删除虚拟网络,它工作正常.我做错了什么?

The above steps though block off access from the app service to blob storage and any assets within return an error: (403) Forbidden. If I remove the Virtual network from blob storage it works fine. What am I doing wrong?

推荐答案

是的,您可以使用 VNet 执行此操作,但您需要使用 应用服务环境.您不能使用 VNet 集成来做到这一点.将 Azure 服务集成到 Azure 虚拟网络 允许从虚拟机或虚拟网络中的计算资源对服务进行私有访问.但是,常规应用服务计划中的 Web 应用服务是多租户的.使用 ASE,您可以将其部署到您的 VNet 中.

Yes, you can do this using a VNet but you need to deploy the web app in a VNet with App Service Environments. You can not do this with VNet integration. Integrating Azure services to an Azure virtual network enables private access to the service from virtual machines or compute resources in the virtual network. However, web app service in a regular app service plan is multi-tenant. With ASE, you could deploy it into your VNet.

您可以从类似的 线程.根据 silent 的评论,您还可以考虑将您的 Web 应用程序部署在一个容器中,该容器可以部署在有一些限制的 VNet 中.

You could get more details and explanation from this similar thread. According to a comment from silent, you could also consider deploying your web app inside a container which could be deployed in a VNet with some restriction.

有时,网络的部署顺序很重要.在您的情况下,您在 VNet 集成之前启用服务终结点.我建议删除集成应用程序子网 VNet 中的 NSG 限制以进行测试.然后你可以检查以下步骤.

Sometimes, the deployment order for networking is important. In your case, you enable service endpoint before VNet integration. I suggest removing NSG restriction in integrated app subnet VNet for a test. Then you could check the following steps.

首先,您可以使用未使用的子网部署新的 VNet 集成.完成 VNet 集成并重新启动 Web 应用程序后,您可以为此子网启用服务终结点和子网委派.最后,您可以在存储帐户的防火墙中添加子网.

Firstly, you could deploy new VNet integration with an unused subnet. After the VNet Integration is completed and the web app is restarted, you could enable service endpoint and subnet delegation for this subnet. In the end, you could add the subnet in the firewall of the storage account.

新版本目前处于预览阶段,而不是 GA.可能并非所有功能都可用.您还可以检查以下特征.

The new version is in Preview and not GA currently. It might be not all functions available. you could also check the following characteristics.

  • 无需网关即可使用新的 VNet 集成功能.
  • 除了与 ExpressRoute 连接的 VNet 集成之外,您无需任何其他配置即可跨 ExpressRoute 连接访问资源.
  • 应用和 VNet 必须位于同一区域.
  • 新功能需要资源管理器 VNet 中有一个未使用的子网.
  • 您的应用必须位于能够扩展到高级 v2 的 Azure 应用服务部署中.
  • 您的应用服务计划必须是标准、高级或 PremiumV2 计划新功能不支持生产工作负载,而它在预览中
  • 新的 VNet 集成功能不适用于应用服务环境中的应用.
  • 您无法删除具有集成应用程序的 VNet.
  • 新的 VNet 集成尚不支持路由表和全局对等互连.
  • 每个应用服务计划实例使用一个地址.由于分配后无法更改子网大小,因此请使用可以超过您的最大比例尺尺寸.具有 32 个地址的/27 是建议的大小,因为它可以容纳应用服务计划扩展到 20 个实例.
  • 您可以使用新的 VNet 集成功能来使用受服务端点保护的资源.为此,请在用于 VNet 集成的子网.

这篇关于使用虚拟网络从 Azure 应用服务访问 Blob 存储的防火墙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 22:21