No job functions found. Try making your job classes and methods public
M

24

78

First off, I have looked at the other SO posts with the same error message and none seem to resolve my issue. I have tried many permutations and options. My function builds fine but will not run in the CLI, I get the following cryptic error. The MSFT documentation does not seem to have the answers either.

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.).

I am trying to run a timer job and then write a collection of messages to an event hub. What am I missing? I have been fighting this for hours.

Function:

    [FunctionName("CreateData")]
    public static async Task Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer,
        [EventHub("murraytest", Connection = "evingest")] IAsyncCollector<string> myeventhub,
        TraceWriter log)
    {
        await myeventhub.AddAsync("data1");
        await myeventhub.AddAsync("data2");
        await myeventhub.AddAsync("data3");

        log.Info($"COMPLETED: {DateTime.Now}");
    }

local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "Eventhub": "UseDevelopmentStorage=true",
    "AzureWebJobsDashboard": "",
    "evingest": "Endpoint=sb://example.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=LtcqBLT5VWjg0dGMdIvxCcEGs8902010Y6y14iGg="

  }
}

Packages

Nuget

function.json - is missing any eventhub bindings!

{
  "generatedBy": "Microsoft.NET.Sdk.Functions-1.0.0.0",
  "configurationSource": "attributes",
  "bindings": [
    {
      "type": "timerTrigger",
      "schedule": "0 */5 * * * *",
      "useMonitor": true,
      "runOnStartup": false,
      "name": "myTimer"
    }
  ],
  "disabled": false,
  "scriptFile": "..\\bin\\AzFuncs.dll",
  "entryPoint": "AzFuncs.Function1.Run"
}
Missi answered 6/12, 2017 at 20:16 Comment(6)
Do you mind upgrading to the latest Sdk.Functions (1.0.6)?Sutherland
First remove ServiceBus reference, then upgrade Sdk, then add it againSutherland
ServiceBus should be 2.1.0-beta4 tooSutherland
When you are done, check that function.json file is generated in bin\Debug\net461\CreateDataSutherland
Ok, fixing the assemblies to the correct versions in a new project worked for this error, but I do notice that the functions.json built in the bin is missing eventhub bindings. The function now runs, but no messages produced.Missi
It's ok, input and output bindings are not put into generated json file. They still work.Sutherland
G
24

UPDATE

My post below is coming up 5 years old. While it is still relevant, there are other answers here you should "and" together with mine. (Esp the net 5 FunctionName).

Original

Another gotcha I found especially if you are converting from another project or version.

In the VS csproj file, make sure AzureFunctionsVersion is present

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
...etc

the tooling adds this automatically but not added if you are modifying a project where this was missing. Hope this helps you save the 3 hours it cost me :-).

Gavin answered 10/12, 2018 at 20:19 Comment(0)
C
67

As addition to the existing answers: We had this issue when upgrading from .net 6 in-process mode to .net 8 with dotnet-isolated mode.

So the nugets depencencies changed from Microsoft.Azure.WebJobs.* (in-process bindings) to Microsoft.Azure.Functions.Worker (isolated bindings). Also we renamed [FunctionName("MyFunction")] to [Function("MyFunction")].

So in the local.settings.json the FUNCTIONS_WORKER_RUNTIME was still the old value of dotnet, but the correct value had to be:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
    // ...
  }
}
Colorable answered 11/12, 2023 at 17:8 Comment(4)
Perfect! Was missing the FUNCTIONS_WORKER_RUNTIME entry. Putting it in made all the difference.Bellyful
GOLD.....THIS ANSWER IS GOLD!Maxma
I ran the .NET Upgrade Assistant tool on my function to upgrade from .NET 6 to .NET 7. It correctly upgraded almost everything, but missed this!Mendelian
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"Fingerbreadth
T
57

If you are using Azure Functions in .NET 5 or higher with the out-of-proces execution model you need to replace your FunctionName with Function, otherwise the function will not be detected.

Before:

[FunctionName("CreateData")]

After:

[Function("CreateData")]
Tightfisted answered 16/6, 2021 at 9:4 Comment(13)
Thanks, this is indeed the correct answer if one is using .NET 5! Upvoted (I fail to understand why someone down voted this answer, I upvoted)Vorlage
Here's the official documentation: learn.microsoft.com/en-us/azure/azure-functions/…Vorlage
God damn you saved me hours of madness, thanks!Ingamar
Why would they change this?Labialized
What is the Nuget package and the namespace for the FunctionAttribute?Lasala
Function attribute is in the namespace Microsoft.Azure.Functions.WorkerEscalate
I think the reason this response may have been downvoted is because it is easy to miss the "out-of-proces execution model" reference, and the error message in the original post doesn't indicate in or out of process. To clarify: [Function] is for out of process and [FunctionName] is the attribute for in process. I got here because I was looking up the error message in an in-process upgrade to v4 from v3 on Azure recommendation and had this error message when in-process. In this case, the [Function] attribute is a red herring.Bink
@DavidBridge Did you find a solution to your problem? I am also receiving this error while trying to upgrade the function runtime from 3 to 4 on an in-process function.Thaddeus
The complete lack of quality in the Function project creation process using latest VS 2022 is unbelievable. Azure Functions team, is anyone there paying attention?Gernhard
No clear documentation, all the ones from Microsoft are outdated. No nice sample or template found in internet for Azure Webjobs!Event
You are transforming WebJob to an Isolated Azure Function (Worker Role) https://mcmap.net/q/270401/-worker-role-vs-web-jobEvent
Thanks mate, this worked for me on .NET 6 and function version 4 🙂Lilah
question is using Azurite is it in our out process?Thirtytwo
G
24

