Deploying Streamlit Application on Azure App Service
To deploy a Streamlit application on Azure App Service, follow these steps:
- Create an Azure App Service with B1 SKU or higher, as the free version does not support Streamlit.
- Choose Python v3.10 or above for Streamlit in the App Service.
- Choose Linux as the operating system for the App Service.
- Make sure your code folder has a
requirements.txt
file with all the dependencies. - Create a bash script
run.sh
, and write the following command in it:python -m streamlit run ui/app.py --server.port 8000 --server.address 0.0.0.0
- Replace
ui/app.py
with your application name. - Use port 8000 because Azure App Service by default exposes only 8000 and 443 ports.
- Open Visual Studio Code and install the Azure Extension Pack.
- Log in to Visual Studio Code with your Azure account.
- Use the
Azure App Service: Deploy to Web App
command in Visual Studio Code and select your App Service name. - Wait for deployment to be finished.
- Go to the Azure portal and update the
Startup Command
configuration for the App Service and set the value torun.sh
. You can find this configuration insideApp Service > Settings > Configurations > General settings
. - Wait for some seconds and visit the application URL. Congratulations! You have successfully deployed your Streamlit application to the Azure App Service.