首页 > 解决方案 > 限制从 Azure 函数子网访问存储帐户

问题描述

我有一个托管在 (S1) 应用服务计划上的 azure 函数。Azure 函数已集成到 VNet 子网。此子网启用了Microsoft.StorageMicrosoft.Web服务端点,并且它被委派给Microsoft.Web/serverFarms

另一方面,存储帐户配置为仅接受来自 azure 函数所属子网的请求。

不幸的是,这不起作用。当我尝试从 Azure 功能与存储帐户通信时,出现以下错误

2020-02-18T02:03:03.505 [Error] Faliure Occured
Azure.RequestFailedException : This request is not authorized to perform this operation.
RequestId:0b034a99-701e-002c-09ff-e5bd0a000000
Time:2020-02-18T02:03:03.1177265Z
Status: 403 (This request is not authorized to perform this operation.)
ErrorCode: AuthorizationFailure

Headers:
Server: Microsoft-HTTPAPI/2.0
x-ms-request-id: 0b034a99-701e-002c-09ff-e5bd0a000000
x-ms-client-request-id: 0bbe8185-4657-47f3-8566-5bcbd16c4274
x-ms-error-code: AuthorizationFailure
Date: Tue, 18 Feb 2020 02:03:02 GMT
Content-Length: 246
Content-Type: application/xml

   at Azure.Storage.Blobs.BlobRestClient.Container.GetPropertiesAsync_CreateResponse(ClientDiagnostics clientDiagnostics,Response response)
   at async Azure.Storage.Blobs.BlobRestClient.Container.GetPropertiesAsync(ClientDiagnostics clientDiagnostics,HttpPipeline pipeline,Uri resourceUri,String version,Nullable`1 timeout,String leaseId,String requestId,Boolean async,String operationName,CancellationToken cancellationToken)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at async Azure.Storage.Blobs.BlobContainerClient.GetPropertiesInternal(BlobRequestConditions conditions,Boolean async,CancellationToken cancellationToken)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Azure.Storage.TaskExtensions.EnsureCompleted[T](Task`1 task)
   at Azure.Storage.Blobs.BlobContainerClient.GetProperties(BlobRequestConditions conditions,CancellationToken cancellationToken)
   at SharedLib.Utils.TestStorageAccountAccess() at D:\poc-code\NetworkSecurityPoc\SharedLib\Utils.cs : 13
   at async MessengerFunction.Trigger.Run(HttpRequest req,ILogger log) at D:\poc-code\NetworkSecurityPoc\MessengerFunction\Trigger.cs : 25

但是当我禁用存储帐户的 vnet 限制时,一切正常。

我可能做错了什么?

谢谢你。

标签: azureazure-functionsazure-storagevnet

解决方案


以下文档可能有助于为什么会发生这种情况:来自 MS 文档:创建函数应用时,必须创建或链接到支持 Blob、队列和表存储的通用 Azure 存储帐户。您目前无法对此帐户使用任何虚拟网络限制。如果在用于函数应用的存储帐户上配置虚拟网络服务终结点,该配置将破坏你的应用。参考:在此处输入链接描述


推荐阅读