The below configuration points to a single executable binary("defaultExecutablePath": "custom_handler") and using which it routes to a specfic end point based on url request.
But we want to isolate and generate unique functions using its binaries and dependencies. This way we can speed up the functions loading into the memory and execute very fast where as this fat binary takes more memory.
- We tried to deploy each function separately but its overriding the previously deployed functions even though function names are different.
- Deploying below structured project is creating multiple functions but all are sharing the same binary code which has its own disadvantage's when it comes to loading into the memory and speed of execution.
**Is there a way to isolate all these functions and execute its own binaries ? **
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"functions": [ "FunctionOne", "FunctionTwo", "FunctionThree", "FunctionFour"],
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
},
"customHandler": {
"description": {
"defaultExecutablePath": "custom_handler",
"workingDirectory": "",
"arguments": []
},
"enableForwardingHttpRequest": true
}
}
func CustomHandler(w http.ResponseWriter, req *http.Request) {
fmt.Println("CustomHandler Called")
switch req.URL.Path {
case "/api/FunctionOne":
FunctionOne.Call(w, req)
case "/api/FunctionTwo":
FunctionTwo.Call(w, req)
case "/api/FunctionThree":
FunctionThree.Call(w, req)
case "/api/FunctionFour":
FunctionFour.Call(w, req)
default:
http.NotFound(w, req)
}
func main() {
listenAddr := ":8080"
if val, ok := os.LookupEnv("FUNCTIONS_CUSTOMHANDLER_PORT"); ok {
listenAddr = ":" + val
}
http.HandleFunc("/", CustomHandler)
log.Printf("About to listen on %s. Go to https://127.0.0.1%s/", listenAddr, listenAddr)
log.Fatal(http.ListenAndServe(listenAddr, nil))
}