Azure-Samples / Orleans-Cluster-on-Azure-App-Service

Sample application demonstrating a multiple-silo Orleans cluster running in Azure App Service.
MIT License
66 stars 51 forks source link

Not working on Linux app service #4

Closed pableess closed 1 year ago

pableess commented 1 year ago

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [x ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Change app-service.bicep so that app service plan and app service are on linux. The application will not strart up because it cannot listen on the silo IP address.

param appName string param location string param vnetSubnetId string param appInsightsInstrumentationKey string param appInsightsConnectionString string param storageConnectionString string

resource appServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = { name: '${appName}-plan' location: location kind: 'linux' sku: { name: 'S1' capacity: 1 } properties:{ reserved: true } }

resource appService 'Microsoft.Web/sites@2021-03-01' = { name: appName location: location properties: { serverFarmId: appServicePlan.id virtualNetworkSubnetId: vnetSubnetId httpsOnly: true siteConfig: {
linuxFxVersion: 'DOTNETCORE|6.0'
vnetPrivatePortsCount: 2 webSocketsEnabled: true netFrameworkVersion: 'v6.0' appSettings: [ { name: 'APPINSIGHTS_INSTRUMENTATIONKEY' value: appInsightsInstrumentationKey } { name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' value: appInsightsConnectionString } { name: 'ORLEANS_AZURE_STORAGE_CONNECTION_STRING' value: storageConnectionString } ] alwaysOn: true } } }

resource appServiceConfig 'Microsoft.Web/sites/config@2021-03-01' = { name: '${appService.name}/metadata' properties: { CURRENT_STACK: 'dotnet' } }

Any log messages given by the failure

2023-02-16T07:06:15.725045408Z SiloConnectionListener failed to start due to errors at stage 1999: System.Net.Sockets.SocketException (99): Cannot assign requested address

2023-02-16T07:06:15.725052008Z at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)

2023-02-16T07:06:15.725055908Z at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)

2023-02-16T07:06:15.725059608Z at System.Net.Sockets.Socket.Bind(EndPoint localEP)

2023-02-16T07:06:15.725063408Z at Orleans.Networking.Shared.SocketConnectionListener.Bind() in /_/src/Orleans.Core/Networking/Shared/SocketConnectionListener.cs:line 63

2023-02-16T07:06:15.725081809Z at Orleans.Networking.Shared.SocketConnectionListenerFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken) in /_/src/Orleans.Core/Networking/Shared/SocketConnectionListenerFactory.cs:line 41

2023-02-16T07:06:15.725086209Z at Orleans.Runtime.Messaging.ConnectionListener.BindAsync(CancellationToken cancellationToken) in /_/src/Orleans.Runtime/Networking/ConnectionListener.cs:line 72

2023-02-16T07:06:15.725090009Z at Orleans.Runtime.Messaging.SiloConnectionListener.OnRuntimeInitializeStart(CancellationToken cancellationToken) in /_/src/Orleans.Runtime/Networking/SiloConnectionListener.cs:line 76

2023-02-16T07:06:15.725093709Z at Orleans.Runtime.SiloLifecycleSubject.MonitoredObserver.OnStart(CancellationToken ct) in /_/src/Orleans.Runtime/Lifecycle/SiloLifecycleSubject.cs:line 116

2023-02-16T07:06:15.734193978Z fail: Orleans.Runtime.SiloLifecycleSubject[100450]

Expected/desired behavior

OS and Version?

Azure App Service Linux plan, S1

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

pableess commented 1 year ago

Update:

I figured out that this issue was caused by 2 things.

  1. My use of the Orleans Dashboard, which was using port 8080, which was also what Azure App Service was trying to use for the aspnetcore application.
  2. When running on linux the app is actually running in a docker container, hence it cannot listen on WEBSITE_PRIVATE_IP. To deal with this, I have changed the listen on loopback address but advertise the WEBSITE_PRIVATE_IP
            return siloBuilder.Configure<EndpointOptions>(e =>
            {
                e.SiloPort = siloPort;
                e.GatewayPort = gatewayPort;
                e.AdvertisedIPAddress = endpointAddress;
                e.GatewayListeningEndpoint = new IPEndPoint(IPAddress.Loopback, gatewayPort);
                e.SiloListeningEndpoint = new IPEndPoint(IPAddress.Loopback, siloPort);
            });

Now the app starts, however when I scale out, the nodes cannot communicate with each over over the VNET. My guess is because the linux container that app services uses does not expose the WEBSITE_PRIVATE_PORTS. I am wondering if maybe this can be done with a custom container but I am still not sure if it is possible to expose the WEBSITE_PRIVATE_PORTS to the VNET?

Do you know if this scenario is possible?

windperson commented 1 year ago

Hi @pableess ,

I''ve managed to run an .NET 6 with Orleans v4.3 example on App Service Linux: https://github.com/windperson/OrleansUrlShortener/tree/AzureWebApp-Linux

There are many tweaks for silo hosting builder code than the Windows App Service:

I've wrote an article contains detail explanations, but it is currently only Chinese version available: https://ithelp.ithome.com.tw/articles/10310277

pableess commented 1 year ago

I have been able to successfully run orleans based app on Linux App Service.

My fork of this repository is here which I used to test.

https://github.com/pableess/Orleans-Cluster-on-Azure-App-Service