• <legend id='ZUzPI'><style id='ZUzPI'><dir id='ZUzPI'><q id='ZUzPI'></q></dir></style></legend>
      <tfoot id='ZUzPI'></tfoot>

      <small id='ZUzPI'></small><noframes id='ZUzPI'>

      • <bdo id='ZUzPI'></bdo><ul id='ZUzPI'></ul>

      <i id='ZUzPI'><tr id='ZUzPI'><dt id='ZUzPI'><q id='ZUzPI'><span id='ZUzPI'><b id='ZUzPI'><form id='ZUzPI'><ins id='ZUzPI'></ins><ul id='ZUzPI'></ul><sub id='ZUzPI'></sub></form><legend id='ZUzPI'></legend><bdo id='ZUzPI'><pre id='ZUzPI'><center id='ZUzPI'></center></pre></bdo></b><th id='ZUzPI'></th></span></q></dt></tr></i><div id='ZUzPI'><tfoot id='ZUzPI'></tfoot><dl id='ZUzPI'><fieldset id='ZUzPI'></fieldset></dl></div>

      1. Azure Java 函数 -502-Bad Gateway

        Azure Java function -502-Bad Gateway(Azure Java 函数 -502-Bad Gateway)
          <tfoot id='KP3SS'></tfoot><legend id='KP3SS'><style id='KP3SS'><dir id='KP3SS'><q id='KP3SS'></q></dir></style></legend>
        • <small id='KP3SS'></small><noframes id='KP3SS'>

          • <i id='KP3SS'><tr id='KP3SS'><dt id='KP3SS'><q id='KP3SS'><span id='KP3SS'><b id='KP3SS'><form id='KP3SS'><ins id='KP3SS'></ins><ul id='KP3SS'></ul><sub id='KP3SS'></sub></form><legend id='KP3SS'></legend><bdo id='KP3SS'><pre id='KP3SS'><center id='KP3SS'></center></pre></bdo></b><th id='KP3SS'></th></span></q></dt></tr></i><div id='KP3SS'><tfoot id='KP3SS'></tfoot><dl id='KP3SS'><fieldset id='KP3SS'></fieldset></dl></div>

              <tbody id='KP3SS'></tbody>
              <bdo id='KP3SS'></bdo><ul id='KP3SS'></ul>

                  本文介绍了Azure Java 函数 -502-Bad Gateway的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我已经按照以下链接创建了 Java azure 函数:

                  现在当我尝试使用 curl 访问时

                  curl -w '
                  ' https://sundaydemo-20180526141357482.azurewebsites.net -d AzureFunctions或邮递员https://sundaydemo-20180526141357482.azurewebsites.net/api/hello

                  然后出现以下错误,我想知道是否有人遇到同样的错误.

                  <块引用>

                  502-坏网关

                  指定的 CGI 应用程序遇到错误,服务器终止了进程.

                  日志:

                  2018-05-31T02:02:50 欢迎您,您现在已连接到日志流服务.2018-05-31T02:03:50 在过去 1 分钟内没有新的跟踪.2018-05-31T02:04:50 在过去 2 分钟内没有新的跟踪.2018-05-31T02:05:50 在过去 3 分钟内没有新的踪迹.2018-05-31T02:06:50 在过去 4 分钟内没有新的痕迹.2018-05-31T02:07:50 在过去 5 分钟内没有新的痕迹.2018-05-31T02:08:50 在过去 6 分钟内没有新的痕迹.2018-05-31T02:09:17.161 [信息] 执行 'Functions.hello' (原因 ='此函数是通过主机 API 以编程方式调用的.',ID = b43d17c9-35c0-4c84-ab7e-26a8ec721fe9)2018-05-31T02:10:50 在过去 1 分钟内没有新的跟踪.2018-05-31T02:11:50 在过去 2 分钟内没有新的痕迹.2018-05-31T02:12:50 在过去 3 分钟内没有新的痕迹.2018-05-31T02:13:50 在过去 4 分钟内没有新的踪迹.2018-05-31T02:14:17.183 [错误] 函数Functions.hello"(ID:b43d17c9-35c0-4c84-ab7e-26a8ec721fe9")超过了 00:05:00 的超时值.发起取消.2018-05-31T02:14:17.451 [错误] Microsoft.Azure.WebJobs.Host:函数超过了 00:05:00 的超时值:Functions.hello.2018-05-31T02:14:17.572 [错误] 执行Functions.hello"(失败,Id=b43d17c9-35c0-4c84-ab7e-26a8ec721fe9)2018-05-31T02:15:50 在过去 1 分钟内没有新的跟踪.2018-05-31T02:16:50 在过去 2 分钟内没有新的踪迹.2018-05-31T02:17:50 在过去 3 分钟内没有新的痕迹.2018-05-31T02:18:50 在过去 4 分钟内没有新的踪迹.

                  还尝试删除所有并添加 CORS *

                  存储:

                  解决方案

                  看来你遇到了 Function Runtime 2.0 Preview Breaking Change.

                  在门户上,函数运行时已更新为 2.0.11857.0(检查您的函数应用设置面板).虽然 maven 插件还没有更新赶上来.

                  所以旧的 mvn 插件构建的代码与最新的运行时不兼容.

                  解决方法是将您的函数运行时固定到前一个.转到应用程序设置面板并将 FUNCTIONS_EXTENSION_VERSIONbeta 更改为 2.0.11776-alpha.

                  请参阅此问题讨论了解更多细节,新插件即将推出.

                  Update-6/15

                  新插件已发布.请参阅jave 语言工作者的通知.

                  • 使用最新的 Maven Azure Functions Archetype 创建新项目

                    mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype

                  • 更新现有项目以使用最新的 Azure Function mvn 插件

                    1. 函数代码(*.java)

                      之前

                      import com.microsoft.azure.serverless.functions.annotation.*;导入 com.microsoft.azure.serverless.functions.*;

                      之后(删除无服务器)

                      import com.microsoft.azure.functions.annotation.*;导入 com.microsoft.azure.functions.*;

                    2. pom.xml

                      1)之前

                      <依赖><groupId>com.microsoft.azure</groupId><artifactId>azure-functions-java-core</artifactId><版本>1.0.0-beta-2/3</版本></依赖>

                      之后

                      <依赖><groupId>com.microsoft.azure.functions</groupId><artifactId>azure-functions-java-library</artifactId><版本>1.0.0-beta-4</版本></依赖>

                      2)在excludeArtifactIds中再找到一个azure-functions-java-core,改为azure-functions-java-library.

                      3)找到azure-functions-maven-plugin,将版本改为1.0.0-beta-2.请参阅 上的最新版本maven.

                  I have created Java azure function as given on following link:

                  https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-java-maven

                  Java Class:

                  package com.khan;
                  
                  import java.util.*;
                  import com.microsoft.azure.serverless.functions.annotation.*;
                  import com.microsoft.azure.serverless.functions.*;
                  
                  /**
                   * Azure Functions with HTTP Trigger.
                   */
                  public class Function {
                      /**
                       * This function listens at endpoint "/api/hello". Two ways to invoke it using "curl" command in bash:
                       * 1. curl -d "HTTP Body" {your host}/api/hello
                       * 2. curl {your host}/api/hello?name=HTTP%20Query
                       */
                      @FunctionName("hello")
                      public HttpResponseMessage<String> hello(
                              @HttpTrigger(name = "req", methods = {"get", "post"}, authLevel = AuthorizationLevel.ANONYMOUS) HttpRequestMessage<Optional<String>> request,
                              final ExecutionContext context) {
                                  
                          context.getLogger().info("Java HTTP trigger processed a request.");
                  
                          // Parse query parameter
                          String query = request.getQueryParameters().get("name");
                          String name = request.getBody().orElse(query);
                  
                          if (name == null) {
                              return request.createResponse(400, "Please pass a name on the query string or in the request body");
                          } else {
                              return request.createResponse(200, "Hello, " + name);
                          }
                                  
                      }
                  }
                  

                  Function created and deployed successfully

                  Now when i try to access using curl

                  curl -w '
                  ' https://sundaydemo-20180526141357482.azurewebsites.net -d AzureFunctions
                  
                  or postman 
                  
                  https://sundaydemo-20180526141357482.azurewebsites.net/api/hello
                  

                  Then get following error , I am wonder if anyone getting same error.

                  502-Bad Gateway

                  The specified CGI application encountered an error and the server terminated the process.

                  Logs :

                  2018-05-31T02:02:50  Welcome, you are now connected to log-streaming service.
                  2018-05-31T02:03:50  No new trace in the past 1 min(s).
                  2018-05-31T02:04:50  No new trace in the past 2 min(s).
                  2018-05-31T02:05:50  No new trace in the past 3 min(s).
                  2018-05-31T02:06:50  No new trace in the past 4 min(s).
                  2018-05-31T02:07:50  No new trace in the past 5 min(s).
                  2018-05-31T02:08:50  No new trace in the past 6 min(s).
                  2018-05-31T02:09:17.161 [Information] Executing 'Functions.hello' (Reason='This function was programmatically called via the host APIs.', Id=b43d17c9-35c0-4c84-ab7e-26a8ec721fe9)
                  2018-05-31T02:10:50  No new trace in the past 1 min(s).
                  2018-05-31T02:11:50  No new trace in the past 2 min(s).
                  2018-05-31T02:12:50  No new trace in the past 3 min(s).
                  2018-05-31T02:13:50  No new trace in the past 4 min(s).
                  2018-05-31T02:14:17.183 [Error] Timeout value of 00:05:00 exceeded by function 'Functions.hello' (Id: 'b43d17c9-35c0-4c84-ab7e-26a8ec721fe9'). Initiating cancellation.
                  2018-05-31T02:14:17.451 [Error] Microsoft.Azure.WebJobs.Host: Timeout value of 00:05:00 was exceeded by function: Functions.hello.
                  2018-05-31T02:14:17.572 [Error] Executed 'Functions.hello' (Failed, Id=b43d17c9-35c0-4c84-ab7e-26a8ec721fe9)
                  2018-05-31T02:15:50  No new trace in the past 1 min(s).
                  2018-05-31T02:16:50  No new trace in the past 2 min(s).
                  2018-05-31T02:17:50  No new trace in the past 3 min(s).
                  2018-05-31T02:18:50  No new trace in the past 4 min(s).
                  

                  Also tried to remove all and added CORS *

                  Storage :

                  解决方案

                  It seems you met Function Runtime 2.0 Preview Breaking Change.

                  On portal, function runtime has been updated to 2.0.11857.0(Check your Function app settings panel). While maven plugin has not been updated to catch up.

                  So the code built by old mvn plugin is not compatible with latest runtime.

                  Workaround is to pin your function runtime to previous one. Go to Application settings panel and change FUNCTIONS_EXTENSION_VERSION from beta to 2.0.11776-alpha.

                  See this issue discussion for more details, new plugin is coming soon.

                  Update-6/15

                  New plugin has been released. See notice for jave language worker.

                  • Create new project using latest Maven Azure Functions Archetype

                    mvn archetype:generate -DarchetypeGroupId=com.microsoft.azure -DarchetypeArtifactId=azure-functions-archetype 
                    

                  • Update existing project to use latest Azure Function mvn plugin

                    1. function code(*.java)

                      Before

                      import com.microsoft.azure.serverless.functions.annotation.*;
                      import com.microsoft.azure.serverless.functions.*;
                      

                      After(remove serverless)

                      import com.microsoft.azure.functions.annotation.*;
                      import com.microsoft.azure.functions.*;
                      

                    2. pom.xml

                      1)Before

                      <dependency>
                          <groupId>com.microsoft.azure</groupId>
                          <artifactId>azure-functions-java-core</artifactId>
                          <version>1.0.0-beta-2/3</version>
                      </dependency>
                      

                      After

                      <dependency>
                          <groupId>com.microsoft.azure.functions</groupId>
                          <artifactId>azure-functions-java-library</artifactId>
                          <version>1.0.0-beta-4</version>
                      </dependency>
                      

                      2)Find one more azure-functions-java-core of excludeArtifactIds, change to azure-functions-java-library.

                      3)Find azure-functions-maven-plugin,change version to 1.0.0-beta-2. See Latest version on maven.

                  这篇关于Azure Java 函数 -502-Bad Gateway的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)

                    <i id='TExz3'><tr id='TExz3'><dt id='TExz3'><q id='TExz3'><span id='TExz3'><b id='TExz3'><form id='TExz3'><ins id='TExz3'></ins><ul id='TExz3'></ul><sub id='TExz3'></sub></form><legend id='TExz3'></legend><bdo id='TExz3'><pre id='TExz3'><center id='TExz3'></center></pre></bdo></b><th id='TExz3'></th></span></q></dt></tr></i><div id='TExz3'><tfoot id='TExz3'></tfoot><dl id='TExz3'><fieldset id='TExz3'></fieldset></dl></div>
                  1. <small id='TExz3'></small><noframes id='TExz3'>

                    • <bdo id='TExz3'></bdo><ul id='TExz3'></ul>

                        <tbody id='TExz3'></tbody>

                          <tfoot id='TExz3'></tfoot>
                          • <legend id='TExz3'><style id='TExz3'><dir id='TExz3'><q id='TExz3'></q></dir></style></legend>