slackapi / bolt-python

A framework to build Slack apps using Python
https://slack.dev/bolt-python/
MIT License
1.05k stars 245 forks source link

Using Bolt with Azure Functions Python #1101

Closed mmercad0 closed 3 months ago

mmercad0 commented 3 months ago

Is it possible to use Bolt to develop an app hosted as an Azure Function? If so, can you provide an example please? If not in Bolt, is it better to use the Web SDK in this case?

seratch commented 3 months ago

Hi @mmercad0, thanks for asking this. It's feasible but I personally don't recommend. Please refer to this comment for more details: https://github.com/slackapi/bolt-python/issues/641#issuecomment-1113853153

mmercad0 commented 3 months ago

Thank you so much, @seratch for the information. This was very helpful.

Based on your comment, you don't recommend it due to the possible cold start of Azure Functions. I plan to have a separate scheduled Azure Function that keeps the one that handles Slack requests awake.

Is there another reason why you don't recommend it? What do you recommend instead?

Thanks again! Marcos

seratch commented 3 months ago

At least at that time, just invoking an Azure Functions function could occasionally take a few seconds (meaning much longer than 3 seconds, which is Slack's requirement). If your approach (like a kind of warm-up?) can consistently prevent this from happening, that could be a solution. I don't have knowledge here, though. Other than the cold start risk, I don't think there are any other known issues with Azure Functions.

If I were to suggest anything else, I would suggest a container-based runtime instead. I am not an Azure expert, but perhaps Azure Container Instances should be the one on the platform. I understand you're interested in FaaS mainly for cost efficiency, though.

I hope this helps! As we don't officially support Azure platform, we won't be able to provide further help on this topic. When you have general questions about Azure, please consult their forums.