UPDATE

My post below is coming up 5 years old. While it is still relevant, there are other answers here you should "and" together with mine. (Esp the net 5 FunctionName).

Original

Another gotcha I found especially if you are converting from another project or version.

In the VS csproj file, make sure AzureFunctionsVersion is present

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
...etc

the tooling adds this automatically but not added if you are modifying a project where this was missing. Hope this helps you save the 3 hours it cost me :-).

Gavin answered 10/12, 2018 at 20:19 Comment(0)
W
20

I randomly had this issue but it only affected the functions in one class. Turned out I just needed to run a dotnet clean first.

Waterless answered 6/1, 2023 at 13:22 Comment(1)
Thanks for this! I ran into this issue after I added a nested setting to my configuration. I confirmed that this is what broke the function app, but if I undid the change and put the configuration back to the default... I would still get this error. It was only after running a dotnet clean that the error went away.Terylene
F
10

My issue was different from the other answers: the local.settings.json was explicitly included in the .gitignore definition. As such the file was not included in a clone and the local build couldn't understand which was the correct runtime to use.

I pulled the default local.settings.json from a sample project to restore the file.

Flamethrower answered 17/11, 2021 at 3:34 Comment(1)
Thanks! That thing was holding me back too.Mislead
A
8

In my case I was simply running the command from an actual function directory. You should run it from the root of the functions project instead!

Aqaba answered 4/1, 2021 at 14:9 Comment(0)
S
6

You should upgrade to the latest Microsoft.NET.Sdk.Functions (1.0.6 as of today) and Microsoft.Azure.WebJobs.Service.Bus (2.1.0-beta4 if running on full framework). You might need to remove the ServiceBus reference first in order to upgrade SDK.

The Microsoft.Azure.Eventhubs package also needs to be removed. All relevant types etc are in Microsoft.Azure.WebJobs.Service.Bus

Also remember to check "Include prerelease" in the package manager in order to find 2.1.0-beta4.

Sutherland answered 6/12, 2017 at 20:54 Comment(0)
B
6

