14

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"
}
Erik Philips
  • 48,663
  • 7
  • 112
  • 142
Murray Foxcroft
  • 10,865
  • 2
  • 52
  • 71

8 Answers8

17

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

MarkD
  • 1,131
  • 12
  • 27
5

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.

Murray Foxcroft
  • 10,865
  • 2
  • 52
  • 71
Mikhail Shilkov
  • 30,280
  • 3
  • 56
  • 87
3

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!

Gerard
  • 2,634
  • 2
  • 22
  • 33
0

If you debug/run from Visual Studio (F5), somehow, even with latest Microsoft.NET.Sdk.Functions (v1.0.28), its not able to detect AzureFunctions defined in the project.

I root caused the issue to Project properties > Debug > Working Directory is not set somehow by default. Set it to the actual directory where binaries are found and your AzureFunctions becomes available for debug.

PS, this would add launchSettings.json /profiles/{projectName}/workingDirectory=/objd/amd64/

image

AAATechGuy
  • 118
  • 1
  • 7
0

I was facing the same issue in Windows.

More specifically I was running:

mvn clean package azure-functions:run  

and the result was:

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

This was related to azure-functions-core-tools library that was installed in my PC. So i fixed it by upgrading it.

npm i azure-functions-core-tools -g --save

npm i -g azure-functions-core-tools@core -g --save
gmavridakis
  • 109
  • 9
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
    

Viola! 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
Furqan Rahamath
  • 1,612
  • 1
  • 15
  • 23
0

If it's working from bin/Debug/netcoreapp3.1/ etc this is because you are missing some needed files in the root or missing sections in some files. (eg: host.json)

I managed to fix this by running func init --force to restore the initial setup and use git to find the missing sections.

enter image description here

Chris Gunawardena
  • 5,338
  • 1
  • 21
  • 40
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.

saurav singh
  • 347
  • 5
  • 14