Deploy your Streamlit app using GitLab and Azure App Service
Here's a step-by-step guide to deploy your Streamlit app using GitLab and Azure App Service:
Step 1: Prepare Your Streamlit App
Ensure your project has the following structure:
Step 2: Create requirements.txt
List all the required libraries, including Streamlit:
You can create it with:
Step 3: Create .gitlab-ci.yml
This config file defines how GitLab will deploy your app:
Replace variables like
$AZURE_USERNAME,$AZURE_APP_NAMEwith actual values or define them as GitLab CI/CD secrets.
Step 4: Push Your Code to GitLab
Commit and push the project to your GitLab repository:
Step 5: Set Up Secrets in GitLab
Go to your GitLab repo → Settings → CI/CD → Variables, and add the following:
-
AZURE_USERNAME -
AZURE_PASSWORD -
AZURE_TENANT -
AZURE_APP_NAME -
AZURE_RESOURCE_GROUP -
AZURE_LOCATION
Step 6: Configure Azure App Service
-
Go to Azure Portal
-
Create a Web App resource.
-
Select a runtime (Python 3.9).
-
Choose deployment via GitHub or External CI/CD if asked.
-
Add a startup command in configuration:
Step 7: Trigger the CI/CD Pipeline
Once pushed, GitLab will automatically run the pipeline and deploy your app to Azure.
No comments