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

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.

Related

Cannot bind parameter 'lockToken' in Azure function app in .net framework?

I was using .net core Azure function in an app, with no problem faced, with the below code.
But when I create an Azure function app using .net framework it is throwing below error.
I tried all possible google solutions. the error is clearly because of nuget and library as same code works fine for v2 .net core function app.
[FunctionName("Function1")]
public static async System.Threading.Tasks.Task RunAsync([ServiceBusTrigger("topic", "sub", Connection = "ConnectionStringSettingName")]Message mySbMsg, string lockToken, MessageReceiver messageReceiver, ILogger log)
{
log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
I even tried this as well:
[FunctionName("Function1")]
public static async System.Threading.Tasks.Task RunAsync([ServiceBusTrigger("topic", "sub", Connection = "ConnectionStringSettingName")]Message mySbMsg, Guid lockToken, MessageReceiver messageReceiver, ILogger log)
{
log.LogInformation($"C# ServiceBus topic trigger function processed message: {mySbMsg}");
}
If I took it as guid or string or vice versa, it gives the error:
Error indexing method 'Function1.RunAsync'.
Microsoft.Azure.WebJobs.Host: Cannot bind parameter 'lockToken' to
type Guid. 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.).
Vice versa error:
RunAsync: Microsoft.Azure.WebJobs.Host: Error indexing method
'Function1.RunAsync'. Microsoft.Azure.WebJobs.Host: Cannot bind
parameter 'lockToken' to type Guid. 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 locktoken parameter that you are sending in is a string.
The error message is that it cannot bind the locktoken to a Guid.
Therefore, it is probably expecting a string that is a valid Guid, and you are sending in something else.

Azure Functions v1 timer triggered function cannot start due to Windows Platform FIPS issue

I'm trying to develop a function app that uses a timer trigger and I'm getting an issue with the Windows Platform FIPS that prevents the timer-triggered function to start locally. Here's the code that's causing the error (it's the default timer-triggered function):
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
namespace FunctionApp1
{
public static class Function1
{
[FunctionName("Function1")]
public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, TraceWriter log)
{
log.Info($"C# Timer trigger function executed at: {DateTime.Now}");
}
}
}
When I try to run this function in func.exe, it produces the following error:
The listener for function 'Function1' was unable to start. mscorlib: Exception has been thrown by the target of an invocation. mscorlib: This implementation is not part of the Windows Platform FIPS validated cryptographic algorithms.
This exact code works on another dev environment that I have access to. What do I need to do to fix these Windows Platform FIPS issues so that the timer trigger will run?
Thanks!
If your environment does need this FipsAlgorithmPolicy somewhere, disable it for Azure function only.
In File Explorer, open %localappdata%\AzureFunctionsTools\Releases\1.4.0\cli\func.exe.Config, add <enforceFIPSPolicy enabled="false"/> under <runtime> element. Note that in this way, you have to repeat this step once new function cli is released.
Similarly, if you use Storage Emulator locally, open C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\AzureStorageEmulator.exe.config, add <enforceFIPSPolicy enabled="false"/> under element.
Else just disable FipsAlgorithmPolicy for your computer.
In search box or right click on Start button and click Run, input regedit to open Registry Editor.
In address bar(View>Address Bar), navigate to Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy.
Double click on Enabled, change Value data to 0.

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.

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.

No job functions found in Azure Webjobs

Trying to get Azure Webjobs to react to incoming Service Bus event, Im running this by hitting F5. Im getting the error at startup.
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.).
My functions-class look like this:
public class Functions
{
// This function will get triggered/executed when a new message is written
// on an Azure Queue called queue.
public static void ProcessQueueMessage([ServiceBusTrigger("test-from-dynamics-queue")] BrokeredMessage message, TextWriter log)
{
log.WriteLine(message);
}
}
I have every class and method set to public
I am calling config.UseServiceBus(); in my program.cs file
Im using Microsoft.Azure.WebJobs v 1.1.2
((Im not entirely sure I have written the correct AzureWebJobsDashboard- and AzureWebJobsStorage-connectionstrings, I took them from my only Azure storage-settings in Azure portal. If that might be the problem, where should I get them ))
According to your mentioned error, it seems that you miss parameter config for ininitializing JobHost. If it is that case, please use the following code.
JobHost host = new JobHost(config)
More detail info about how to use Azure Service Bus with the WebJobs SDK please refer to the document.The following is the sample code from document.
public class Program
{
public static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
config.UseServiceBus();
JobHost host = new JobHost(config);
host.RunAndBlock();
}
}

Resources