【问题标题】:404 Not Found exception when webjob has completed processing job on Azure queue当 webjob 完成 Azure 队列上的处理作业时出现 404 Not Found 异常
【发布时间】:2016-05-12 23:04:34
【问题描述】:

我有一个在本地服务器上运行的网络作业(即未托管在 Azure 上)。它可以很好地从队列中获取作业,并且可以毫无问题地处理它们,但是当它完成队列中的作业处理时出现以下异常:

Unhandled Exception: Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (404) Not Found. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
   at Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpResponseParsers.ProcessExpectedStatusCodeNoException[T](HttpStatusCode expectedStatusCode, HttpStatusCode actualStatusCode, T retVal, StorageCommandBase`1 cmd, Exception ex)
   at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.<DeleteBlobImpl>b__29(RESTCommand`1 cmd, HttpWebResponse resp, Exception ex, OperationContext ctx)
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndGetResponse[T](IAsyncResult getResponseResult)
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result)
   at Microsoft.WindowsAzure.Storage.Blob.CloudBlob.EndDelete(IAsyncResult asyncResult)
   at Microsoft.WindowsAzure.Storage.Core.Util.AsyncExtensions.<>c__DisplayClass4.<CreateCallbackVoid>b__3(IAsyncResult ar)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Host.Protocols.PersistentQueueWriter`1.<DeleteAsync>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Host.Loggers.CompositeFunctionInstanceLogger.<DeleteLogFunctionStartedAsync>d__e.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.<TryExecuteAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Host.Executors.TriggeredFunctionExecutor`1.<TryExecuteAsync>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Host.Queues.Listeners.QueueTriggerExecutor.<ExecuteAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.WebJobs.Host.Queues.Listeners.QueueListener.<ProcessMessageAsync>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.Azure.WebJobs.Host.Timers.BackgroundExceptionDispatcher.<>c__DisplayClass1.<Throw>b__0()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

webjob 在我的开发机器和另一台 PC 上运行良好,但在 Windows 2012 R2 服务器上出现异常。如果我将连接字符串更改为从不同 Azure 帐户中的队列读取,它工作正常,所以我猜我的主 Azure 帐户上的设置有问题,但我不明白为什么它在运行时没有问题在其他机器上。

我目前正在使用 v1.1.0 的 Microsoft.Azure.WebJobs 和 v7.0.0 的 WindowsAzure.Storage。我使用 Microsoft.Azure.WebJobs 的 v1.1.1 和 WindowsAzure.Storage 的 v5.0.2 得到相同的结果。

我已按照问题 Azure Web Job-The remote server returned 404 中的建议进行操作,并且可以确认我已设置了这 4 个 blob 容器。

编辑 我将 microsoft.azure.webjobs nuget 包更新为 1.1.2,这似乎解决了上述问题,但是在愉快地运行 2 周后,错误突然重新出现。没有代码更改或重新部署;运行良好的代码无缘无故停止工作,据我所知,我们的 Azure 帐户没有任何变化。我已将配置文件更改为指向不同的 Azure 帐户,并且再次正常工作。

关于导致 404 的原因有什么建议吗?

【问题讨论】:

  • 你能分享一个代码吗? “更改设置”意味着只是更改连接,还是其他?
  • 抱歉,是的,更改设置意味着更改配置文件中的连接字符串,没有更改其他设置或代码。我已经编辑了问题以澄清。
  • 你解决过这个问题吗?

标签: c# azure azure-webjobs azure-webjobssdk


【解决方案1】:

未处理的异常:Microsoft.WindowsAzure.Storage.StorageException

这意味着您没有正确配置存储。 Web 作业需要在 app.config AzureWebJobsDashboardAzureWebJobsStorage 中设置两个 appSettings。

<add name="AzureWebJobsDashboard" connectionString="DefaultEndpointsProtocol=https;AccountName=ACCOUNTNAME;AccountKey=ACCOUNTKEY" />
<add name="AzureWebJobsStorage" connectionString="DefaultEndpointsProtocol=https;AccountName=ACCOUNTNAME;AccountKey=ACCOUNTKEY" />

此外,设置可以指向相同的 blob 存储,Web 作业将创建所需的文件夹并写入它们。

Webjob 正在将日志和其他一些内容写入 blob 存储,这就是它失败的原因,因为它尝试写入数据,但无法访问存储

【讨论】:

  • 我的配置文件中有这两个设置,并且使用相同的设置,应用程序可以在其他机器上正常运行,所以我认为这不是配置问题。
  • 这是正确答案。我们注意到这些在 App.config 中是必需的,但是当部署到 Azure 时,它​​们需要在应用服务上进行设置。见:stackoverflow.com/a/63925646/3417242
【解决方案2】:

我已将 Microsoft.Azure.WebJobs nuget 包更新为新的 1.1.2 版本,现在似乎可以正常工作了。

编辑 请参阅更新的问题。此答案不再有效

【讨论】:

    猜你喜欢
    • 2016-09-15
    • 2023-04-07
    • 1970-01-01
    • 2012-12-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-12
    相关资源
    最近更新 更多