Azure function trigger with IoT-Hub "EntityPath" - node.js

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

Related

Orchestrator function 'XYZ' failed: The function 'XYZ' doesn't exist, is disabled, or is not an orchestrator function

I'm trying to run Azure Orchestrations and I sunddenly I started getting the error from the statusQueryGetUri:
Orchestrator function 'UploadDocumentOrchestrator' failed: The function 'UploadDocumentOrchestrator' doesn't exist, is disabled, or is not an orchestrator function.
I've run this functions dozens of times today without any issue. VSCode doesn't flag any issues. I've tried restarting and that hasn't helped either.
This has happened once before. I got the error, troubleshot for like 3 hours, got frustrated, left, and came back to my computer an hour later and the problem was resolved without changing anything. I suspect the issue is related to caching somehow, but I'm not sure where to fix this.
There is a similar issue noted at:
https://github.com/Azure/azure-functions-durable-extension/issues/577
After I run func start, my "missing" orchestration appears in the launch screen indicating that it is valid as shown below.
I start the UploadDocumentOrchestrator with the HttpTrigger StartUploadDocuments. I see the trigger complete its execution UploadDocumentOrchestrator never starts in the logs.
UploadDocumentOrchestrator: orchestrationTrigger
For detailed output, run func with --verbose flag.
[2023-01-11T19:58:10.490Z] Executing 'StartUploadDocuments' (Reason='This function was programmatically called via the host APIs.', Id=f158ac3e-fa39-403c-9671-307ea54d5948)
[2023-01-11T19:58:10.599Z] Started orchestration with ID = '29b9ab7fcffe4f59bd47032ef21c19e8'.
[2023-01-11T19:58:10.620Z] Executed 'StartUploadDocuments' (Succeeded, Id=f158ac3e-fa39-403c-9671-307ea54d5948, Duration=154ms)
[2023-01-11T19:58:13.952Z] Host lock lease acquired by instance ID '0000000000000000000000004906C298'.
As it mentioned in the Same GitHub Ticket, it is solved by clearing the Azure storage emulator data, check here.
It might be due to the Caching issue and also #ConnorMcMahon given another scenario in GitHub Issue #1381 of the same error - renaming the function caused the same issue for a few users:
The function ‘XYZ’ doesn’t exist, is disabled, or is not an orchestrator function.

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

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.

Unable to deploy/update google cloud function

I have a Firebase project with 29 functions 2 with python and 27 with nodejs.
Modified 2 of them and now I can't deploy properly. I get an error log that send me to the logviewer and one of the errors is:
ERROR: build step 3
"us.gcr.io/fn-img/buildpacks/nodejs10/builder:nodejs10_20201201_20_RC00"
failed: step exited with non-zero status: 46
The functions keep on working, but I can't update/deploy properly. When I try to deploy them individually I get that error for both functions, but when I try to deploy ALL the functions I only get the error with those 2 functions the rest of the functions, that don't have any modification have no problem redeploying.
I checked the source code in the Cloud console and they have a warning icon saying that:
Function is active, but last deployment failed
The source code in the Cloud console is the same as the one I'm trying to deploy but the functions has the same functionality that before when I made the changes, the functions still works but can't update.
These are javascript functions that I deployed using the Firebase Node Sdk.
Any help?
EDIT I:
I reverted the changes on one of the functions that's been there for over 2 years and still have the same issue, can't update/deploy, that function triggers on storage.onFinalize().
The other function on firestore.onCreate()
EDIT II:
The newest function that I created is not in use, is part of a new feature in my android application, so I duplicated it, gave it different name and deployed without issues. In that case I could delete the original function without any issue as is not being used. But I can't do the same for the other function, the other function is constantly in use.

boto3 refers FEATURE_OCSP_MODE when setting IP address, but cannot find document about it

I got the following error message:
An HTTP Client raised and unhandled exception: name 'FEATURE_OCSP_MODE' is not defined.
However, I cannot find any reference on the internet about this FEATURE_OCSP_MODE. I was calling describe_addresses() of boto3 using Pythan 3.8. The code was working until yesterday (8/24/2020).
I have just faced the same problem and the root cause was the snowflake-connector-python version as mentioned by Ben Campbell. In version v2.3.0 they accidentally removed the 'FEATURE_OCSP_MODE' constant but in version v2.3.1 they added it back.
The solution is to use snowflake-connector-python==2.3.1 or a newer one.
I rolled back to boto3==1.14.46 and snowflake-connector-python==2.2.10 as I was getting errors in both within Airflow 1.10.10 on Python 3.6.
This did the trick.

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.

Resources