You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

已启用身份验证的Azure函数应用Event Grid触发授权问题

问题描述

我有一个包含多个函数的Azure Function App,部分函数使用HTTP触发器,还有一个使用Event Grid Trigger。我希望对HTTP触发器强制启用身份验证,但启用后Event Grid无法触发对应的函数,Log Analytics中得到如下错误:

outcome=Unauthorized
latencyInMs=1600
id=0f82d947-028f-4fda-8f02-ff2b5b91997d
outputEventSystemId=61e3220c-ca44-42d3-a747-42ed44104871
state=FilteredFailingDelivery
deliveryTime=12/6/2024 3:13:39 PM
deliveryCount=0
probationCount=1
deliverySchema=EventGridEvent
trackedSystemTopicState=CreatedExplicitlyByUser
eventSubscriptionDeliverySchema=EventGridEvent
outputEventFields=InputEvent| EventSubscriptionId| DeliveryTime| State| Id| ProbationCount| LastHttpStatusCode| LastDeliveryOutcome| DeliverySchema| LastDeliveryAttemptTime| SystemId| UseMappedResourceArmIdForBilling| TrackedSystemTopicState
outputEventFieldCount=12
dedicatedQueueDeliveryQueueId=
requestExpiration=1/1/0001 12:00:00 AM
delivered=False id=40706be1-9f96-4b99-9fda-7a940e8cf1b7
inputEventSystemId=d11146fa-4136-4fad-9388-097739fa3b0c publishTime=12/6/2024 3:13:38 PM
eventTime=12/6/2024 3:13:37 PM
eventType=Microsoft.AppConfiguration.KeyValueModified
deliveryTime=1/1/0001 12:00:00 AM
filteringState=FilteringPending
inputSchema=EventGridEvent
publisher=MICROSOFT-APPCONFIGURATION-CONFIGURATIONSTORES.WESTEUROPE-1.EVENTGRID.AZURE.NET
size=682
subject=https://appconfiguration.azconfig.io/kv/qwerty?label=apmgroup-Group1&api-version=2023-10-01
inputEventFields=Id| PublishTime| SerializedBody| EventType| Topic| Subject| FilteringHashCode| SystemId| Publisher| FilteringTopic| TopicCategory| DataVersion| MetadataVersion| InputSchema| EventTime| FilteringPolicy
inputEventFieldCount=16
type=AzureFunction
subType=NotApplicable
supportsBatching=False
aadIntegration=False
managedIdentityType=None
armId=/subscriptions/<subid>/resourceGroups/<rgname>/providers/Microsoft.Web/sites/<function app name>/functions/<function name>
deliveryResponse=Unauthorized
errorCode=Unauthorized
HttpRequestMessage: httpVersion=1.1
HttpResponseMessage: HttpVersion=1.1
StatusCode=Unauthorized(Unauthorized)
StatusDescription=Unauthorized
IsRedirected=False
RedirectUrl=

请问是否可以让Event Grid无需授权即可触发函数,或者有其他可行的解决方案?

可行解决方案
  • 方案1:配置身份验证豁免规则
    在Function App的「身份验证」设置中,添加例外规则:选择「允许服务标签」,指定EventGrid服务标签。这样Event Grid的请求会被直接放行,HTTP触发器的身份验证依然生效。

  • 方案2:用Azure AD身份验证让Event Grid合法调用

    1. 给Function App的Azure AD身份验证添加「应用程序」类型的身份提供者,配置允许的客户端范围;
    2. 创建托管标识(系统分配或用户分配均可),赋予其访问Function App的对应权限;
    3. 创建Event Grid订阅时,选择「使用Azure AD身份验证」,指定该托管标识,让Event Grid以合法身份请求函数。
  • 方案3:拆分Function App
    将Event Grid Trigger的函数单独部署到一个新的Function App中,这个新App不启用身份验证,专门处理Event Grid触发请求;原App保留身份验证,仅处理HTTP触发器请求。两个App可通过内部调用或存储队列等方式传递数据,保证业务流程完整。

内容的提问来源于stack exchange,提问作者Hofa

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 19:53:17