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

David 5 Reputation points
2024-05-17T14:45:18.0733333+00:00

Hello,

I am having a problem and suspecting it is a bug. Was thinking to create a bug on GitHub, but figured that I might get a faster answer here and maybe there is an obvious fix. I am using VS Codes Azure Function extension to create the standard typescript code base for an Azure Function and then try to start debugging locally form the vs code extension. In the terminal I then get the error:

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

And in the extension gives me the error: Error: connect ECONNREFUSED 127.0.0.1:7071. This error happens with all functions that I want to debug locally, so I cant work on any Azure Functions, but in the case I provide here all files are completely the standard generated ones (by the Azure Function Extension for VS Code), but I will post them anyway here to make sure. host.json:

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

package.json:

{
  "name": "hforce-devops-github-automatizations-temporary",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "build": "tsc",
    "watch": "tsc -w",
    "clean": "rimraf dist",
    "prestart": "npm run clean && npm run build",
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {
    "@azure/functions": "^4.0.0"
  },
  "devDependencies": {
    "@types/node": "^18.x",
    "typescript": "^4.0.0",
    "rimraf": "^5.0.0"
  },
  "main": "dist/src/functions/*.js"
}

local.settings.json:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=...",
    "FUNCTIONS_WORKER_RUNTIME": "node",
    "AzureWebJobsFeatureFlags": "EnableWorkerIndexing"
  }
}

tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "outDir": "dist",
    "rootDir": ".",
    "sourceMap": true,
    "strict": false
  }
}

and the src\functions\manualTestTagUpdate.ts:

import { app, HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions";

export async function manualTestTagUpdate(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> {
    context.log(`Http function processed request for url "${request.url}"`);

    const name = request.query.get('name') || await request.text() || 'world';

    return { body: `Hello, ${name}!` };
};

app.http('manualTestTagUpdate', {
    methods: ['GET', 'POST'],
    authLevel: 'anonymous',
    handler: manualTestTagUpdate
});

I dont know how interesting it is, but I will also provide the whole terminal output:

 *  Executing task: npm install 


up to date, audited 50 packages in 698ms

14 packages are looking for funding     
  run `npm fund` for details

found 0 vulnerabilities
 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: npm run clean 


> hforce-devops-github-automatizations-temporary@1.0.0 clean
> rimraf dist

 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: npm run build 


> hforce-devops-github-automatizations-temporary@1.0.0 build
> tsc

 *  Terminal will be reused by tasks, press any key to close it. 

 *  Executing task: func host start 


Azure Functions Core Tools
Core Tools Version:       4.0.4483 Commit hash: N/A  (64-bit)
Function Runtime Version: 4.1.3.17473

[2024-05-17T14:25:48.952Z] 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.).
For detailed output, run func with --verbose flag.
[2024-05-17T14:25:54.307Z] Host lock lease acquired by instance ID '000000000000000000000000DBED5792'.

Would be nice to have some feedback on what the problem could be and some possible fixes.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,421 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 13,871 Reputation points
    2024-05-20T17:27:38.91+00:00

    Hi @David Greetings! Welcome to Microsoft Q&A forum. Thank you for posting this question here.

    Your code and the files generated by the Azure Function Extension seems fine. I have tested the same code with the exact same generated files, and I could successfully debug the code locally.

    The error message Error: connect ECONNREFUSED 127.0.0.1:7071 implies that function could not connect to the port 7071. Verify if you have any firewall or antivirus programs blocking the connection to the port. Once you run the Azure function locally you can check the processes listening on the port 7071 using the command - netstat -ano | findstr :7071. Please find the below image for reference.

    enter image description here

    Try executing the function on a different port using the below command from the terminal window.

    func start --port <port number>
    

    If you still encounter the same issue capture the verbose level logging using the command func start --verbose from terminal and see if you get any additional logging.

    Hope this helps! If you need any additional assistance, please let us know in the comments below.

    Solution

    Issue is most likely with older versions of Azure CLI and azure-functions-core-tools. Reinstalling Azure CLI and azure-functions-core-tools helped resolve the issue.


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.