繁体   English   中英

Java Azure Function 不在本地执行

[英]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*

*模板有一个简单的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
}

在执行 mvn azure-functions:run 时,应用程序成功启动,我在命令提示符下得到以下信息

[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'. 

但是当我尝试从 postman 中点击 api( http://localhost:7071/api/hello ) 时,我没有得到任何响应,我在命令提示符中看到以下内容

[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)

在此之后没有任何反应:30 分钟后,我在命令提示符中收到如下超时异常:

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

有人可以提出可能导致这种情况的原因,为什么在 postman 中没有看到任何响应,我在这里做错了吗? 我是否缺少任何配置内容? 及时的帮助将不胜感激

请检查您的 function 代码。

根据您提供的信息,触发器已经被触发。 这意味着您的触发器内的代码逻辑尚未完成。 换句话说,你成功触发了触发器,但是你卡在了触发器的内部逻辑中。 请检查您的代码。

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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