Azure Function Node.js Failed to start a new language worker for runtime: node - node.js

I unexpectedly began receiving a 502 Bad Gateway error for all of my HTTP-triggered functions in an Azure Function app that has been running successfully for the past few months.
After digging into the kudu logs, I found the following -
Failed to start a new language worker for runtime: node.
Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: Failure
Exception: Worker was unable to load entry point "index.js": Found zero files matching the supplied pattern
Stack: Error: Worker was unable to load entry point "index.js": Found zero files matching the supplied pattern
at C:\Program Files (x86)\SiteExtensions\Functions\4.12.0\workers\node\dist\src\worker-bundle.js:2:44797
at Generator.next (<anonymous>)
at o (C:\Program Files (x86)\SiteExtensions\Functions\4.12.0\workers\node\dist\src\worker-bundle.js:2:44124)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Grpc.GrpcWorkerChannel.StartWorkerProcessAsync(CancellationToken cancellationToken) at /_/src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs : 271
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcFunctionInvocationDispatcher.InitializeJobhostLanguageWorkerChannelAsync(??) at /_/src/WebJobs.Script/Workers/Rpc/FunctionRegistration/RpcFunctionInvocationDispatcher.cs : 154
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcFunctionInvocationDispatcher.InitializeJobhostLanguageWorkerChannelAsync(??) at /_/src/WebJobs.Script/Workers/Rpc/FunctionRegistration/RpcFunctionInvocationDispatcher.cs : 146
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcFunctionInvocationDispatcher.InitializeJobhostLanguageWorkerChannelAsync(??) at /_/src/WebJobs.Script/Workers/Rpc/FunctionRegistration/RpcFunctionInvocationDispatcher.cs : 137
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at async Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcFunctionInvocationDispatcher.<>c__DisplayClass56_0.<StartWorkerProcesses>b__0(??) at /_/src/WebJobs.Script/Workers/Rpc/FunctionRegistration/RpcFunctionInvocationDispatcher.cs : 229
I have not changed the file path settings and I was able to find the index.js source file inside of /dist in Kudu as is specified in my function.json binding.
My application configuration settings have Functions extension version set to ~4 and runtime set to Node ~16.
[Screenshot of Function App configuration settings for functions extension version and runtime][2]
In my deployment pipeline, the logs state that the app is being deployed with Node version 16.17.1, and Kudu logs further state that the specific version of the Functions extension tools being used is 4.12.0.
I have tried the following: restarting my application; updating my app configuration to explicitly set the Functions extension package to 4.12.1 (most recently released version); setting my Node version to 14; changing my App Service plan from consumption to premium to see if the error could be due in some way to cold starting; and explicitly setting the entry point of my HTTP-triggered functions in my function.json file. I have also updated my host.json file to update the ExtensionsBundle to use version 3.0.0 at the lowest:
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.3.0, 4.0.0)"
}
}
I have seen this problem referenced on Stack Overflow, GitHub and Microsoft support forums related to .NET projects but have not been able to use these resources to resolve my issue.

I don't know if you still have this problem, I had the same problem since 0:00 UTC last night on one of my subscriptions and I just found a workaround: in despair I downgraded my Function apps from "~4" to "~3" ... 502s and exceptions disappeared!
Definitely not a long-term solution but I have a Production again and my customers can access their app.

I was facing the same issue, and solved it by creating a new Function App and solving the problems when pre-validating migration from version 3 to 4.
So my recommendation for you is to go to your Function App > Diagnose and Solve Problems menu, and search for "Functions 4.x Pre-Upgrade Validator".
There you can check problems that may need to be solved before upgrading correctly to newest ~4 version.
In my situation it was the name of the Function App, being > than 32 chars.
You can find info regarding this topic in the official Azure Function Migration Guide.
Regards!

Had this issue for function app hosted on windows after upgrading node version to 18.x.x
WEBSITE_NODE_DEFAULT_VERSION : ~18
And our run time was 3.x
but as per this
it looks like Node 18 is only supported by runtime 4.x GA (Node.js 18, 16, & 14)
This meant we had to upgrade the host json to update accordingly to support node 18
Update config for function app was upgraded
FUNCTIONS_EXTENSION_VERSION : ~4
Final step was to restart the function app.
after doing the above, solved the issue Failed to start a new language worker for runtime: node.

Related

Azure function trigger with IoT-Hub "EntityPath"

I am currently having troubles with connecting my function trigger to an IoT-Hub, overnight it broke somehow.
Function version 4.
Node.js version 14 LTS.
First I got an error saying I have to use web.jobs version 4.3.0, I changed the host.json to include this
Then it has started giving me a runtime error which I don't know how to fix, the error:
I defined connection string in the portal which has the format
"Endpoint=sb//{iothub-ns-"somename"-"somenumber".servicebus.windows.net/}; SharedAccessKeyName={NameOfAccessKey};SharedAccessKey={TheKey};EntityPath={Name};
Lastly I tried removing the EntityPath which removed the error but then nothing came to the function anymore
Edit:
I got it fixed by changing function version to 3 and reverting the original Host.json to be "version": "[2.*, 3.0.0)".
I have no idea how the runtime version got changed, even when I made new functions they would also get this error. It is probably just something I have done within my workspace that is causing this.
while defining the connection string give the entity path as even hub compatible name
Endpoint=sb://<Event hub-compatible endpoint>.servicebus.windows.net/;EntityPath=<Event Hub compatible name>;SharedAccessKeyName=<keyName>;SharedAccessKey=<key>"
It's an open bug, reported here - https://github.com/Azure/azure-functions-core-tools/issues/3034

