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

Azure IoT Hub遗留WebJob连接报401未授权错误求助

Azure IoT Hub遗留WebJob突发401未授权问题

问题现象

昨日起,用于读取Azure IoT Hub消息的遗留WebJob启动连接端点时抛出401错误:

Management operation failed. status-code: 401. status-description: Attempted to perform an unauthorized operation..

原有配置

此前使用默认eventHubName及iothubowner共享访问策略连接字符串:

HostName={our hoist here};SharedAccessKeyName=iothubowner;SharedAccessKey={key here}

该配置此前运行正常,昨日午间突发报错。

排查操作

  • 更换备用连接字符串无效
  • 检查iothubowner权限无异常
  • 改用内置端点中的Event Hub-compatible endpoint后恢复正常

使用的已弃用NuGet包

  • Microsoft.Azure.WebJobs 2.1.0
  • Microsoft.Azure.WebJobs.ServiceBus 2.1.0
  • WindowsAzure.ServiceBus 6.2.2
  • WindowsAzure.Storage 8.7.0
  • Microsoft.Azure.ServiceBus.EventProcessorHost 3.1.5

相关日志

[12234a: INFO] Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'Functions.ReceiveDataBatchAsync' was unable to start. ---> Microsoft.ServiceBus.Messaging.MessagingException: Management operation failed. status-code: 401, status-description: Attempted to perform an unauthorized operation..
[12234a: INFO]    at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
[12234a: INFO]    at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.Amqp.AmqpServiceClient`1.RequestAsyncResult.End(IAsyncResult result)
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.Amqp.AmqpServiceClient`1.EndRequest(IAsyncResult result, MethodData md, MethodCallMessage mcm)
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.Amqp.AmqpServiceClient`1.AmqpClientProxy.Invoke(MethodCallMessage mcm)
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.RealProxy.Invoke(Object[] args)
[12234a: INFO]    at proxy_2.EndGetRuntimeInfo[T](IAsyncResult )
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.Amqp.AmqpEventHubClient.GetRuntimeInfoAsyncResult`1.<>c.<GetAsyncSteps>b__12_3(GetRuntimeInfoAsyncResult`1 thisPtr, IAsyncResult r)
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
[12234a: INFO] --- End of stack trace from previous location where exception was thrown ---
[12234a: INFO]    at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.Amqp.AmqpEventHubClient.<GetRuntimeInformationAsync>b__4_1(IAsyncResult r)
[12234a: INFO]    at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
[12234a: INFO] --- End of stack trace from previous location where exception was thrown ---
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.EventProcessorHost.<InitializeAsync>d__53.MoveNext()
[12234a: INFO] --- End of stack trace from previous location where exception was thrown ---
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12234a: INFO]    at Microsoft.ServiceBus.Messaging.EventProcessorHost.<StartAsync>d__54.MoveNext()
[12234a: INFO] --- End of stack trace from previous location where exception was thrown ---
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12234a: INFO]    at Microsoft.Azure.WebJobs.Host.Listeners.FunctionListener.<StartAsync>d__8.MoveNext()
[12234a: INFO]    --- End of inner exception stack trace ---
[12234a: INFO]    at Microsoft.Azure.WebJobs.Host.RecoverableException.TryRecover(TraceWriter trace, ILogger logger)
[12234a: INFO]    at Microsoft.Azure.WebJobs.Host.Listeners.FunctionListener.<StartAsync>d__8.MoveNext()
[12234a: INFO] --- End of stack trace from previous location where exception was thrown ---
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12234a: INFO]    at Microsoft.Azure.WebJobs.Host.Listeners.CompositeListener.<StartAsync>d__4.MoveNext()
[12234a: INFO] --- End of stack trace from previous location where exception was thrown ---
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12234a: INFO]    at Microsoft.Azure.WebJobs.Host.Listeners.CompositeListener.<StartAsync>d__4.MoveNext()
[12234a: INFO] --- End of stack trace from previous location where exception was thrown ---
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[12234a: INFO]    at Microsoft.Azure.WebJobs.Host.Listeners.ListenerFactoryListener.<StartAsyncCore>d__8.MoveNext()
[12234a: INFO] --- End of stack trace from previous location where exception was thrown ---
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[12234a: INFO]    at System.Runtime.CompilerServices.TaskAwaiter.H
[12234a: SYS ERR ] Job failed due to exit code -1
[12234a: SYS INFO] Process went down, waiting for 60 seconds

疑问

是否存在未注意到的破坏性变更导致该问题?


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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.11 14:10:29