Azure function is not triggered locally
Asked Answered
W

2

2

I developed my Azure function app locally using VScode and pushed it to azure cloud, I have eventhub-trigger functions, I used to debug my code locally through VScode normally, but now when I run func host start --debuge, functions in my app started but nothing is triggered, I can see them triggered on the cloud through their log, it drive me mad, why they are not triggered locally, they are enabled, I restarted my function app several times, but I got nothing. My app is https://butterflyfnapp.azurewebsites.net

Wilbertwilborn answered 29/10, 2017 at 16:26 Comment(2)
Do you use the same Blob Storage locally and in Azure? Are there competing with each other?Christology
I'm using Table storage, the same code is on both on cloud and locally, I need to develop/add a piece of code locally, when done I will push it to cloud, do u think that I have to delete the cloud code first, or what shall I do.Wilbertwilborn
H
3

In additional to Mikhail, other option is to create a separate consumer group of the Event Hub for each environment such as a cloud and development/VS and configured them in the Application settings or local.settings.json. Then add the ConsumerGroup = "%consumergroup%" to the EventHubTrigger argument in your function, where the consumergroup is an example of the variable name in the settings.

Beside the above options, still you have a capability for testing a non-Http trigger function locally using a Http POST request. In other words, your function can be tested locally the same way like is done in the portal. More details here.

The following is an example of the testing EventHubTrigger function using a Http POST request:

url: http://localhost:7071/admin/functions/MyFunction

payload:

{
  "input": '{"Id":1234,"Name":"abcd"}'
}
Hesperian answered 30/10, 2017 at 16:51 Comment(0)
C
2

Event Hub consumer information (checkpoints) are stored in Blob Storage. If you share the connection string to Blob Storage between development / production environments, they will use the same checkpoints, so they will compete against each other.

My guess is that your cloud deployment always processes the events, updates the checkpoint to the latest position, and then local deployment takes this checkpoint and doesn't do anything.

To make sure this doesn't happen, create an additional "dev" Blob Storage and set the local connection string setting to that storage.

Christology answered 30/10, 2017 at 12:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.