Closed jeffhollan closed 2 years ago
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 https://github.com/Azure/azure-functions-java-library/pull/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");
}
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 duringmvn package
we need to add an annotation for @WarmupTriggerhttps://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-warmup?tabs=java
/ cc @kulkarnisonia16 @alexkarcher-msft @amamounelsayed