基于计时器的Azure函数抱怨日志类型

基于计时器的Azure函数抱怨日志类型,azure,azure-functions,Azure,Azure Functions,我和你的问题完全一样 但是这些答案都不起作用,谷歌搜索了很长一段时间,我的版本也在更新,等等,但我还是犯了同样的错误 代码是示例模板 using System; using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Host; namespace NWMPosNGPimFeeder { public static class Function1 { [FunctionName("Function

我和你的问题完全一样

但是这些答案都不起作用,谷歌搜索了很长一段时间,我的版本也在更新,等等,但我还是犯了同样的错误

代码是示例模板

using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;

namespace NWMPosNGPimFeeder
{
    public static class Function1
    {
        [FunctionName("Function1")]
        public static void Run([TimerTrigger("0 */1 * * * *")]TimerInfo myTimer, TraceWriter log)
        {
            log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
        }
    }
}
主机etc的版本如下,包括实际错误

[21/5/2018 2:03:29 AM] Host has been specialized
Listening on http://localhost:7071/
Hit CTRL-C to exit...
[21/5/2018 2:03:29 AM] Reading host configuration file 'C:\Users\MattDouhan\source\repos\NWMPosNGPimFeeder\NWMPosNGPimFeeder\bin\Debug\net461\host.json'
[21/5/2018 2:03:29 AM] Host configuration file read:
[21/5/2018 2:03:29 AM] {
[21/5/2018 2:03:29 AM] }
[21/5/2018 2:03:30 AM] Loaded custom extension 'BotFrameworkConfiguration'
[21/5/2018 2:03:30 AM] Loaded custom extension 'SendGridConfiguration'
[21/5/2018 2:03:30 AM] Loaded custom extension 'EventGridExtensionConfig'
[21/5/2018 2:03:31 AM] Generating 1 job function(s)
[21/5/2018 2:03:31 AM] Starting Host (HostId=desktop7cks1do-1972353084, Version=1.0.11232.0, ProcessId=2668, Debug=False, Attempt=0)
[21/5/2018 2:03:31 AM] A ScriptHost error has occurred
[21/5/2018 2:03:31 AM] Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1.Run'. Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type TraceWriter. Make sure the parameter Type is supported by the binding. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
[21/5/2018 2:03:31 AM] Error indexing method 'Function1.Run'

问题出现在cli VS使用的旧函数上

版本=1.0.11232.0

这意味着cli版本为
1.0.4
。此旧版本确实会导致您的问题,但已在新版本中修复

检查您的
Azure功能和Web作业工具
版本

如果VS未能下载新版本cli,则最新扩展名
15.0.40502.0
,将使VS使用cli
1.0.4
。此下载过程处于后台,似乎没有明确的警告。看

解决方案

我建议您删除
C:\Users\UserName\AppData\Local\AzureFunctionsTools
文件夹,然后重新启动VS以再次下载它

当我们创建函数应用程序时,我们可以在对话框上看到提示,确保所有模板都是最新的…

等一下,我们可以看到提示的变化如下

如果在3m之后(您需要下载2亿个文件),它没有改变,请检查
C:\Users\UserName\AppData\Local\AzureFunctionsTools\Releases\1.0.12.1
文件夹以查看它是否为空。如果它是空的,这意味着下载不能通过VS完成。我们必须手动完成

您可以在
C:\Users\UserName\AppData\Local\AzureFunctionsTools\feed.json中找到cli、itemTemplates和projectTemplates的下载链接


您可以参考
1.0.10
文件夹来构建类似的文件夹结构。

您能否提供一些信息,如您的函数应用程序版本(v1或v2)、cli、主机版本。请参见示例>添加到问题中我有点困惑抱歉,我有Microsoft.net.sdk.functions 1.0.13您是说另一个nuget软件包吗?O我不确定如何确切地检查您所指的内容to@MattDouhan你的意思是不确定如何检查Azure功能和Web作业工具的版本?是的,但没关系,我删除了文件夹并在下载新版本后重新启动了vola。它工作正常:)