Azure Web作业 - 远程服务器返回404

时间:2015-09-24 08:06:42

标签: azure-webjobs azure-webjobssdk

我有一个连续运行的Web作业,它侦听start队列和一个停止queue及其各自的功能。 Web作业中有3个预定义进程,start队列包含一条消息,该消息提到要启动的进程名称,而stop队列包含一条消息,提示要停止进程名称。

当webjob停止进程时,它会在过去4周内因上述异常而崩溃并重新启动。

Executing: 'Functions.StartProcess' because New queue message detected on 'start'.
Updated the status of Process A to 1
Process A Started
Process A processed 200 records
Process A processed 200 records
Process A processed 200 records
Process A processed 200 records
Process A processed 200 records
Executing: 'Functions.StopProcess' because New queue message detected on 'stop'.
Process A stopped
Disposed Process A
Updated the status of Process A to 3

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.CloudBlobSharedImpl.<DeleteBlobImpl>b__1b(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.CloudBlockBlob.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.Queues.Listeners.QueueTriggerExecutor.<ExecuteAsync>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.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甚至不包含任何删除blob文件的代码。

在调试时,调试器在抛出异常时没有指向任何特定的行,因此我不知道实际原因是什么。

PS :它曾经在此之前完美运行,并且每个函数的主体都包含在try catch块中。 catch块不会重新抛出异常,只是记录stacktrace并继续。

修改

我必须检查下面的容器是否在那里

enter image description here

在webjob的存储空间中,还更新了Microsoft.Web.WebJobs.Publish nuget包。 我真的不确定这是否可以解决问题,但

3 个答案:

答案 0 :(得分:6)

看起来你是对的,你确实需要手动创建blob容器,发布web作业,在这种情况下它看起来像环境将为您创建容器。

当我最初尝试时,我首先做了发布,它就像一个魅力。第二个项目,我的方式不同,所以我先运行控制台应用程序,然后继续使用404.

所以,你需要创建:

  • 天青-webjobs的仪表板
  • 天青-webjobs的主机
  • 天青的作业的主机 - 归档
  • 天青的作业的主机输出

希望它有所帮助。

答案 1 :(得分:0)

我收到同样的错误。

对我来说有用的是将我的WindowsAzure.Storage包从4.3.0更新为7.1.2,但我会使用最新的或其他任何WebJobs正在使用的包(如果它们正在运行)没问题)。

答案 2 :(得分:0)

我们的WebJob在星期五下午中旬遇到了此问题。之前的部署是在9天之前完成的,WebJob正常运行直到突然没有运行。不知道为什么它停止工作。 经过大量阅读后,我相信这只是意味着它在初始化WebJob时由于某种原因无法连接到存储帐户。

我们的解决方案是通过我们的ARM模板将AzureWebJobsStorage和AzureWebJobsDashboard连接字符串添加到App Service的连接字符串config中。

       "AzureWebJobsDashboard": {
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccount'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]",
          "type": "Custom"
        },
        "AzureWebJobsStorage": {
          "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccount'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccount')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]",
          "type": "Custom"
        }

这些值已经存在于App Service的应用程序设置配置中,该设置必须是其先前的工作方式。

我们确实针对其他建议更新了库,以解决此问题。仅凭这一点并不能解决问题。 我们也将WebJob从.Net Framework 4.5迁移到4.6,以与该解决方案的其余部分匹配,尽管我认为这并不是真正的解决方案,只是仅供参考,以防它对某人有所帮助。