microsoft / azure-container-apps

Roadmap and issues for Azure Container Apps
MIT License
365 stars 29 forks source link

[dapr] Event Hubs input binding crashes dapr container #603

Open snobu opened 1 year ago

snobu commented 1 year ago

I'm trying to define a dapr Event Hubs input binding for my Container App.

Here's what i came up with -

componentType: bindings.azure.eventhubs
name: eventhub-input-binding 
version: v1
metadata:
  - name: connectionString.     # My Event Hub connection string
    value: Endpoint=sb://iothub-ns-poorlyfund-2415[.....]=;EntityPath=poorlyfundedskynet
  - name: storageAccountName    # Azure Storage Account Name
    value: "SomeStorageAccountNameHere"
  - name: storageAccountKey     # Azure Storage Account Key
    value: "nrkA[....]t2ahsCg=="
  - name: storageContainerName  # Azure Storage Container Name
    value: "SomeContainerNameHere"
scopes:
  - dapr-eventhub.   # the name of my Container App

Initially, i did not have storageAccountName and storageAccountKey in, and that made the sidecar container fail to start with storageAccountName is required, so i got the hint.

Now, the dapr sidecar container just crashes on startup and the system logs don't give me anything useful.

Is there an obvious mistake i'm making in the YAML definition?

This is what i use to apply it -

az containerapp env dapr-component set \
           --name env-dapr-eventhub \
           --resource-group dapr-eventhub \
           --dapr-component-name eventhub-input-binding \
           --yaml components/eventhubs_binding.yaml
snobu commented 1 year ago

Adding consumerGroup fixed the container startup problem, but now i'm simply not getting anything in the request body -

Container Apps Log Stream -

2023-01-27T10:51:43.30244  Connecting to the container 'dapr-eventhub'...
2023-01-27T10:51:43.32251  Successfully Connected to container: 'dapr-eventhub'
2023-01-27T10:50:26.146309473Z req.Body is: {}

My code -

func main() {
    http.HandleFunc("/eventhub-input-binding", func(rw http.ResponseWriter, req *http.Request) {
        var _time TheTime
        fmt.Printf("req.Body is: %s\n", req.Body)
        ...

dapr container -

level=info msg="app has not subscribed to binding eventhub-input-binding."

So i guess that's what i'm missing now. How do i subscribe to the binding? Also, do i really need this name property?

name: eventhub-input-binding

How does dapr know what to call inside my container? Is this what gives it the URL? I'm quite confused here.

BlackRider97 commented 4 months ago

@snobu I believe that you are missing couple of important configurations for this binding component.
Please see all required fields here https://docs.dapr.io/reference/components-reference/supported-bindings/eventhubs/

I can quickly see that eventHub and eventHubNamespace are missing, that may be a reason for events are being subscripted

I would suggest before running it on ACA, validate locally so you can isolate problem your own better.

fbcog commented 3 months ago

@BlackRider97 In the docs, it says eventHubNamespace and connectionString mutually exclude.