Skip to content

Template for Deploying a containerized Streamlit application on Azure Linux Web App 🐳🚀☁️ Infra managed via Terraform🛠️

License

Notifications You must be signed in to change notification settings

WayneGoosen/azure-streamlit-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Azure Streamlit PoC 🐳🚀☁️

PoC

streamlit

Overview

I needed to create a quick proof of concept (PoC) using Streamlit but had two constraints:

With this in mind, containerizing and hosting on Azure was the solution. This repository provides a boilerplate to fast track this with the following implementations:

  • Containerized Streamlit app with a blank app.py file (just add your code).
  • GitHub workflow to build and publish the image to ghcr.io.
  • Terraform code to manage infrastructure on Azure.
  • GitHub workflow to execute Terraform apply & destroy infrastructure.

I hope this helps you to ship more 🚀

What is Streamlit? 🤔

Streamlit is an open-source Python library that makes it easy to create interactive web applications for machine learning and data science projects.

Check it out

What's the damage (WTD)? 💰

Description Cost (Per month)
B1 ($0.075/hour) tier for Azure App Service costing $54.79
Standard tier with LRS for Azure Storage Account costing (10K+ operations cost excluded as minimal usage) $0.0184
GitHub Workflows (if private repo, check pricing) $0
Total $54.81

Disclaimer: Estimation only. Pricing might change; please refer to official documentation at the time of evaluation.

Technologies Used 🧑‍💻

Azure Docker Terraform GitHub Actions Python

Hosting and Deployment 🚀

  • Hosting: Azure App Service.
  • Deployment: GitHub Actions

Architecture Overview 🏛️

  • Interactive web-based frontend.
  • Python-based backend.
  • GitHub Container Registry to store the image.

Getting Started 🧑‍💻

This project requires an Azure subscription to run, Get started

  1. Create a repository from this template repo.

  2. Open a shell and run azure login

  3. Update subject field within your respository naming in infra/scripts/credential.json

  4. Execute infra/scripts/initialize.sh and capture output fields

  5. Setting up environments:

    • Navigate to the your repository on GitHub.
    • Go to “Settings” > “Environments”.
    • Create a new environment 'production'
  6. Adding Secrets:

    • Navigate to the your repository on GitHub.
    • Go to “Settings” > “Environments” > Select “production”.
    • Go to "Environment secrets" and select "Add environment secret"
    • Add the following secrets using the output of step 4: AZURE_ENTRA_ID_CLIENT_ID, AZURE_ENTRA_ID_TENANT_ID & AZURE_SUBSCRIPTION_ID

Development

To begin, make sure you have the Dev containers extension installed and have Docker running. Check out Devcontainers for context.

  1. Clone this repo and open it in Visual Studio Code.
  2. You should this this notification pop up:

devcontainerprompt

Select _Reopen in Container_ and the devcontainer will be loaded.

This will prepare your dev environment with the required tooling.

Using a special button

This will open this repo in Visual Studio Code using a link. Press below:

Open in Remote - Containers

License 📝

This project is licensed under the MIT License - see the LICENSE file for details.