Hosting Streamlit on Azure Compure Instance

I am trying to host a Streamlit app on Azure Compute Instance resource.

It appears that accessing the instance is possible through https://{instanceName}-{internalPort}.northeurope.instances.azureml.ms (with an Azure-provided security layer in between).

To smoketest this I created a simple Flask app and verified I could access it: I was able to access my dummy app on https://[REDACTED]-5000.northeurope.instances.azureml.ms/, since it was running on port 5000 internally.


Attempt 1: Basic Configuration

Now I want to serve my Streamlit app. Initially I wanted to eliminate error sources and simply check if wires are connected correctly, and my app is simply:

import streamlit as st

st.title("Hello, World!")

Running this streamlit app (streamlit run sl_app.py) gives:

2022-03-28 11:49:38.932 Trying to detect encoding from a tiny portion of (13) byte(s).
2022-03-28 11:49:38.933 ascii passed initial chaos probing. Mean measured chaos is 0.000000 %
2022-03-28 11:49:38.933 ascii is most likely the one. Stopping the process.

  You can now view your Streamlit app in your browser.

  Network URL: http://[REDACTED]:8501
  External URL: http://[REDACTED]:8501

Trying to access this through https://[REDACTED]-8501.northeurope.instances.azureml.ms/ I can access the app, but the “Please wait…” indicator appears indefinitely:

enter image description here

Attempt 2: Updated Streamlit Config

Inspired by App is not loading when running remotely Symptom #2 I created a Streamlit config.toml with a reconfiguring of server/browser access points, and ended up with the following:

[browser]
serverAddress = "[REDACTED]-8501.northeurope.instances.azureml.ms"
serverPort = 80
gatherUsageStats = false

[server]
port = 8501
headless = true
enableCORS = false
enableXsrfProtection = false
enableWebsocketCompression = false

Running the app now gives:


  You can now view your Streamlit app in your browser.

  URL: http://[REDACTED]-8501.northeurope.instances.azureml.ms:80

However, I still get the infinite Please wait-indicator. Diving a little bit deeper reveals something related to a wss stream? Whatever that is?

enter image description here

I suspect that what I’m seeing is due to the fact that Azure automatically pipes my request from http:// to https://, and this for some reason rejects the stream component that Streamlit uses?


Note: Various IP addresses and hostnames are REDACTED for the sake of security :slight_smile:

This is a Websocket connection.
I think this is used by streamlit for communication between backend and frontend.

Makes sense. Any idea what to do about it?