Azure / Azure-Functions

1.11k stars 195 forks source link

"No job functions found." reported when jobs are there + Functions tab empty #2168

Open tymtam2 opened 2 years ago

tymtam2 commented 2 years ago

This is functions 4.1.3.17473

Sometimes:

  1. Application Insights reports the following Warning: No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.). with category: Host.Startup

  2. The Functions tab shows no functions

I haven't been able to pinpoint what triggers this error. I have experienced situations that without an obvious reason (so no deployment, no restart, no new requests) the Function tab starts displaying the functions after it was empty.

This seems to affect function apps with Http and EventHub triggers.

The classes containing the Run methods are public and the Run method is decorated with [FunctionName("MyAmazingFunction")]

v-bbalaiagar commented 2 years ago

Hi @tymtam2 , Thank you for your feedback! If you are using Azure Functions in .NET 5 with the out-of-process execution model you need to replace your FunctionName with Function, otherwise the function will not be detected.

Before:

[FunctionName("CreateData")] After:

[Function("CreateData")]

Here is the official document - https://docs.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=browser&pivots=development-environment-vs#rename-the-function

Please check and let us know if this helps.

tymtam2 commented 2 years ago

@v-bbalaiagar Thanks for you comment.

Here's some more info

  1. I'm using .NET 6
  2. I cannot see FunctionAttribute so I canot use [Function("CreateData")]
  3. Why or how would it work intermittently? I have the same code deployed in another resource group and it works.
tymtam2 commented 2 years ago

According to https://stackoverflow.com/questions/55802391/settings-website-contentshare-and-website-contentazurefileconnectionstring-i

missing WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE could cause No job functions found. warning.

This makes this issue related to https://github.com/Azure/Azure-Functions/issues/2169

However after adding WEBSITE_CONTENTAZUREFILECONNECTIONSTRING and WEBSITE_CONTENTSHARE No job functions found. warning is still appearing in logs and Functions tab is empty.

tymtam2 commented 2 years ago

As far as I remember redeployment of the function fixes the issue for some time.

Restarting the function app does not fix the issue.

v-bbalaiagar commented 2 years ago

Hi @tymtam2 , Thank you for the update. We will investigate this further and update you with the findings.

tymtam2 commented 2 years ago

Excellent. The issue is still tagged with 'Needs%3A%20Author%20feedback'. Do you need extra information?

Here are the important bits about the project:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Azure.Messaging.EventHubs" Version="5.6.2" />
    <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
    <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.0.1" />
    <PackageReference Include="StackExchange.Redis" Version="2.2.88" />
    <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>

The function project references one project wich in turn references the following packages:

 <ItemGroup>
    <PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="6.0.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.0" />
    <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
  </ItemGroup>
SirSavio commented 2 years ago

Any news on this?

brandenlivermore commented 2 years ago

I am also experiencing a similar issue with .NET 6 functions on the consumption plan. My function app was working great for over 20 days after deployment and then one day stopped running. It logged the No job functions found for a while and then stopped.

Restarting the function app fixed the issue for about 8 hours until it happened again. About an hour ago I redeployed to the function and it's been working since, but I'm worried the issue will happen again.

sayago69 commented 2 years ago

One more case here: deploying an Azure function using containers and getting that annoying No job functions found message.

After lots of reading and investigating, I think I've narrowed the problem down to the creation of the container. If I build my container locally using docker build and then I run it using docker run I get the same error message and my function is not working:

image

This is how my docker file looks like:

FROM mcr.microsoft.com/azure-functions/dotnet:4 AS base WORKDIR /home/site/wwwroot EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build WORKDIR /src COPY ["MyProject.csproj", "MyProject/"] RUN dotnet restore "MyProjectFolder/MyProject.csproj" COPY . . WORKDIR "/src/MyProject" RUN dotnet build "MyProject.csproj" -c Release -o /app/build

FROM build AS publish RUN dotnet publish "MyProject.csproj" -c Release -o /app/publish

FROM base AS final WORKDIR /home/site/wwwroot COPY --from=publish /app/publish . ENV AzureWebJobsScriptRoot=/home/site/wwwroot \ AzureFunctionsJobHostLoggingConsole__IsEnabled=true

Note that I had to change the line first COPY line from COPY ["MyProjectFolder/MyProject.csproj", "MyProject/"] to COPY ["MyProject.csproj", "MyProject/"] in order to make it work. Otherwise, it was failing because it was not finding the project file.

I've already tried some other approaches like the one in this SO post but still getting the same error and no idea what's failing in here.

I'll keep looking for the solution. Let me know if anyone has any suggestions, ideas or even the right thing to do. They all will be welcomed.

