Azure java function : No HTTP triggers found when deploying

141 Views Asked by At

I just wrote a new function with java runtime 17. Locally, I am able to run the azure function but the deployment is giving "No HTTP triggers found.". This started happening today. It was working till yesterday. Not sure what has changed for java on jan 31st 2024.

{
  "version": "2.0",
  "logging": {
    "applicationInsights": {
      "samplingSettings": {
        "isEnabled": true,
        "excludedTypes": "Request"
      }
    }
  },
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[4.*, 5.0.0)"
  }
}

Deployment:

10:29:46 PM njs123: c:\trunk\jj\build\tmp\jar\MANIFEST.MF
10:29:46 PM njs123: c:\trunk\jj\build\azure-functions\jj-1706844397343\host.json
10:29:46 PM njs123: c:\trunk\jj\build\azure-functions\jj-1706844397343\local.settings.json
10:29:46 PM njs123: c:\trunk\jj\build\azure-functions\jj-1706844397343\HttpTriggerJava1\function.json
10:29:46 PM njs123: c:\trunk\jj\build\azure-functions\jj-1706844397343\jj-1.0-SNAPSHOT.jar
10:29:46 PM njs123: c:\trunk\jj\build\azure-functions\jj-1706844397343\lib\azure-functions-java-core-library-1.0.0.jar
10:29:46 PM njs123: c:\trunk\jj\build\libs\jj-1.0-SNAPSHOT.jar
10:29:46 PM njs123: c:\trunk\jj\build\classes\java\main\com\fun

Code:

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

public class HttpTriggerJava1 {
@FunctionName("HttpTriggerJava1")
public HttpResponseMessage run(
        @HttpTrigger(name = "req", methods = {HttpMethod.GET, 
HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION) 
  HttpRequestMessage<Optional<String>> request,
        final ExecutionContext context) {
    context.getLogger().info("Java HTTP trigger processed a 
    request.");
    String query = request.getQueryParameters().get("name");
    String name = request.getBody().orElse(query);
    if (name == null) {
        return 
request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please 
pass a name on the query string or in the request body").build();
    } else {
        return 
request.createResponseBuilder(HttpStatus.OK).body("Hello, " + 
name).build();
      }
   }
}
1

There are 1 best solutions below

0
Pravallika KV On

I was facing the same issue while deploying Java Http Triggered Azure function using Visual Studio code.

To resolve this, I have downgraded Azure Functions Extension version to 1.13.1 in Visual Studio Code=>Extensions=> Search for Azure Functions=>click on drop down of Uninstall->select Install other version=>select 1.13.1 version.

enter image description here

Local response:

enter image description here

9:48:10 PM: Running command: "mvn archetype:generate -DarchetypeGroupId="com.microsoft.azure" -DarchetypeArtifactId="azure-functions-archetype" -DarchetypeVersion="LATEST" -DjavaVersion="17" -DgroupId="com.function" -DartifactId="javafn" -Dversion="1.0-SNAPSHOT" -Dpackage="com.function" -DappName="javafn-1707149882549" -B"...
[INFO] Scanning for projects...
[INFO] 
[INFO] ------------------< org.apache.maven:standalone-pom >-------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] --------------------------------[ pom ]---------------------------------
[INFO] 
[INFO] >>> archetype:3.2.1:generate (default-cli) > generate-sources @ standalone-pom >>>
[INFO] 
[INFO] <<< archetype:3.2.1:generate (default-cli) < generate-sources @ standalone-pom <<<
[INFO] 
[INFO] 
[INFO] --- archetype:3.2.1:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Batch mode
[INFO] Archetype repository not defined. Using the one from [com.microsoft.azure:azure-functions-archetype:1.52] found in catalog remote
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: azure-functions-archetype:LATEST
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: com.function
[INFO] Parameter: artifactId, Value: javafn
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: package, Value: com.function
[INFO] Parameter: packageInPathFormat, Value: com/function
[INFO] Parameter: resourceGroup, Value: java-functions-group
[INFO] Parameter: package, Value: com.function
[INFO] Parameter: appName, Value: javafn-1707149882549
[INFO] Parameter: javaVersion, Value: 17
[INFO] Parameter: groupId, Value: com.function
[INFO] Parameter: artifactId, Value: javafn
[INFO] Parameter: appServicePlanName, Value: java-functions-app-service-plan
[INFO] Parameter: trigger, Value: HttpTrigger
[INFO] Parameter: appRegion, Value: westus
[INFO] Parameter: version, Value: 1.0-SNAPSHOT
[INFO] Parameter: docker, Value: false
[INFO] Executing META-INF/archetype-post-generate.groovy post-generation script
[INFO] Project created from Archetype in dir: C:\Users\uname\AppData\Local\Temp\38be4356cf\javafn
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  9.489 s
[INFO] Finished at: 2024-02-05T21:48:24+05:30
[INFO] ------------------------------------------------------------------------
Finished running command: "mvn archetype:generate -DarchetypeGroupId="com.microsoft.azure" -DarchetypeArtifactId="azure-functions-archetype" -DarchetypeVersion="LATEST" -DjavaVersion="17" -DgroupId="com.function" -DartifactId="javafn" -Dversion="1.0-SNAPSHOT" -Dpackage="com.function" -DappName="javafn-1707149882549" -B".
9:50:28 PM pravjavafunc: Stopping app...
9:50:30 PM pravjavafunc: Starting deployment...
9:50:30 PM pravjavafunc: Creating zip package...
9:50:30 PM pravjavafunc: Zip package size: 20.3 kB
9:50:54 PM pravjavafunc: Updating submodules.
9:50:54 PM pravjavafunc: Preparing deployment for commit id '818babcf62'.
9:50:55 PM pravjavafunc: Skipping build. Project type: Run-From-Zip
9:50:55 PM pravjavafunc: Skipping post build. Project type: Run-From-Zip
9:50:55 PM pravjavafunc: Triggering recycle (preview mode disabled).
9:50:56 PM pravjavafunc: Deployment successful.
9:50:59 PM pravjavafunc: Starting app...
9:51:11 PM pravjavafunc: Syncing triggers...
9:51:15 PM pravjavafunc: Querying triggers...
9:51:20 PM pravjavafunc: HTTP Trigger Urls:
  HttpExample: https://pravjavafunc.azurewebsites.net/api/httpexample

Portal:

enter image description here

Response:

enter image description here