我的代码:
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
namespace sampleapplication
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([BlobTrigger("testcontainer/{name}", Connection = "")]Stream myBlob, string name, ILogger log)
{
log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
}
}
}
在运行应用程序时,
[30-01-2019 10:56:19] Run:
Microsoft.Azure.WebJobs.Host: Error indexing method 'Function1.Run'.
Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'log' to type ILogger.
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.).
TraceWritter是默认设置,但跟踪编写器的单元测试用例无法执行。 所以我搜索了许多他们更喜欢Ilogger的网站。
如何在Azure Function App中初始化Ilogger?