0

I have a webjob running on a server on premise (i.e. not hosted on Azure). It can get jobs from the queue fine, and processes them with no problem but I'm getting the following exception when it has finished processing a job on the queue:

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()

The webjob runs fine on my dev machine, and on another PC but gets the exception on a Windows 2012 R2 server. If I change the connection strings to read from a queue in a different Azure account it works fine, so I guess there is something wrong with the settings on my main Azure account, but I don't understand why its not a problem when it runs on other machines.

I am currently using v1.1.0 of the Microsoft.Azure.WebJobs with v7.0.0 of WindowsAzure.Storage. I get the same results with v1.1.1 of the Microsoft.Azure.WebJobs with v5.0.2 of WindowsAzure.Storage.

I have followed the suggestions in the question Azure Web Job-The remote server returned 404 and can confirm I have the those 4 blob containers set up.

Edit I updated the microsoft.azure.webjobs nuget package to 1.1.2 and this seemed to fix the above problem, but after running happily for 2 weeks the error suddenly re appeared. There was no code change or re deployment; the code that was working fine just stopped working for no reason, and as far as I know there was no change to our Azure account. I have changed the config file to point to a different Azure account and again it works fine.

Any suggestions on what is causing the 404?

Community
  • 1
  • 1
Jon Clarke
  • 366
  • 2
  • 14

2 Answers2

1

Unhandled Exception: Microsoft.WindowsAzure.Storage.StorageException

This means that you have not configured properly storage. Web job require to set two appSettings in app.config AzureWebJobsDashboard, AzureWebJobsStorage .

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

Also that settings could point to same blob storage, web job will create required folders and write to them.

Webjob is writing logs and some other stuff to blob storage that is why it fails because it tries to write data, but cant access storage

Vova Bilyachat
  • 18,765
  • 4
  • 55
  • 80
  • I had both those settings in my config file, and with the same settings the app could run fine on other machines so I don't think it was a config issue. – Jon Clarke Apr 25 '16 at 08:43
  • This is the correct answer. We noticed these were required in the App.config but when deployed to Azure, they needed to be set on the App Service. See: https://stackoverflow.com/a/63925646/3417242 – Ryan D Sep 16 '20 at 18:09
0

I've updated the Microsoft.Azure.WebJobs nuget package to the new 1.1.2 version and it seems to be working fine now.

Edit See updated question. This answer is no longer valid

Jon Clarke
  • 366
  • 2
  • 14