Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure function apps and web sockets

I can see multiple places that web sockets are not supported in function apps. I just want to create a web socket for some seconds and close it down again. So I do not have a need for a complex socket framework. I was wondering why this settings is present if it is not supported? Has Microsoft started supporting this feature?

enter image description here

like image 666
Thomas Segato Avatar asked May 28 '26 22:05

Thomas Segato


1 Answers

Azure Functions are generally hosted in 2 ways:

  1. Consumption Plan (Serverless)
  2. App Service Plan (Dedicated)

Consumption Plan (Serverless)

In this plan, the underlying machine is de-provisioned when the server is idle. So, you may lose your active Web-Socket connections when the machine is idle and de-provisioned.

Also, below is the statement from the Microsoft Azure Function team:

There are some challenges here because WebSocket is really a stateful protocol (you have a long lived connection between a given client and a given server) while Azure Functions is designed to be stateless. For example, we will often deprovision a Function App from one VM and start it on a different VM (perhaps in a different scale unit) based on capacity constraints. This is safe to do for us today because of our stateless design - but if we did it when there were WebSockets connections to that VM, we'd be terminating those connections. Source: GitHub

App Service Plan (Dedicated)

If you are using a dedicated App Service Plan, then Web Sockets will work for sure, because there is a machine in the background which is not serverless (always available).

Just make sure you have enabled Web Sockets in the configuration (as you have done already).

Check web-socket connection limits for App Service Plans from here - App Service limits Web Sockets Limit

like image 130
Ankush Jain Avatar answered May 30 '26 10:05

Ankush Jain



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!