使用Visual Studio 2017为本地开发人员设置Azure Functions运行时版本

时间:2019-03-26 15:03:53

标签: azure azure-functions

AF运行时2.0.12332在VS 2017上本地工作。但是它自动更改为2.0.12353,它具有issues

如何通过本地站上的ctor更改为2.0.12332或其他支持DI的版本?

enter image description here

enter image description here 如果可能的话,可能的解决方案,但是我该如何实现呢?

1)在本地支持不同版本并运行特定版本,或者

2)卸载当前版本,然后重新安装corect版本

更新

由于缺乏IoC支持而导致的异常:

2019-03-15T01:28:45.311 [Error] Executed 'Test' (Failed, Id=6bdb0e8e-2353-4ed2-83ce-2a5288fd124d)
System.InvalidOperationException : Unable to resolve service for type 'ICar' while attempting to activate 'TestFunctions'.
   at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetService(IServiceProvider sp,Type type,Type requiredBy,Boolean isDefaultParameterRequired)
   at lambda_method(Closure ,IServiceProvider ,Object[] )
   at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IServiceProvider serviceProvider) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs : 42
   at Microsoft.Azure.WebJobs.Host.Executors.DefaultJobActivator.CreateInstance[T](IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\DefaultJobActivator.cs : 32
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.<>c__DisplayClass1_1.<.ctor>b__0(IFunctionInstanceEx i) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 20
   at Microsoft.Azure.WebJobs.Host.Executors.ActivatorInstanceFactory`1.Create(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\ActivatorInstanceFactory.cs : 26
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.CreateInstance(IFunctionInstanceEx functionInstance) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionInvoker.cs : 44
   at Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ParameterHelper.Initialize() at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 845
   at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsyncCore(IFunctionInstanceEx functionInstance,CancellationToken cancellationToken) at C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Executors\FunctionExecutor.cs : 116

要解决Azure Functions上的运行时问题,请参阅Depdency Injection and Logging start failing suddently without code changes when they were working properly with Azure Functions

1 个答案:

答案 0 :(得分:0)

要解决Azure Functions上的运行时问题,请参阅Depdency Injection and Logging start failing suddently without code changes when they were working properly with Azure Functions

解决方案1 ​​

1下载此 https://github.com/Azure/azure-functions-core-tools/releases/tag/2.4.419

2将第1步中的文件替换为以下

%AppData%\..\Local\AzureFunctionsTools\Releases\2.18.4\cli

2.18.4可能与您当前的文件夹不同。选中它以查看您当前的文件夹

enter image description here

Soluton 2

1从此处https://github.com/Azure/azure-functions-core-tools/releases下载并提取最新的x64 1.x版本

2右键单击项目的“属性”->“调试”

3将“启动”更改为“可执行文件”,然后放置下载的x64 func.exe的路径

4将应用程序参数设置为主机启动

5 F5

enter image description here