I have developed an azure function app. It is in Python and works perfectly fine. I first developed this in a virtual environment using pyenv on my laptop.
Now, I switched to another laptop, downloaded the function app and set a new virtual environment for this laptop. The function starts fine and the virtual environment works. The packages are installed as far as I can see.
However, when starting the function, I get 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.)’.
I have seen others with similar issues. However, these issues were mostly in the host.json and the local.settings.json.I have not yet been able to find a solution to it, or an error in both of these files. Also, my function_app.py does not throw any errors (possibly because it is not seen…)
The first few lines of my function_app.py, where i added the @app.function_name line as per previous posts:
app = func.FunctionApp(http_auth_level=func.AuthLevel.ANONYMOUS)
@app.function_name("func")
@app.route(route="http_example", auth_level=func.AuthLevel.ANONYMOUS)
def http_trigger(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')
the host.json:
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.15.0, 4.0.0)"
}
}
the local.settings.json:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
"AzureWebJobsStorage": "UseDevelopmentStorage=true"
}
}
It is good to know that this is another laptop, logged in with an account from another tenant. I am not sure if this may cause an issue.
Thank you in advance.
EDIT:
Screenshot of the folder structure:
folderstructure
launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Python Functions",
"type": "debugpy",
"request": "attach",
"connect": {
"host": "localhost",
"port": 9091
},
"preLaunchTask": "func: host start"
}
]
}
2
Answers
My problem was in the fact that I was using an old version of the Functions Core Tools. I have updated this version to version 4 with command:
Thanks to @Ikhtesam Afrin, who helped me through the comments.
In order to avoid this error, please follow below steps-
It is recommended to use V4 version of Azure Function core Tools. You can either install it using MSI or
npm i -g azure-functions-core-tools@4 --unsafe-perm true
, refer Azure Functions Core Tools Versions.Either navigate to Run -> Start debugging in vs code or use
func host start
command in terminal to execute your function.You will get the expected response.