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

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.

Related

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.

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.

Starting Azure Service Bus Trigger Function throws InvalidOperationException for "Host not yet started"

I have a v.2 Service Bus Trigger function which, when I attempt to start, throws the following exception:
System.InvalidOperationException
HResult=0x80131509
Message=The host has not yet started.
Source=Microsoft.Azure.WebJobs.Host
StackTrace:
at Microsoft.Azure.WebJobs.JobHost.StopAsync() in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\JobHost.cs:line 121
at Microsoft.Azure.WebJobs.Hosting.JobHostService.StopAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Hosting\JobHostService.cs:line 32
at Microsoft.Extensions.Hosting.Internal.Host.<StopAsync>d__10.MoveNext()
I've searched around but cannot find anyone with a similar issue (and fix). I'm running VS 15.8.7 with all extensions and packages updated.
Here's what my function looks like:
[FunctionName("ServiceBusListenerFunction")]
public static void Run([ServiceBusTrigger("myTopic", "MySubscription", Connection = "MyConnection")]string mySbMsg, ILogger log)
{
log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
And here's my local.settings.json:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"MyConnection": "UseDevelopmentStorage=true",
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true"
},
"Host": {
"LocalHttpPort": 7077
}
}
I also tried doing the following in launchSettings.json, but it didn't help:
{
"profiles": {
"MyProject": {
"commandName": "Project",
"executablePath": "C:\\Users\\[myUserName\\AppData\\Roaming\\npm\\node_modules\\azure-functions-core-tools\\bin\\func.dll",
"commandLineArgs": "host start --port 7077"
}
}
}
I have Service Bus Explorer running and have created the above-named topic and subscription on it. The project in which the functions are located is built against .NET Standard 2.0.
Please let me know if you have any suggestions or need additional information.
EDIT: I grabbed the red exception text that appears briefly in the console window before it closes (which happens right before I get the above exception), and it reads:
Host initialized
A host error has occurred
System.Private.Uri: Value cannot be null
Parameter name: uriString
Stopping job host
Searching on this, I found this, but it doesn't seem as though I should have to change the attribute to get this working.
Thanks in advance for any help.
Problem is caused by this setting
"MyConnection": "UseDevelopmentStorage=true"
UseDevelopmentStorage=true represents Storage emulator connection string, for a Service Bus trigger, use Service Bus connection string(same one used in Service Bus Explorer or find it in Azure portal).
Some improvements:
In local.settings.json, LocalHttpPort somehow doesn't work in VS, you can remove it as commandLineArgs in launchSettings.json works as expected.
AzureWebJobsDashboard is not required now, so it can be deleted without special purpose.
In launchSettings.json, remove executablePath which is invalid as well. Usually we don't need this setting as VS use latest CLI by default.
One of the ways, I sorted the issue by removing the connection string from the [ServiceBusTrigger] and inserting it through local.settings.json.
in the function file.
[ServiceBusTrigger("Your-Topics-Name", "SubscriptionName",Connection = "MyServiceBus")]
Inside the local.settings.json.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsMyServiceBus": "your connection string",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
note: connection string name start with the "AzureWebJobs" so you can put the remaining as the name.
In my case, it was just to update the version of Microsoft.Azure.WebJobs.Extensions.ServiceBus from 4.7.x to 5.x.x, and that's it :-)
I had to install Azure Functions Core Tools. It includes a version of the same runtime that powers Azure Functions runtime that you can run on your local development computer. It also provides commands to create functions, connect to Azure, and deploy function projects.
In my case the problem was the Platform target, change it to Any CPU instead of x86
I solve the issue by updating all the packages. I had sold packages that were incompatible with a recent package I installed.

The binding type 'serviceBusTrigger' is not registered error in azure functions c# with core tools 2

I open a fresh new azure functions project, my packages are:
Microsoft.Azure.WebJobs 3.0.0-beta4
Microsoft.Azure.WebJobs.ServiceBus 3.0.0-beta4
Microsoft.NET.Sdk.Functions 1.0.7
NETStandardLibrary 2.0.1
I use servicebustrigger and my function code is basic:
public static class Function1
{
[FunctionName("OrderPusherFunction")]
public static Task Run([ServiceBusTrigger("orders","orderpusher", Connection ="ServiceBus")]
string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
return Task.CompletedTask;
}
}
I also have:
Azure Functions Core Tools (2.0.1-beta.22) and Function Runtime Version: 2.0.11415.0
When i run, i get "The binding type 'serviceBusTrigger' is not registered" error, and the function does not get triggered. Anyone has an idea? This looks to me as a basic setup..
Basically, in v2 ServiceBus trigger was moved out of the default installation into Extensibility model. You need to register Service Bus binding as an extension as per Binding Extensions Management.
Unfortunately, this is all work-in-progress, as there is a number of issues for Service Bus binding:
Migrate ServiceBus Extension to .NET Core - "Done", but see the comments for which problems still exist
Build failure after installing ExtensionsMetadatGenerator into empty v2 app prevents VS tooling from registering the extension properly
Extensions.json is not updated when "extension install" CLI command executed for service bus extension for CLI issue
My advice would be to stick to v1 for now.

Cannot bind function parameter to type TraceWriter after publishing to Azure

I'm following the guide https://mikhail.io/2017/12/precompiled-azure-functions-in-fsharp/:
Created dotnet f# project: dotnet new classlib --language F# --name HelloFunctions
Added reference to functions: dotnet add package Microsoft.NET.Sdk.Functions
Added a new function as noted in file Library.fs below, added configuration files, etc.
Compiled the function
It successfully starts locally with dotnet build && dotnet publish && cd bin/Debug/netstandard2.0/publish && func start.
Publish it to Azure: func azure functionapp publish <name>
Azure sees the function, it is ok.
When I navigate to function by clicking its name in the tree the error popups:
Function ($Hello) Error: Microsoft.Azure.WebJobs.Host:
Error indexing method 'Functions.Hello'. Microsoft.Azure.WebJobs.Host:
Cannot bind parameter 'log' to type TraceWriter. Make sure the parameter Type
is supported by the binding. 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.).
The function does not seem to be working. Perhaps because of the error above.
Library.fs
namespace HelloFunctions
open System
open Microsoft.Azure.WebJobs
open Microsoft.Azure.WebJobs.Host
module Say =
let private daysUntil (d: DateTime) =
(d - DateTime.Now).TotalDays |> int
let hello (timer: TimerInfo, log: TraceWriter) =
let christmas = new DateTime(2017, 12, 25)
daysUntil christmas
|> sprintf "%d days until Christmas"
|> log.Info
Sounds very much like assembly version conflict (runtime running one version of Microsoft.Azure.WebJobs.Host.dll, while your app referenced the other).
My guess would be that you compiled your local app with version 2.0 of the runtime, while Azure Function App is configured to 1.0 (default). Please check.

Resources