2

I create a new azure function(CosmosDB Trigger) in a project in Visual Studio.

Azure Function CosmosDB Trigger debugging does not work properly in Visual Studio. It does work for the first time visual studio starts. After that debugging stops working.

However, if I wait for 5-10 minutes, restart debugging, then the debugging would work again.

Is there a workaround available or any process to kill to make the debugging works at all times.

Ningomba
  • 45
  • 5
  • I don't understand killing a process. Cosmos Triggers happen server side and there is not enough information to go on here. How are you debugging? Can you post some code for what you're doing? Thanks. – Mark Brown Mar 22 '20 at 08:34
  • I am writing an azure function in visual studio. It is not that the debugging is not working. It works for the first time, I try to debug. If I stop the function and restart again and try to debug, it will not work. The debugging works again after 5-10 minutes. – Ningomba Mar 22 '20 at 08:44

1 Answers1

3

Check the lease collection of your trigger in your CosmosDB database. If there are any documents in there after you stopped your function, delete them. Your function is probably not freeing its lease when you stop it during debugging.

Alex AIT
  • 17,361
  • 3
  • 36
  • 73
  • Thank you, This is the solution. How do we delete the lease without going to Azure, or you suggest using emulator to make it easy. – Ningomba Mar 22 '20 at 13:48
  • You could try stopping the debugging with ctrl+c while in the console, maybe then it has enough time to clean up. Using the emulator can also make things easier – Alex AIT Mar 22 '20 at 13:57
  • Found a good post explaining how this is working: https://stackoverflow.com/questions/61686067/cosmosdb-lease-collection-is-no-longer-being-created-automatically – Mehdi Benmoha Feb 09 '21 at 11:01