Azure function is not triggered locally

邮差的信 提交于 2020-05-15 16:30:33

问题


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


回答1:


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"}'
}



回答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.



来源:https://stackoverflow.com/questions/47002514/azure-function-is-not-triggered-locally

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!