【问题标题】:Azure Web Job-The remote server returned 404Azure Web Job-远程服务器返回404
【发布时间】:2015-09-24 08:06:41
【问题描述】:

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

当网络作业停止一个进程时,它会在过去 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 块不会重新抛出异常,而只是记录堆栈跟踪并继续。

编辑

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

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

【问题讨论】:

  • 你能检查失败的 blob 的容器名称吗?
  • 我没有创建任何容器,也没有尝试删除任何内容。我不知道网络作业试图删除什么。我也没有任何 blob 触发器。存储具有由 azure webjob sdk 创建的默认容器

标签: azure-webjobs azure-webjobssdk


【解决方案1】:

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

当我最初尝试它时,我先发布了它,它就像一个魅力。第二个项目,我的做法不同,所以我先运行了控制台应用程序,它一直以 404 失败。

所以,你需要创建:

  • azure-webjobs-dashboard
  • azure-webjobs-hosts
  • azure-jobs-hosts-archive
  • azure-jobs-hosts-输出

希望对某人有所帮助。

【讨论】:

  • 我会添加..如果你想在 C# CloudStorageAccount storageAccount =...; CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); //这个容器是 companystyles blobClient.GetContainerReference("azure-webjobs-dashboard").CreateIfNotExists(); blobClient.GetContainerReference("azure-webjobs-hosts").CreateIfNotExists(); blobClient.GetContainerReference("azure-jobs-hosts-archive").CreateIfNotExists(); blobClient.GetContainerReference("azure-jobs-hosts-output").CreateIfNotExists();
【解决方案2】:

我遇到了同样的错误。

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

【讨论】:

    【解决方案3】:

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

    我们的解决方案是通过我们的 ARM 模板将 AzureWebJobsStorage 和 AzureWebJobsDashboard 连接字符串添加到应用服务的连接字符串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"
            }
    

    这些值已经存在于应用服务的应用设置配置中,这一定是它之前的运行方式。

    我们确实根据其他建议更新了有关此问题的其他答案的库。仅凭这一点并没有解决它。 我们还将 WebJob 从 .Net Framework 4.5 迁移到 4.6 以匹配解决方案的其余部分,但我不认为这真的是修复的一部分,仅供参考,以防它对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-20
      • 2018-04-17
      • 2010-11-07
      • 1970-01-01
      相关资源
      最近更新 更多