【问题标题】:Azure Functions locally "The system cannot find the file specified" during TypeScriptCompiler.CompileAsync()在 TypeScriptCompiler.CompileAsync() 期间本地 Azure Functions “系统找不到指定的文件”
【发布时间】:2017-12-25 18:09:44
【问题描述】:

我在 VS Code 和 Node 8.9.3 中本地运行 azure 工具,并使用“func new”创建的 Typescript 2.6.2 Azure 函数。我不得不将"scriptFile": "index.ts", 添加到function.json 中才能做到这一点——否则它会抱怨找不到主脚本。但是现在它似乎在所有注册中都成功了——在不存在的路由上适当地 404ing,但是当我使用 Postman 发布到它或从浏览器 GET 时它会发出这个:

{
    "id": "952c0946-bd72-49e7-9f25-c3a8ba8ca236",
    "requestId": "954642f2-9b17-43a2-b26f-b63615360301",
    "statusCode": 500,
    "errorCode": 0,
    "message": "Exception while executing function: Functions.CreateAccount -> The system cannot find the file specified",
    "errorDetails": "Microsoft.Azure.WebJobs.Host.FunctionInvocationException : Exception while executing function: Functions.CreateAccount ---> System.ComponentModel.Win32Exception : The system cannot find the file specified
        at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
        at System.Diagnostics.Process.Start()
        at Microsoft.Azure.WebJobs.Script.Description.Node.TypeScript.TypeScriptCompiler.CompileAsync(String inputFile,TypeScriptCompilationOptions options)
        at async Microsoft.Azure.WebJobs.Script.Description.Node.TypeScript.TypeScriptCompilation.CompileAsync(??)
        at async Microsoft.Azure.WebJobs.Script.Description.Node.TypeScript.TypeScriptCompilation.CompileAsync(??)
        at async Microsoft.Azure.WebJobs.Script.Description.Node.TypeScript.TypeScriptCompilationService.GetFunctionCompilationAsync(FunctionMetadata functionMetadata)
        at async Microsoft.Azure.WebJobs.Script.Description.ConditionalJavaScriptCompilationService.GetFunctionCompilationAsync(FunctionMetadata functionMetadata)
        at async Microsoft.Azure.WebJobs.Script.Description.NodeFunctionInvoker.CompileAndTraceAsync(LogTargets logTargets,Boolean throwOnCompilationError,Boolean suppressCompilationSummary)
        at async Microsoft.Azure.WebJobs.Script.Description.NodeFunctionInvoker.CreateFunctionTarget(CancellationToken cancellationToken)
        at async Microsoft.Azure.WebJobs.Script.Description.FunctionLoader`1.GetFunctionTargetAsync[T](Int32 attemptCount)
        at async Microsoft.Azure.WebJobs.Script.Description.NodeFunctionInvoker.GetFunctionTargetAsync()
        at async Microsoft.Azure.WebJobs.Script.Description.NodeFunctionInvoker.InvokeCore(Object[] parameters,FunctionInvocationContext context)
        at async Microsoft.Azure.WebJobs.Script.Description.FunctionInvokerBase.Invoke(Object[] parameters)
        at async Microsoft.Azure.WebJobs.Host.Executors.VoidTaskMethodInvoker`2.InvokeAsync[TReflected,TReturnType](TReflected instance,Object[] arguments)
        at async Microsoft.Azure.WebJobs.Host.Executors.FunctionInvoker`2.InvokeAsync[TReflected,TReturnValue](Object instance,Object[] arguments)
        at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.InvokeAsync(IFunctionInvoker invoker,ParameterHelper parameterHelper,CancellationTokenSource timeoutTokenSource,CancellationTokenSource functionCancellationTokenSource,Boolean throwOnTimeout,TimeSpan timerInterval,IFunctionInstance instance)
        at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithWatchersAsync(IFunctionInstance instance,ParameterHelper parameterHelper,TraceWriter traceWriter,CancellationTokenSource functionCancellationTokenSource)
        at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
        at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??) 
        End of inner exception
        at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
        at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.ExecuteWithLoggingAsync(??)
        at async Microsoft.Azure.WebJobs.Host.Executors.FunctionExecutor.TryExecuteAsync(IFunctionInstance functionInstance,CancellationToken cancellationToken)
        at Microsoft.Azure.WebJobs.Host.Executors.ExceptionDispatchInfoDelayedException.Throw()
        at async Microsoft.Azure.WebJobs.JobHost.CallAsync(??)
        at async Microsoft.Azure.WebJobs.Script.ScriptHost.CallAsync(String method,Dictionary`2 arguments,CancellationToken cancellationToken)
        at async Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostManager.HandleRequestAsync(FunctionDescriptor function,HttpRequestMessage request,CancellationToken cancellationToken)
        at async Microsoft.Azure.WebJobs.Script.Host.FunctionRequestInvoker.ProcessRequestAsync(HttpRequestMessage request,CancellationToken cancellationToken,WebScriptHostManager scriptHostManager,WebHookReceiverManager webHookReceiverManager)
        at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.<>c__DisplayClass3_0.<ExecuteAsync>b__0(??)
        at async Microsoft.Azure.WebJobs.Extensions.Http.HttpRequestManager.ProcessRequestAsync(HttpRequestMessage request,Func`3 processRequestHandler,CancellationToken cancellationToken)
        at async Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.ExecuteAsync(HttpControllerContext controllerContext,CancellationToken cancellationToken)
        at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
        at async System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
        at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.WebScriptHostHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
        at async Microsoft.Azure.WebJobs.Script.WebHost.Handlers.SystemTraceHandler.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)
        at async System.Web.Http.HttpServer.SendAsync(HttpRequestMessage request,CancellationToken cancellationToken)"
}

Typescript 在本地也能很好地处理其他事情。其他人遇到这个错误吗?我该如何解决?

【问题讨论】:

    标签: azure azure-functions


    【解决方案1】:

    我认为 Azure Functions 无法识别 Typescript 文件。在运行之前,您可能需要通过tsc 命令将您的 ts 代码编译成 javascript。

    你也可以按照这个文档来编译和运行它: https://github.com/TsuyoshiUshio/TypeScriptCosmosSpike#compile-typescript

    【讨论】:

    • 谢谢。也许你是对的,但有一些迹象表明 typescript 应该可以工作:1) 2.0 运行时的known issues docs 表示 Typescript 尚未迁移。 2) This article 说您必须选择加入 到 2.x 运行时。 3)异常的堆栈跟踪确实涉及typescript编译,所以它似乎知道它需要做什么。
    • 哦,还有 4) azure cli func new 提供 typescript 作为语言选择。
    • 功能团队成员在这里。 Functions 在预览版中确实支持 TypeScript,但我们已经讨论过弃用它。您无法提供自己的 tsconfig.json,因此您不必确保完全正确地设置它,这有点麻烦。以我的经验,最好事先转译为 JS 并自己控制配置。总的来说,我认为由于这些怪癖,我们翻译 TS 并没有变得更容易。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-21
    相关资源
    最近更新 更多