我在内部服务器上运行webjob(即不在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帐户上的设置有问题,但我不明白为什么它运行时不是问题在其他机器上。
我目前正在使用Microsoft.Azure.WebJobs的v1.1.0和WindowsAzure.Storage的v7.0.0。我使用WindowsAzure.Storage的v5.0.2版本的Microsoft.Azure.WebJobs v1.1.1得到了相同的结果。
我已按照问题Azure Web Job-The remote server returned 404中的建议进行操作,并确认我已设置了这4个blob容器。
修改 我将microsoft.azure.webjobs nuget包更新到1.1.2,这似乎解决了上述问题,但在愉快地运行了2周后,错误突然重新出现。没有代码更改或重新部署;工作正常的代码无缘无故停止工作,据我所知,我们的Azure帐户没有变化。我已将配置文件更改为指向不同的Azure帐户,并且它再次正常工作。
有关导致404的原因的任何建议?
答案 0 :(得分:0)
未处理的异常:Microsoft.WindowsAzure.Storage.StorageException
这意味着您尚未正确配置存储空间。 Web作业需要在app.config AzureWebJobsDashboard , AzureWebJobsStorage 中设置两个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存储,这就是它失败的原因,因为它试图写入数据,但无法访问存储
答案 1 :(得分:0)
我已将Microsoft.Azure.WebJobs nuget软件包更新到新的1.1.2版本,现在看起来工作正常。
修改强> 查看更新的问题。这个答案不再有效