Orleans crashes on Azure Web App when Application Insights is enabled
- Dominant language
- C#
- Stars
- 10.9k
- Forks
- 2.1k
- Avg merge
- 14h 57m
- Merged PRs (30d)
- 349
Description
We have Orleans silo running on Azure Web App and another Web App that runs an API that does the calls to Orleans.
To run Orleans the Silo Web App must have the vnetPrivatePortsCount enabled, which will provide the ports to connect the API to the silo, and both Web Apps communicate through a VNet.
When we enabled Application Insights to get metrics from performance and manage logs, it worked properly with the API Web App. **Enabling on the silo, the Web App stops to work.**
Looking for the cause, we found that when App Insights is enabled, the ports Orleans gets on [dbo].[OrleansMembershipTable] are different from the ones showing as available on the Web App WEBSITE_PRIVATE_PORTS environment variable, not using the private ports and instead, it tries to increase the port numbers and use those. The method we use to do this is ConfigureEndpoints and we use the WEBSITE_PRIVATE_PORTS.
```
PAddress endpointAddress = IPAddress.Parse(configuration!.GetValue(EnvironmentVariables.WebAppsPrivateIPAddress)!);
string[] strPorts = configuration!.GetValue(EnvironmentVariables.WebAppsPrivatePorts)!.Split(',');
siloBuilder.ConfigureEndpoints(endpointAddress, int.Parse(strPorts[0]), int.Parse(strPorts[1]), listenOnAnyHostAddress: true);
```
After we disabled the Applications Insights, Orleans returned to the initial state, working properly getting the correct ports from the WEBSITE_PRIVATE_PORTS environment variable.
Contributor guide
Assessment
This issue has not been assessed yet.