EDIT: See some official doc available now on Folder Structure and Import behavior.
In java you can do something like this because it uses class-name.function-name as "scriptFile" in generated function.json:
public class EhConsumerFunctions {
private void processEvent(String request, final ExecutionContext context) {
// process...
}
@FunctionName("HttpTriggerFunc")
public void httpTriggerFunc(
@HttpTrigger(name = "req", methods = {HttpMethod.GET}, authLevel = AuthorizationLevel.ANONYMOUS)
HttpRequestMessage<Optional<String>> req,
final ExecutionContext context) {
processEvent(req.getBody().get(), context);
}
@FunctionName("TimerTriggerFunc")
public void timerTriggerFunc(
@TimerTrigger(name = "timerRequest", schedule = "0 */5 * * * *") String timerRequest,
final ExecutionContext context) {
processEvent(timerRequest, context);
}
}
For python, it takes script name and expects it to have a main and separate function.json. So you'll have to have two folders and two scripts. But each script can import a common business logic module which does the actual processing.
Something like:
MyFunctionApp
|____ host.json
|____ business
| |____ logic.py
|____ http_trigger
| |____ __init__.py
| |____ function.json
|____ timer_trigger
|____ __init__.py
|____ function.json
http_trigger/__init__.py will have:
from business import logic
def main(req: func.HttpRequest) -> func.HttpResponse:
return logic.process(req)
and http_trigger/function.json will have:
{
"scriptFile": "http_trigger/__init__.py",
"disabled": false,
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "res"
}
]
}