Azure函数本地“系统找不到指定的文件”在TypeScriptCompiler.CompileAsync()期间

问题描述 投票:0回答:1

我在VS Code和Node 8.9.3中本地运行azure工具,并使用“func new”创建了Typescript 2.6.2 Azure Function。我不得不将"scriptFile": "index.ts",添加到function.json甚至到目前为止 - 否则它抱怨它无法找到主脚本。但现在它似乎在所有注册中都取得了成功 - 在不存在的路由上适当地进行了404,但是当我使用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个回答
1
投票

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

您可以按照此文档编译并运行它:https://github.com/TsuyoshiUshio/TypeScriptCosmosSpike#compile-typescript

© www.soinside.com 2019 - 2024. All rights reserved.