GabrieleVolpato commented 2 years ago

Hello everyone, I'm experiencing the same issue. I have an Azure Function project developed in .net 6. Everything worked well for around 20 days and than it just stopped getting triggered by the configured EventHubTrigger. Recreating or redeploying the function worked for a few times but now it seems to have stopped forever. It doesn't even work anymore in my local computer. I already checked all the connection strings and quotas and it's all good. I'm sure my event hub has messages to deliver.

Here is my csproj file if it can help somehow

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="5.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Sql" Version="0.1.286-preview" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..\ModbusEnergyReaderIoT.Shared\ModbusEnergyReaderIoT.Shared.csproj" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Properties\PublishProfiles\" />
  </ItemGroup>
</Project>

Of course I get the "No job functions found." error too.

UPDATE: I really don't know how to explain this to myself, but just starting the function in local with --verbose without any other change made it restart working magically. Than I could find that the reason it didn't get triggered anymore in the cloud was an error parsing the SqlOuptutTrigger configuration. It still doesn't make sense that the configuration worked fine for nearly a month but it now works.

jainindore commented 2 years ago

I am facing the same error, I just created Azure function with Event Hub Trigger, .net version is .NET6 and function version is v4.

Below is the error:

No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

sergevm commented 1 year ago

What is the status on this issue?

Experiencing the No job functions found issue as well, in my case, the functions are in a docker container that is published in a private container registry.

We deploy the functions with the container via a pipeline in an app service. We see via the Kudu app in the docker logs that the pull is successful, however, the function runtime reports that there are no job functions found.

When I pull the image locally, and run it, the test function executes just fine, so the container is fine I believe.

jwzadev commented 1 year ago

I ran into this issue and started the function app locally with --verbose logs. I found in the logs that there was something strange with the function meta data: The runtime was trying to register a very old function that I had deleted as the only function job, completely ignoring the existing (new) functions. Decided to delete bin and obj folders and did a nuget restore to force refresh the metadata and it worked.

NOTE: I think a step to recreating this issue is to create a FunctionStartup class for dependency injection on a function app project that had working functions previously. The function app seems to forget to refresh the function metadata afterwards.

Ninchuga commented 1 year ago

I experienced the same error No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).

After I changed from [Function(nameof(MyFunction))] to [FunctionName(nameof(MyFunction))] it started to work magically, and function was recognized locally. I am using SqlServer trigger in my function with --prerelease version.

Working version:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Sql" Version="2.0.145" />
    <PackageReference Include="microsoft.azure.webjobs.extensions.sql" Version="3.0.181-preview" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
  </ItemGroup>
  <ItemGroup>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>
using Microsoft.Extensions.Logging;
using System.Collections.Generic;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Sql;
using VideoStore.OrderingFunction.Models;

namespace VideoStore.OrderingFunction
{
    public static class OrderingFunction
    {
        [FunctionName(nameof(OrderingFunction))]
        public static void Run(
            [SqlTrigger(tableName: "[OrderingDb].[dbo].[Orders]", connectionStringSetting: "SqlConnectionString")]
            IReadOnlyList<SqlChange<Order>> changes,
            ILogger logger)
        {

            if (changes is null)
                return;

            foreach (var change in changes)
            {
                logger.LogInformation("Order operation: '{Operation}' for order id: {OrderId}, and user: '{UserEmail}' with price: {Price}.", 
                    change.Operation, change.Item.Id, change.Item.UserEmail, change.Item.Price);
            }
        }
    }
}
ksgopal4 commented 1 year ago

I had this error on my local machine out of the blue, with no code change. Using .NET 7, out of process. It looks like something from past builds lingers around causing this issue. I did the following to fix this.

KyleLJohnson commented 10 months ago

None of the above fixes this issue. It's very strange. It comes out of nowhere. Any update?

aiurovet commented 10 months ago