Azure Service bus trigger for function app with session enabled - Node.js

I have a function that is trigged by service bus with session enabled, but I get the error:
Microsoft.Azure.ServiceBus: It is not possible for an entity that requires sessions to create a non-sessionful message receiver
Is there a way to enable sessions with nodejs app?
I tried to edit my host.json but it didnt work, SessionHandlerOptions is not showing as property for serviceBus... "Property SessionHandlerOptions is not allowed"
{
"version": "2.0",
"extensions": {
"serviceBus": {
"SessionHandlerOptions": ....
}
}
}
}
Also tried to add "isSessionsEnabled": true in function.json but still getting same error.
Any idea?
This is a common question. Azure Functions don't support Service Bus sessions since Azure Function was create. This situation keeps for 3-4 years. Several months ago comes up a nuget package to Support this. For node.js I don't find a SDK to install. If you use C#, now it has a solution. But for node.js, I am not sure. You can have a try of the newest SDK, maybe it can support this.
This is an Function SDK issue. You can take a look.
So, after some hours and thanks to the suggestion from #BowmanZhu I found the solution that works also when using node.js.
Im using azure-functions-core-tools, so update it to latest version:
npm install -g azure-functions-core-tools#2
From the root map of the project install the package 3.1.1 of ServiceBus extension:
dotnet add package Microsoft.Azure.WebJobs.Extensions.ServiceBus --version 3.1.1
In the extensions.csproj file you should see now that the package reference for the package is 3.1.1
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.1.1" />
then run:
func extensions install
last add in function.json add in bindings:
"isSessionsEnabled": true
run func start to start the function app locally. You should not see anymore the error message and a queue with session enabled can be used to trig the function.

Azure Functions Precompiled & Blob Trigger : The function type name is invalid

I try to deploy a precompiled Azure Function that use Blob Trigger.
After publishing the function, I have the following error in Kudu and my function is not executed:
2017-05-30T14:34:11.436 Starting Host (HostId=sfl-data-forecast-dev-funcs, Version=1.0.10945.0, ProcessId=17328, Debug=True, Attempt=0)
2017-05-30T14:34:11.436 Development settings applied
2017-05-30T14:34:11.436 No job functions found. Try making your job classes and methods public. 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.).
2017-05-30T14:34:11.436 Job host started
2017-05-30T14:34:11.436 The following 1 functions are in error:
Import: The function type name 'Forecasts.Functions.ImportForecastsFunction' is invalid.
I do not understand why I have this error. The Azure function is in a web project that targeting framework 4.6.1. WebJob SDK, and Extensions nuget package were added. I have downgraded Newtonsoft.Json to version 9.01 but it didn't change anything.
I have the following function.json:
{
"scriptFile": "..\\bin\\SFL.Data.Forecasts.Functions.dll",
"entryPoint": "SFL.Data.Forecasts.Functions.ImportForecastsFunction.Run",
"bindings": [
{
"name": "file",
"type": "blobTrigger",
"direction": "in",
"path": "forecasts/{name}",
"connection": "HotStorageAccount.ConnectionString"
}
],
"disabled": false
}
Faced the same exception. Turned out that the runtime version was invalid. Erroneously defined as ~1, even though the function is referencing netcore2.1, not supported by runtime Version 1.
In particular, the invalid version was caused by an ARM-template based resource group deployment, defining the function app's parameter FUNCTIONS_EXTENSION_VERSION as ~1 instead of ~2.
I solved the problem by providing a namespace for the Azure Function file.
namespace MyProject.AppFunctions
This is my class:
namespace MyProject.AppFunctions
{
public static class SomeFunction
{
public static async Task<HttpResponseMessage> Run(...)
{
// CODE
}
}
}
This is my functions.json file:
{
"scriptFile": "..\\bin\\MyProject.AppFunctions.dll",
"entryPoint": "MyProject.AppFunctions.SomeFunction.Run",
...
}
FWIW, I just resolved the same issue. The problem was that in my debugger settings, it was pointing to an old version of the func.exe application. I switched my debugger settings to launch %AppData%\npm\func.cmd instead and everything worked fine.
(Solution) Function (FunctionName/CsvUpload) Error: The function type name 'Functions.CsvUpload' is invalid
I have solved this error by setting the value in Azure configuration from ~1 to ~2. Make Sure you have to use Visual studio 2019 and Microsoft.NET.Sdk.Functions 3.0.2 When you are working on dotnet core 3.0 something ! If you are using Visual Studio 2017 you must have to set your sdk version lower than 3.0.2 (Microsoft.NET.Sdk.Functions : 1.0.29 something) then only you can set FUNCTIONS_EXTENSION_VERSION = ~1
If you using Visual Studio 2019 then use FUNCTIONS_EXTENSION_VERSION = ~2
If you using Visual Studio 2017 then use FUNCTIONS_EXTENSION_VERSION = ~1
This also happens when you have multiple Azure Functions Core Tools versions installed at the same time.
I got this error when trying to debug a v4 Azure Function locally. Turns out I had v2 installed. Once I removed v2 things started working again.

