簡體   English   中英

使用 .NET Core 2 的 Azure WebJobs 因“存儲帳戶無效”而失敗

[英]Azure WebJobs using .NET Core 2 failing with "Invalid storage account"

遵循 Matt Roberts 出色的分步文章Azure WebJobs in .NET Core 2 (with DI and configuration),我創建了一個部署沒有問題的解決方案(使用 Visual Studio 2017),但因“無效存儲帳戶”異常而失敗:

Unhandled Exception: System.InvalidOperationException: Invalid storage account 'mywebjobsstorage'. Please make sure your credentials are correct. ---> System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task`1<Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties> Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.GetServicePropertiesAsync(System.Threading.CancellationToken)'.

我可以看到 AzureWebJobsDashboard 和 AzureWebJobsStorage 環境變量必須被拾取,因為錯誤明確命名了連接字符串中使用的 AccountName。

我用存儲連接字符串嘗試了兩種變體,結果相同:

DefaultEndpointsProtocol=https;AccountName=mywebjobsstorage;AccountKey=********

DefaultEndpointsProtocol=https;AccountName=mywebjobsstorage;AccountKey=********;EndpointSuffix=core.windows.net

任何想法可能是什么問題?

這是完整的異常日志,以防它包含任何其他線索,或者我被誤導了:

[03/29/2018 07:52:43 > d801c3: SYS INFO] Status changed to Initializing
[03/29/2018 07:52:48 > d801c3: SYS INFO] Run script 'run.cmd' with script host - 'WindowsScriptHost'
[03/29/2018 07:52:48 > d801c3: SYS INFO] Status changed to Running
[03/29/2018 07:52:48 > d801c3: INFO] 
[03/29/2018 07:52:48 > d801c3: INFO] D:\local\Temp\jobs\triggered\MyWebJobs\uoyrr1m3.5sq>dotnet MyWebJobs.dll 
[03/29/2018 07:52:50 > d801c3: ERR ] 
[03/29/2018 07:52:50 > d801c3: ERR ] Unhandled Exception: System.InvalidOperationException: Invalid storage account 'mywebjobsstorage'. Please make sure your credentials are correct. ---> System.MissingMethodException: Method not found: 'System.Threading.Tasks.Task`1<Microsoft.WindowsAzure.Storage.Shared.Protocol.ServiceProperties> Microsoft.WindowsAzure.Storage.Blob.CloudBlobClient.GetServicePropertiesAsync(System.Threading.CancellationToken)'.
[03/29/2018 07:52:50 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.Host.Storage.Blob.StorageBlobClient.GetServicePropertiesAsync(CancellationToken cancellationToken)
[03/29/2018 07:52:50 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.Host.Executors.DefaultStorageCredentialsValidator.<ValidateCredentialsAsyncCore>d__1.MoveNext()
[03/29/2018 07:52:50 > d801c3: ERR ]    --- End of inner exception stack trace ---
[03/29/2018 07:52:50 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.Host.Executors.DefaultStorageCredentialsValidator.<ValidateCredentialsAsyncCore>d__1.MoveNext()
[03/29/2018 07:52:50 > d801c3: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/29/2018 07:52:50 > d801c3: ERR ]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[03/29/2018 07:52:50 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/29/2018 07:52:50 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/29/2018 07:52:50 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.Host.Executors.DefaultStorageCredentialsValidator.<ValidateCredentialsAsync>d__0.MoveNext()
[03/29/2018 07:52:50 > d801c3: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/29/2018 07:52:50 > d801c3: ERR ]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[03/29/2018 07:52:50 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/29/2018 07:52:50 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/29/2018 07:52:50 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.Host.Executors.DefaultStorageAccountProvider.<CreateAndValidateAccountAsync>d__24.MoveNext()
[03/29/2018 07:52:50 > d801c3: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.Host.Executors.DefaultStorageAccountProvider.<TryGetAccountAsync>d__25.MoveNext()
[03/29/2018 07:52:51 > d801c3: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.Host.Executors.JobHostConfigurationExtensions.<CreateJobHostContextAsync>d__1.MoveNext()
[03/29/2018 07:52:51 > d801c3: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.JobHost.<InitializeHostAsync>d__44.MoveNext()
[03/29/2018 07:52:51 > d801c3: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.JobHost.<StartAsyncCore>d__25.MoveNext()
[03/29/2018 07:52:51 > d801c3: ERR ] --- End of stack trace from previous location where exception was thrown ---
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
[03/29/2018 07:52:51 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.JobHost.Start()
[03/29/2018 07:52:51 > d801c3: ERR ]    at Microsoft.Azure.WebJobs.JobHost.RunAndBlock()
[03/29/2018 07:52:51 > d801c3: ERR ]    at MyWebJobs.Program.Main(String[] args) in C:\!Projects\SomeProject\src\MyWebJobs\Program.cs:line 30
[03/29/2018 07:52:51 > d801c3: SYS INFO] Status changed to Failed
[03/29/2018 07:52:51 > d801c3: SYS ERR ] Job failed due to exit code -532462766

看起來這些 NuGet 包中的任何一個都存在錯誤:

  • Microsoft.Azure.WebJobs
  • Microsoft.Azure.WebJobs.Extensions

我正在使用這些軟件包的 v2.2.0,但它們似乎有一個錯誤。 在沒有任何代碼更改的情況下將這些替換為 NuGet 包的 v3 beta 預發行版解決了該問題。

更新

.NET Core 僅支持 v3+ - https://github.com/Azure/azure-webjobs-sdk/issues/1649#issuecomment-377633805

我們最近在我們的一項網絡工作中遇到了類似的問題,該工作早些時候運行良好,但突然停止工作。 Web 作業嘗試每分鍾重新啟動一次,但失敗並顯示錯誤消息Invalid storage account ABStorage 請確保您的憑據正確無誤。 Web 作業仍處於Pending Restart狀態。 經過調查,我們發現存儲連接字符串完全正常,而 Azure 存儲 SDK 中存在一些錯誤,這是由於 Azure 門戶上針對存儲帳戶配置的 CORS 規則沒有被正確解釋。 在 Azure 門戶中,我們在 Azure 存儲上只有 1 個 CORS 規則,並選擇了所有允許的 HTTP 方法。 單行中的所有 7 個 HTTP 方法 我們更新了存儲帳戶上的 CORS 規則,使每個域都有一個 HTTP 方法,並且 Web 作業能夠立即啟動。 連續只有一個 HTTP 方法

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM