Azure/azure-functions-java-library

Add definition for "warmup" trigger

jeffhollan opened this issue · 3 comments

There's a new trigger for Azure Functions that allows your app to "warmup" before routing traffic during scale operations. Because in Java apps function.json metadata is generated during mvn package we need to add an annotation for @WarmupTrigger

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-warmup?tabs=java

/ cc @kulkarnisonia16 @alexkarcher-msft @amamounelsayed

hi
any update on this?
i am trying to create a java azure function like:
@functionName("Warmup")
public void warmUpFunction(ExecutionContext context){
try{
connection = DriverManager.getConnection(connectionUrl);
context.getLogger().info("EventHubTriggerJavaToSQLDB.WarmUp function executed.");

    }catch (SQLException e) {
        context.getLogger().info("Exception while getting="+e.toString());
        e.printStackTrace();
    }  
}

and getting error on start up:
The 'Warmup' function is in error: At least one binding must be declared

I can't comment to the issue status, but wanted to share the following workaround.

After building, manually add a bindings element to the function.json file for your warmup triggered function:
{ "bindings": [ { "type": "warmupTrigger", "direction": "in", "name": "warmupContext" } ] ...
Reference function.json file is in this documentation: https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-warmup?tabs=csharp-script

resolved by #183

example like:

@FunctionName("Warmup")
public void warmup(@CustomBinding(direction = "in", name = "warmupContext", type = "warmupTrigger")Object warmupContext, ExecutionContext context) {
    context.getLogger().info("Function App instance is warm up");
}