Azure Service Fabric Changing Setting After Deployment

We're testing out service fabric and experiencing some issues.
Firstly the VM Type A1v2 comes with 10gb of HDD, however the issue is the log file takes up over 9gb of space almost immediately so deployments then fail with an out of disk space exception. So I've discovered I need to set the SharedLogSizeInMb to a smaller value as below:
"fabricSettings": [
{
"name": "KtlLogger",
"parameters": [
{
"name": "SharedLogSizeInMB",
"value": "256"
}
]
}
],
The issue now is I am not sure how to apply this change. I can't seem to find a way to do it in the portal and when I download the powershell setup scripts from the portal in the Service Fabric setup process and run them to create a new Service Fabric instance it just gets as far as deploying and fails.
So my questions are:
1) How should I be adjusting this setting, I assume it can only be done via an ARM script?
2) Can these scripts only be used to create a new Service Fabric cluster or can you also somehow run them to just change a setting?
3) Should the vanilla script I export from Azure just work? The error messages I can find are very generic and non explanatory. Seems to just be an exception getting thrown in each VM when trying to create service fabric. I am pretty much using all the default settings nothing special.
Thanks,
Oliver
EDIT
My files in comment 2 just have this over and over.
2017/05/02-04:22:00.388,Info,4864,ImageStoreClient.ManagedFileLock,Obtained writer lock for D:\SvcFab\lock
2017/05/02-04:22:00.739,Info,4864,FabricDeployer.FabricDeployer,Executing Configure /fabricBinRoot:C:\Program Files\Microsoft Service Fabric\bin /fabricDataRoot:D:\SvcFab /fabricLogRoot:D:\SvcFab\Log /cm:C:\WindowsAzure\Logs\Plugins\Microsoft.Azure.ServiceFabric.ServiceFabricNode\1.0.0.35\TempClusterManifest.xml /oldClusterManifestString: /im:C:\WindowsAzure\Logs\Plugins\Microsoft.Azure.ServiceFabric.ServiceFabricNode\1.0.0.35\InfrastructureManifest.xml /instanceId: /targetVersion: /nodeName: /nodeTypeName: /runAsType: /runAsAccountName: /runAsPassword: /serviceStartupType: /output: /currentVersion: /error: /bootstrapMSIPath: /machineName: /fabricPackageRoot: /jsonClusterConfigLocation: /enableCircularTraceSession:False
2017/05/02-04:22:02.452,Info,4864,FabricDeployer.FabricDeployer,Running operation System.Fabric.FabricDeployer.ConfigureOperation
2017/05/02-04:22:02.576,Info,4864,FabricDeployer.FabricDeployer,Creating FabricDataRoot D:\SvcFab, if it doesn't exist on machine
2017/05/02-04:22:02.576,Info,4864,FabricDeployer.FabricDeployer,Creating FabricLogRoot D:\SvcFab\Log, if it doesn't exist on machine
2017/05/02-04:22:04.907,Info,4864,ImageStoreClient.ManagedFileLock,Released writer lock on D:\SvcFab\lock
My Event Logs this over and over.
Failed starting service, Error: Microsoft.Azure.ServiceFabric.Extension.Core.AgentException: Configure node failed with code -1
at Microsoft.Azure.ServiceFabric.Extension.Core.NodeBootstrapAgent.StartFabricHostService(Boolean isBootstrapping)
ERROR: Microsoft.Azure.ServiceFabric.Extension.Core.AgentException: Configure node failed with code -1
at Microsoft.Azure.ServiceFabric.Extension.Core.NodeBootstrapAgent.StartFabricHostService(Boolean isBootstrapping)
at Microsoft.Azure.ServiceFabric.Extension.Core.NodeBootstrapAgent.d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Azure.ServiceFabric.Extension.Core.NodeBootstrapAgent.d__0.MoveNext()

How to solve cloud foundry deployment to Azure

I encounter an error trying to deploy cloud foundry to azure. Below is the stack trace. Any ideas how to resolve it?
Deploying
---------
Director task 7
Deprecation: Ignoring cloud config. Manifest contains 'networks' section.
Started preparing deployment > Preparing deployment. Done (00:00:01)
Error 100: Unable to render instance groups for deployment. Errors are:
- Unable to render jobs for instance group 'cf_z1'. Errors are:
- Unable to render templates for job 'cloud_controller_ng'. Errors are:
- Error filling in template 'cloud_controller_api.yml.erb' (line 131: undefined method `empty?' for 123456:Fixnum)
It seems BOSH is expecting a string for a value in your manifest and you have supplied a number. I'm not sure what version of cloudfoundry you are deploying but looking at cloud_controller_api.yml.erb on line 131, I think you should start by looking at the value for router.route_services_secret in your manifest.

Resources