I am trying to run an azure function that I wrote in Java locally using func start
. This doesn’t work and this is the error message that I’m getting:
`PS C:UsersUserNamePicturesPowerPagesstyringsgruppen-powerpages-siteJavavscode> func start
Azure Functions Core Tools
Core Tools Version: 4.0.6610 Commit hash: N/A +0d55b5d7efe83d85d2b5c6e0b0a9c1b213e96256 (64-bit)
Function Runtime Version: 4.1036.1.23224
For detailed output, run func with –verbose flag.
[2025-01-07T13:56:43.088Z] Host lock lease acquired by instance ID ‘000000000000000000000000618D1A8C’.`
The class I’m trying to run is public and the method inside is also public, so this shouldn’t be the issue. The error about binding extensions shouldn’t be a problem either since I’m not using any startup code in my program. If anyone could help me with this, please respond, any feedback is appreciated.
2
Answers
please find below to step by step guide to run a java function app. there are some steps required to setup env and project in vs code. you can run cmd to launch the function app but ideally you would like to run it directly in vs code for debugging etc.
https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-cli-java?tabs=windows%2Cbash%2Cazure-cli%2Cbrowser
https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-java
To run an HTTP trigger function in Java locally, you can use the command
mvn azure-functions:run
.I tried your code, ran it using the above command, and it worked fine for me.
Sales.java :
FormParser.java :
local.settings.json :
pom.xml :
Terminal Output :
I successfully sent the POST request for the above HTTP trigger function.
I got the following logs after sending the POST request.
Azure SQL db data :