我已經寫了預編譯Azure的功能在Visual Studio 2017年在C#以下步驟項目描述here或here的參數未初始化。我想申請洞察通過Microsoft.Extensions.Logging.ILogger界面登錄,以取代TraceWriter
記錄。對於我更新了Microsoft.Azure.WebJobs NuGet包到2.1.0-beta1版本,其包括ILogger結合,使直接結合到應用程序數據分析記錄器。我還添加了應用程序設置APPINSIGHTS_INSTRUMENTATIONKEY
和一個有效的應用程序見解工具密鑰。與參數代替我的函數的參數TraceWriter
後,我觸發功能,並收到以下錯誤響應:ILogger例如在預編譯Azure的功能
{
"id": "497256d0-1c3a-4a10-a1cc-41b771305338",
"requestId": "e546219e-7e38-4fa7-80cf-b06e0b8f4018",
"statusCode": 500,
"errorCode": 0,
"messsage": "Exception while executing function: Functions.HelloHttpTrigger -> Exception binding parameter 'log' -> No value was provided for parameter 'log'.",
"errorDetails": "Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.HelloHttpTrigger ---> System.InvalidOperationException : Exception binding parameter 'log' ---> System.InvalidOperationException : No value was provided for parameter 'log'.\r\n at Microsoft.Azure.WebJobs.Host.Bindings.Invoke.ClassInvokeBinding`1.BindAsync(BindingContext context)\r\n at async Microsoft.Azure.WebJobs.Host.Triggers.TriggeredFunctionBinding`1.BindCoreAsync[TTriggerValue](ValueBindingContext context,Object value,IDictionary`2 parameters) \r\n End of inner exception\r\n at Microsoft.Azure.WebJobs.Host.Executors.DelayedException.Throw()\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,IReadOnlyDictionary`2 parameters,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) \r\n End of inner exception\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)\r\n at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)\r\n at Microsoft.Azure.WebJobs.Host.Executors.ExceptionDispatchInfoDelayedException.Throw()\r\n at async Microsoft.Azure.WebJobs.JobHost.CallAsyncCore(MethodInfo method,IDictionary`2 arguments,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.ScriptHost.CallAsync(String method,Dictionary`2 arguments,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostManager.HandleRequestAsync(FunctionDescriptor function,HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken)\r\n at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.SystemTraceHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.WebScriptHostHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)\r\n at async System.Web.Http.HttpServer.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)"
}
所以不能創建的實例。但是,如果我使用函數腳本創建項目而不是預編譯函數,那麼ILogger實例將正確實例化。這是否意味着ILogger的實例化只適用於函數腳本?我希望情況並非如此,那麼我應該如何增加預編譯函數的設置才能使其工作?
你見過https://stackoverflow.com/a/46471220/1171619? – Mikhail