按照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
答案 0 :(得分:1)
看起来这些NuGet包中都有一个错误:
我使用的是这些软件包的v2.2.0,但它们似乎有一个bug。将这些替换为NuGet包的v3 beta预发行版而不进行任何代码更改解决了这个问题。
<强>更新强>
.NET Core上仅支持v3 + - https://github.com/Azure/azure-webjobs-sdk/issues/1649#issuecomment-377633805