gpt4 book ai didi

c# - 使用 .NET Core 2 的 Azure WebJobs 失败并显示 "Invalid storage account"

转载 作者:行者123 更新时间:2023-12-02 23:00:27 24 4
gpt4 key购买 nike

遵循 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

关于c# - 使用 .NET Core 2 的 Azure WebJobs 失败并显示 "Invalid storage account",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49551078/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com