This happened to me after a nuget upgrade for Microsoft.Azure.Functions.Worker.Sdk to 1.16.2 (also experienced by a user in this SO thread above, https://mcmap.net/q/268283/-no-job-functions-found-try-making-your-job-classes-and-methods-public).

I found an open issue here (https://github.com/Azure/azure-functions-dotnet-worker/issues/2070) and a workaround that is working for me and a couple of people in the issue thread.

The workaround, according to the comments in the issue posted above, is to add the following to your csproj PropertyGroup:

<FunctionsEnableWorkerIndexing>False</FunctionsEnableWorkerIndexing>.

Boyle answered 28/11, 2023 at 13:35 Comment(1)
Seems like this issue is still occurring. I had to do this after upgrading all my packages.Adventure
B
4

In my case, the clue was this message at the start of the console output:

Can't determine project language from files. Please use one of [--csharp, --javascript, --typescript, --java, --python, --powershell]

Adding the --csharp argument did the trick.

Beatify answered 3/12, 2021 at 12:42 Comment(1)
I had the same problem. Fixed it by adding FUNCTIONS_WORKER_RUNTIME as a setting in my local.settings.json. Acceptable values can be found hereHatpin
L
3

migration from dotnet6.0 to dotnet8.0 then change in local.settings.json file

"FUNCTIONS_WORKER_RUNTIME": "dotnet"

to

"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"

remove the startup.cs file and move all service and HostBuilder.ConfigureServices to Program.cs

Limiter answered 28/5 at 10:10 Comment(0)
B
2

Had this error on my local machine out of the blue, after nuget update of an shared assembly. The same function still worked on a build server. It looks like something lingering from past build outputs/packages caused this.

My Setup:

  • .NET 7, out of process.
  • VS.NET 2022
  • Core Tools Version: 4.0.5085 Commit hash: N/A (32-bit)
  • Function Runtime Version: 4.16.4.20366

I had to do the following to get rid of the issue:

  • Stop VS.NET
  • Delete bin folders
  • Delete obj folders
  • Clear nuget cache in C:\Users<username>.nuget
  • Restart VS.NET, build and run
Berkow answered 7/7, 2023 at 9:21 Comment(0)
W
1

In my case (v3 on net core 3.1) it was a weird case that somehow this was removed from csproj file.

<None Update="local.settings.json">
  <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
  <CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
Walther answered 14/9, 2021 at 8:3 Comment(0)
E
1

I got the error mentioned in the question in Rider when I tried to run localy azure function. I tried to run proejct in Visual Studio and I got another error during the build:

A project with an Output Type of Class Library can not be started directly.

It turned out that I removed at some point from csproj package reference:

<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />

After adding it to csproj I am able to run azure function.

Exempt answered 23/3, 2023 at 13:57 Comment(0)
M
1

so for me it worked when i startet the function with: "func start --csharp"

edit: after the first time starting the function with the func start --csharp command i can now start it normal with func start

Marvelofperu answered 13/7, 2023 at 9:15 Comment(0)
C
1

i had this problem recently and took me 2 days to found out that i only need the latest version of azure functions core tools.

Cerumen answered 4/9, 2023 at 10:42 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Savannahsavant
V
1

This started happening after upgrading to Microsoft.Azure.Functions.Worker.Sdk 1.16.0. A downgrade to 1.15.1 solved the issue.

See: https://github.com/Azure/azure-functions-dotnet-worker/issues/2029

Volny answered 7/11, 2023 at 17:48 Comment(0)
V
0

I appreciate the other answers here. But in my case none of them worked on VS Code.

I am still trying to use .NET core SDK version of 2.1 and had to use all old version of dependencies for my Azure function.

Even after everything seeming right, I was still unable to run the function locally. Turns out, there is a small step to be taken:

  1. First, publish your project dotnet publish

  2. The published stuff should be in bin/Debug/netstandard2.0 . Just get inside this folder and run your function:

    cd bin/Debug/netstandard2.0  # I was using netstandard2.0 framework
    func start --build # You can add --verbose flag for more detailed outputs
    

Voila! That's it. Just to be clear, here are my versions:

  • .NET core SDK version: 2.1.810
  • Azure CLI version: 2.12.0
  • Azure Function version: v2
  • Microsoft.NET.Sdk.Functions: 1.0.37
Vittle answered 30/9, 2020 at 21:48 Comment(0)
D
0

in my scenario, for Existing Project, I missed to give reference in .csproj file after installing azure function setup in windows

here is it

you can run command on VS Code Func init --force and Select Dotnet template and then delete .csproj file which is created automatically.

local.settings.json

"Values": {
        "AzureWebJobsStorage": "UseDevelopmentStorage=false",
        "FUNCTIONS_WORKER_RUNTIME": "dotnet"
    }

.csproj file

<ItemGroup>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
  </ItemGroup>  

I hope someone helps out there if you are using like me visual studio code.

Diathesis answered 12/2, 2021 at 8:44 Comment(1)
That was it, thank you. I managed to delete Microsoft.NET.Sdk.Functions from the project :(Double
P
0

It happened to me when I changed the name of the project and some other refactoring. It was working on that machine after the change, but interesting enough when I switch to a different machine, I got this error - even if it's the same code.

The solution was for me basically creating a random new azure function and running again. All my functions appeared on the cli on the next run.

Pitchdark answered 12/9, 2021 at 13:51 Comment(0)
T
0

I was running "func start" from the wrong folder. Make sure you're running it from the root folder of the azure function. This should be true for any language (I'm using python)

Tamarra answered 20/9, 2021 at 19:49 Comment(0)
P
0

After having upgraded a lot of packages - amongst others the one that triggered the change from [FunctionName("CreateData")] to [Function("CreateData")], I needed to delete the bin and obj folder before the functions were discovered again.

Population answered 23/9, 2022 at 20:42 Comment(0)
C
0

I Recently came across this issue and found it to be something else.

For context of my situation i am upgrading a .NET5 Function to .NET6 and it is a 'dotnet-isolated' function that i am working with that is triggered by from serviceBus.

        [Function(nameof(XFunction))]        
    public async Task Run([ServiceBusTrigger(QueueName, Connection = "ServiceBusName", IsSessionsEnabled = true)] string? message, FunctionContext context)

For me, the fix to this was actually reading some of the documentation a little closer.

(See: https://learn.microsoft.com/en-us/azure/azure-functions/migrate-version-1-version-4?source=recommendations&tabs=net6-isolated%2Cazure-cli%2Cwindows&pivots=programming-language-csharp)

The key point was: Relevent Snapsot of docs

The .NET5 function was referencing:

        <PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.33" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.2.3" />

As soon as i removed these and re-ran the function it worked as expected.

Hope this saves someone a little time if they are in my shoes now in the future :)

Conterminous answered 3/10, 2023 at 11:55 Comment(0)
P
0

I had the same issue when pulling a project that had been updated from .NET 7 to .NET 8.

In my case I'm running the project on a Mac with VSCode. What worked for me was updating Core tools from 4.0.5095 -> 4.0.5801.

brew tap azure/functions
brew install azure-functions-core-tools@4
Pursy answered 22/5 at 16:8 Comment(0)
A
-2

Removed and reinstaled Azure Functions Core Tools at the last version worked for me.

Airdrop answered 26/6 at 14:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.