It suddenly started to happen for me too (about a week ago) but only when deployed to Azure Kubernetes Services (AKS). Locally, it is fine. A bit earlier, I had the issue locally too, and the culprit was the older version of Azure Functions Core Tools. Once upgraded from 4.0.5198 to 4.0.5441, the problem was gone (currently, I'm on 4.0.5455). However, Azure Functions Core Tools are not used in AKS runs. So, no idea at the moment what else can be done to rectify the issue. I tried the Trace-level logging but that didn't give me more information. I suspect that the problem might be due to some bug in the latest version of the dotnet runtime,

Kobudzik commented 10 months ago

I also have this problem. It started when I updated Microsoft.Azure.Functions.Worker.Sdk to version 1.6.x. It works locally with func start and also in docker, but for some reason it fails when ran in kubernetes managed environment. Dockerfile uses mcr.microsoft.com/dotnet/sdk:8.0 and mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0. After reverting to Azure.Functions.Worker.Sdk to 1.5.x it works again.

aiurovet commented 10 months ago

This is fantastic! Thanks a lot, @Kobudzik! It worked for me too. Although in my case, it was a downgrade from 1.16.x to 1.15.x

rdon05 commented 9 months ago

Thanks a lot for the answer @Kobudzik. Downgrading from 1.16.2 to 1.15.1 fixed my issue as well. Does anyone have any idea what's causing this behavior when using 1.16.2 of the Azure.Functions.Worker.Sdk library?

rlauer commented 9 months ago

Just adding that we had the same problem here after upgrading to .NET 8 isolated worker - downgrading from 1.16.2 to 1.15.1 fixes the issue too. Oddly enough this problem only happened in some environments in Azure despite them being identical in configuration.

dnak commented 9 months ago

We had this issue also, downgrading to 1.15.1 worked.

This really needs attention. If I'm understanding all the dependencies correctly, this is tied to Isolated Workers, which is required when you move to .NET 8, which is LTS. So everyone starts to upgrade to .NET 8, they are going to encounter this issue and the bug will take out production systems by surprise.

nthekim commented 9 months ago

I also have this problem. It started when I updated Microsoft.Azure.Functions.Worker.Sdk to version 1.6.x. It works locally with func start and also in docker, but for some reason it fails when ran in kubernetes managed environment. Dockerfile uses mcr.microsoft.com/dotnet/sdk:8.0 and mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0. After reverting to Azure.Functions.Worker.Sdk to 1.5.x it works again.

Thank you very much, we have the same problem with Azure.Functions.Worker.Sdk 1.6.2 and after downgrading to 1.15.1 it worked again. Please fix this ASAP.

thaggren commented 9 months ago

Just adding that we had the same problem here after upgrading to .NET 8 isolated worker - downgrading from 1.16.2 to 1.15.1 fixes the issue too. Oddly enough this problem only happened in some environments in Azure despite them being identical in configuration.

Same for me. Upgrading .NET 7 functions to .NET 8 (isolated). Had to downgrade from 1.16.4 to 1.15.1

DevBiker commented 9 months ago

Same thing here. Isolated Function app targeting Framework 4.8. Downgrading from 1.16.4 to 1.15.1 fixed the problem.

mdocter commented 9 months ago

I ran into this issue after upgrading a .Net 6 Azure Functions project to .Net 8.

I found this post on Reddit by @Redge365 stating:

"I tracked the issue down to needing to update the local.settings.json file FUNCTIONS_WORKER_RUNTIME value from "dotnet" to "dotnet-isolated"

And that worked for me. After that small change I could run and debug the Azure Functions project locally again.

MatthewSteeples commented 9 months ago

My fix was the same as @mdocter, but I also had to change the environment variable in the deployed Function app too

fijsh commented 9 months ago

I have the same issue with .NET 8. Have Azure.Functions.Worker.Sdk 1.6.4. It works after downgrading to 1.15.1.

sedlaceks commented 8 months ago

.NET 7, downgrading to 1.15.x solved the issue as well

TheoBP commented 8 months ago

My fix was the same as @mdocter, but I also had to change the environment variable in the deployed Function app too

What did you change it to?

TheoBP commented 8 months ago

I ran into this issue after upgrading a .Net 6 Azure Functions project to .Net 8.

I found this post on Reddit by @Redge365 stating:

"I tracked the issue down to needing to update the local.settings.json file FUNCTIONS_WORKER_RUNTIME value from "dotnet" to "dotnet-isolated"

And that worked for me. After that small change I could run and debug the Azure Functions project locally again.

This isn't working for me unfortunately (with .NET 7).

MatthewSteeples commented 8 months ago

My fix was the same as @mdocter, but I also had to change the environment variable in the deployed Function app too

What did you change it to?

dotnet-isolated

karolis1994 commented 7 months ago

I am running into this problem in Azure after migrating my function app from .NET 6 "in-process" to .NET 8 "isolated" mode. The weirdest part is that when I publish directly from my visual studio, there is no problem and the function works as expected, but when I use azure pipelines to deploy it, this problem appears.

What I have tried already:

I do not want to commit to always manually publishing my function apps, even when they do not change often. So I would really like to get it to work through azure pipelines.

acarroll-trend commented 7 months ago

I ran into this issue today in my local development environment after updating the Microsoft.Azure.Functions.Worker.Sdk package from v1.15.1 to v1.17.0.

I was able to work around it by upgrading the Azure Functions Core Tools to v4.0.5504. If you're using Visual Studio to launch the tools, you'll need to force it to update like described here.

sadiqkhoja commented 4 months ago

I am getting this error on Azure intermittently, fix for me is to "Advanced Application restart" under diagnostic tools.

I have to do perform "Advance Application restart" every couple of days and then something happens (maybe system maintenance / change of instance) and I see following messages in logs:

Initializing Warmup Extension.
Initializing Host. OperationId: '27dcf955-469c-4e1d-a617-3b116bca02b4'.
Host initialization: ConsecutiveErrors=0, StartupCount=1, OperationId=27dcf955-469c-4e1d-a617-3b116bca02b4
Starting JobHost
Starting Host
Loading functions metadata
Host lock lease acquired by instance ID '4674be82b396abaf83d02ae5cb9797e3'.
Application started. Press Ctrl+C to shut down.
Hosting environment: Production
Content root path: /home/site/wwwroot/
Reading functions metadata (Custom)
1 functions found (Custom)
1 functions loaded
Generating 1 job function(s)
Worker process started and initialized.
No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
Initializing function HTTP routes No HTTP routes mapped
Host initialized (14286ms)
Host started (14336ms)
Job host started

Function Runtime version : 4.33.2.2 dotnet core: net8.0 Hosting: App Service Plan (B1)


Edit: When application runs correctly I see 2 functions found (Custom) even though I have only 1 function defined. Even when I run the app locally it says 2 functions found (Custom)

cesar-albusac commented 4 months ago

I was following the Microsoft Learn Function tutorial Exercise - Create and test a simple Azure Function locally with Visual Studio. Also, I got the same issues trying to Debug it locally.

Downgrading the Microsoft.NET.Sdk.Functions worked for me too.

jpalo commented 3 months ago

Microsoft.Azure.Functions.Worker.Sdk 1.17.2 also doesn't work, needed to downgrade to 1.15.1. #pleasefix

troyha commented 2 months ago

Microsoft.Azure.Functions.Worker.Sdk 1.17.4 also doesn't work, needed to downgrade to 1.15.1. #pleasefix

Happened to me after upgrading from net6.0 to net8.0 and upgrading the SDK package to latest.

ben-lewis-newday commented 2 months ago

Seeing the exact same issue when upgrading from .NET 6 in-process to .NET 8 isolated

John-Leitch commented 2 months ago

@ben-lewis-newday

Seeing the exact same issue when upgrading from .NET 6 in-process to .NET 8 isolated

I ran into this issue during the same upgrade. After moving from FunctionNameAttribute to FunctionAttribute, I had to replace Microsoft.Azure.WebJobs.EventHubTriggerAttribute with Microsoft.Azure.Functions.Worker.EventHubTriggerAttribute.

tolyakir commented 2 months ago

In my case the bootstrap code in Program.cs wasn't invoked at all. Adding this line to local.settings.json solved the problem without downgrading Microsoft.Azure.Functions.Worker.Sdk:

"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",

unmade-spangle commented 1 month ago

This issue happens with me as well, under .net 8, with all required properties present, running locally, with the latest version (1.22 at this time). It ran fine before, suddenly on a restart it stopped. Nothing solves it.

dsschnau commented 5 hours ago

I'm also grappling with this issue, deploying a .NET 8 dotnet-isolated application to a function app on a P0 app service plan.

I notice that the error only shows up on startup in the file system logs only, not in the app insights logs. I must have something configured incorrectly.

fijsh commented 5 hours ago

I'm also grappling with this issue, deploying a .NET 8 dotnet-isolated application to a function app on a P0 app service plan.

I notice that the error only shows up on startup in the file system logs only, not in the app insights logs. I must have something configured incorrectly.

Check if your worker runtime is set to 'dotnet-isolated' instead of 'dotnet'.

dsschnau commented 5 hours ago

It is indeed:

image

troyha commented 5 hours ago

It is indeed:

image

FUNCTIONS_INPROC_NET8_ENABLED should be 0 or not even configured (defaults to 0). Setting it to 1 is for in process which contradicts the dotnet-isolated config.

dsschnau commented 5 hours ago

Oh, interesting! I also have these configured, are they also incorrect? image

(from what I've read so far, they should be okay...)

dsschnau commented 5 hours ago

after deleting FUNCTIONS_INPROC_NET8_ENABLED, the problem persists.

fijsh commented 5 hours ago

The placeholder setting can also be removed.

dsschnau commented 5 hours ago

That didn't fix it, but something interesting happened, after a reran func azure functionapp publish to deploy, all of those environment variables returned.