I am experimenting with an odd scenario. Basically I want to subscribe to a Dapr Topic from a Go function inside Azure Functions.
For the Go function, I was able to register a Custom Handler that can handle the HTTP Requests:
func orderHandler(w http.ResponseWriter, r *http.Request) {
log.Println("Handler invoked from an event")
var invokeRequest InvokeRequest
d := json.NewDecoder(r.Body)
if err := d.Decode(&invokeRequest); err != nil {
log.Fatal("Error while decoding the Body")
return
}
log.Println(invokeRequest)
}
And inside the main function, I have the code to register the endpoints
func main() {
customHandlerPort, exists := os.LookupEnv("FUNCTIONS_CUSTOMHANDLER_PORT")
if !exists {
customHandlerPort = "8080"
}
mux := http.NewServeMux()
mux.HandleFunc("/orders", orderHandler)
fmt.Println("Go server Listening on: ", customHandlerPort)
log.Fatal(http.ListenAndServe(":"+customHandlerPort, mux))
}
I added the customHandler property inside the host.json file:
Inside the components folder I only have one file called pubsub.yaml, which contains the Redis Component.
Right after the initialization I get this error:
time="2024-03-06T10:13:24.3482556-03:00" level=error msg="app returned http status code 500 from subscription endpoint" app_id=functionA instance= scope=dapr.runtime.processor.pubsub type=log ver=1.12.5
I suppose there's something going on with the Subscription Endpoint, which is falling with 500 HTTP Error in Dapr initialization and also when I try to call localhost:3001/dapr/subscribe
Is there a way to run a Custom Handler with Dapr Topic Subscription in Azure Functions?
I have also tried:
Creating a dapr/subscribe and /orders HTTP Trigger.
I am experimenting with an odd scenario. Basically I want to subscribe to a Dapr Topic from a Go function inside Azure Functions.
For the Go function, I was able to register a Custom Handler that can handle the HTTP Requests:
And inside the main function, I have the code to register the endpoints
I added the
customHandler
property inside thehost.json
file:And created Function called
DaprEventTrigger
with the followingfunction.json
:To run this I am running the following cmd:
Inside the
components
folder I only have one file calledpubsub.yaml
, which contains the Redis Component.Right after the initialization I get this error:
I suppose there's something going on with the Subscription Endpoint, which is falling with 500 HTTP Error in Dapr initialization and also when I try to call
localhost:3001/dapr/subscribe
Is there a way to run a Custom Handler with Dapr Topic Subscription in Azure Functions?
I have also tried:
dapr/subscribe
and/orders
HTTP Trigger.