0

Facing error when running Maven

I ran the command mvn -e azure-functions:run and getting the below error. I already installed the Azure Functions Core Tools from the site. What do I need to do to run mvn azure-functions:run sucessfully.

[ERROR] Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.22.0:run (default-cli) on project hello: Azure Functions Core Tools not found. Please go to https://aka.ms/azfunc-install to install Azure Functions Core Tools first. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.22.0:run (default-cli) on project hello: Azure Functions Core Tools not found. Please go to https://aka.ms/azfunc-install to install Azure Functions Core Tools first. at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156) at org.apache.maven.lifecycle.internal.MojoExecutor.execute (M

Need to run mvn -e azure-functions:run successfully but facing the errors as shown below. Also I installed Azure Function tool locally.

[ERROR] Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.22.0:run (default-cli) on project hello: Azure Functions Core Tools not found. Please go to https://aka.ms/azfunc-install to install Azure Functions Core Tools first. -> [Help 1] org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.microsoft.azure:azure-functions-maven-plugin:1.22.0:run (default-cli) on project hello: Azure Functions Core Tools not found. Please go to https://aka.ms/azfunc-install to install Azure Functions Core Tools first.

8
  • If you are running your code from VS Code, have you installed Azure Functions from your VS Code Extension like this? Commented Apr 3, 2024 at 7:57
  • Have you installed Azure Tools from VS Code Extension? Commented Apr 3, 2024 at 8:05
  • After successful installation of Azure Function Core Tools from this Doc, Azure Functions and Azure Tools from Vs code Extension, try to restart the VS Code and run the code again using this command mvn azure-functions:run. Commented Apr 3, 2024 at 8:13
  • I can able to run the code with the command see this, output. Commented Apr 3, 2024 at 8:22
  • 1
    I am using STS IDE for development and not VS Code. How do we configure if we use different IDE apart from VS Code? Commented Apr 3, 2024 at 14:04

1 Answer 1

0

In addition to my comments, I fixed the issue by installing the Azure Functions Core Tools from this document, as shown in the image below.

enter image description here

I tried the sample code below with an HTTP trigger function in Java.

Code :

Function.java :

package com.function;

import com.microsoft.azure.functions.ExecutionContext;
import com.microsoft.azure.functions.HttpMethod;
import com.microsoft.azure.functions.HttpRequestMessage;
import com.microsoft.azure.functions.HttpResponseMessage;
import com.microsoft.azure.functions.HttpStatus;
import com.microsoft.azure.functions.annotation.AuthorizationLevel;
import com.microsoft.azure.functions.annotation.FunctionName;
import com.microsoft.azure.functions.annotation.HttpTrigger;

import java.util.Optional;

public class Function {
    @FunctionName("HttpExample")
    public HttpResponseMessage run(
            @HttpTrigger(
                name = "req",
                methods = {HttpMethod.GET, HttpMethod.POST},
                authLevel = AuthorizationLevel.ANONYMOUS)
                HttpRequestMessage<Optional<String>> request,
            final ExecutionContext context) {
        context.getLogger().info("Java HTTP trigger ran successfully.");
        final String query = request.getQueryParameters().get("name");
        final String name = request.getBody().orElse(query);

        if (name == null) {
            return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Provide a name to get request").build();
        } else {
            return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();
        }
    }
}

local.settings.json :

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "<storage_conne>",
    "FUNCTIONS_WORKER_RUNTIME": "java"
  }
}

Run Command :

mvn clean package
mvn -e azure-functions:run 
          (or)
mvn azure-functions:run

Output :

The following HTTP trigger function in Java ran successfully, as shown below:

enter image description here

Browser output :

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.