2016-04-22 50 views
0

我有一個在本地服務器上運行的webjob(即不在Azure上託管)。它可以從隊列中得很好的工作,並沒有問題,處理它們,但我發現以下異常時處理完隊列作業:404 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

對不起,是的,更改設置意味着更改配置文件中的連接字符串,沒有其他設置或代碼被更改。我編輯了這個問題來澄清。 –

+0

你有沒有解決這個問題? –

回答

0

未處理的異常:Microsoft.WindowsAzure.Storage.StorageException

這意味着你沒有正確配置存儲。 Web作業需要在app.config中設置兩個appSettings AzureWebJobsDashboard,AzureWebJobsStorage

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

此外,該設置可能指向相同的Blob存儲,Web作業將創建所需的文件夾並寫入它們。

Webjob正在寫日誌和一些其他的東西,Blob存儲,這就是爲什麼,因爲它嘗試將數據寫入失敗,但不能訪問存儲

+0

我在配置文件中都有這些設置,並且使用相同的設置,應用可以在其他機器上正常運行,所以我不認爲這是配置問題。 –

0

我的Microsoft.Azure.WebJobs更新NuGet包新1.1.2版本,它現在似乎工作正常。

編輯 查看更新的問題。這個答案不再有效

相關問題