简体   繁体   中英

Java Azure Function Not Executing Locally

Hi all, I'm working on Azure functions, I'm new to this, I have created a local java Azure function project using the below archetype:

*mvn archetype:generate -DgroupId=com.mynew.serverlesstest -DartifactId=serverlessexample - 
DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype - 
DinteractiveMode=false*

*The template has a simple java function.

Upon executing a "mvn clean package" command, function.json gets generated in the target folder for the function, below is my function.json*

{
  "scriptFile" : "..\\serverlessexample-1.0-SNAPSHOT.jar",
  "entryPoint" : "com.mynew.serverlesstest.Function.hello",
  "bindings" : [ {
    "type" : "httpTrigger",
    "name" : "req",
    "direction" : "in",
    "authLevel" : "anonymous",
    "methods" : [ "get", "post" ]
  }, {
    "type" : "http",
    "name" : "$return",
    "direction" : "out"
  } ],
  "disabled" : false
}

on doing a mvn azure-functions:run, the application starts successfully, and I get below in the command prompt :

[06-04-2020 07:26:55] Initializing function HTTP routes
[06-04-2020 07:26:55] Mapped function route 'api/hello' [get,post] to 'hello'
[06-04-2020 07:26:55] Mapped function route 'api/HttpTrigger-Java' [get,post] to 'HttpTrigger-Java'
[06-04-2020 07:26:55]
[06-04-2020 07:26:55] Host initialized (424ms)
[06-04-2020 07:26:55] Host started (433ms)
[06-04-2020 07:26:55] Job host started

Http Functions:

      hello: [GET,POST] Hosting environment: Production
      http://localhost:7071/api/hello
      Content root path: C:\Users\ramaswamys\Development\azure- 
      serverless\serverlessexample\target\azure-functions\serverlessexample-20200403205054646
      Now listening on: http://0.0.0.0:7071
      Application started. Press Ctrl+C to shut down.   

      HttpTrigger-Java: [GET,POST] http://localhost:7071/api/HttpTrigger-Java

      [06-04-2020 07:27:00] Host lock lease acquired by instance ID 
      '000000000000000000000000852CF5C4'. 

But when I try hitting the api( http://localhost:7071/api/hello ) from postman, I dont get any response, I see the below in the command prompt :

[06-04-2020 07:29:04] Executing HTTP request: {
[06-04-2020 07:29:04]   "requestId": "af46115f-7a12-49a9-87e0-7fb073a66450",
[06-04-2020 07:29:04]   "method": "GET",
[06-04-2020 07:29:04]   "uri": "/api/hello"
[06-04-2020 07:29:04] }
[06-04-2020 07:29:05] Executing 'Functions.hello' (Reason='This function was programmatically called 
via the host APIs.', Id=7c712cdf-332f-413f-bda2-138f9b89025b)

After this nothing happens: after 30 min I get a timeout exception like below in the command prompt:

Microsoft.Azure.WebJobs.Host: Timeout value of 00:30:00 was exceeded by function: Functions.hello.

Can someone suggest what might be causing this, why no response is seen in the postman, Am I doing any thing wrong here? Am I missing any configuration stuff? Timely help would be appreciated

Please have a check of your function code.

From the info you offer, the trigger has already be triggered. So that means the code logic inside your trigger is not completed. In other words, you successfully triggered the trigger, but you are stuck in the internal logic of the trigger. Please check your code.

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM