|
| 1 | +# Vacation Planner on Azure Container Instances |
| 2 | + |
| 3 | +A sample application demonstrating how to deploy a containerized Flask web app using four Azure services: |
| 4 | + |
| 5 | +- **Azure Blob Storage** — Stores vacation activities as JSON blobs |
| 6 | +- **Azure Key Vault** — Stores the storage connection string as a secret |
| 7 | +- **Azure Container Registry (ACR)** — Hosts the Docker container image |
| 8 | +- **Azure Container Instances (ACI)** — Runs the containerized application |
| 9 | + |
| 10 | +## Architecture |
| 11 | + |
| 12 | +``` |
| 13 | +┌──────────────┐ store conn ┌──────────────┐ env vars ┌──────────────┐ |
| 14 | +│ Storage │ ──── string ────► │ KeyVault │ ─────────► │ ACI │ |
| 15 | +│ Account │ │ (secrets) │ │ (container │ |
| 16 | +└──────────────┘ └──────────────┘ │ group) │ |
| 17 | + ▲ │ │ |
| 18 | + │ read/write activities │ │ |
| 19 | + └────────────────────────────────────────────────────────┤ │ |
| 20 | + │ │ |
| 21 | +┌──────────────┐ image pull │ │ |
| 22 | +│ ACR │ ────────────────────────────────────────────► │ │ |
| 23 | +│ (registry) │ (registry credentials) └──────────────┘ |
| 24 | +└──────────────┘ |
| 25 | +``` |
| 26 | + |
| 27 | +**Deployment flow:** The deploy script creates Storage and Key Vault first, stores the storage connection string as a secret, creates ACR and pushes the container image, then creates an ACI container group that pulls from ACR with the secrets injected as environment variables. |
| 28 | + |
| 29 | +**At runtime:** The Flask app reads the storage connection string from its environment, connects to Blob Storage, and provides a web UI for managing vacation activities (add, edit, delete). |
| 30 | + |
| 31 | +## Prerequisites |
| 32 | + |
| 33 | +- [LocalStack](https://docs.localstack.cloud/getting-started/installation/) |
| 34 | +- [Docker](https://docs.docker.com/get-docker/) |
| 35 | +- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli) |
| 36 | +- [azlocal](https://pypi.org/project/azlocal/) (`pip install azlocal`) |
| 37 | + |
| 38 | +## Quick Start |
| 39 | + |
| 40 | +```bash |
| 41 | +# Start LocalStack Azure |
| 42 | +IMAGE_NAME=localstack/localstack-azure-alpha localstack start -d |
| 43 | +localstack wait -t 60 |
| 44 | + |
| 45 | +# Login |
| 46 | +azlocal login |
| 47 | +azlocal start_interception |
| 48 | + |
| 49 | +# Deploy all services |
| 50 | +cd python |
| 51 | +bash scripts/deploy.sh |
| 52 | + |
| 53 | +# Validate the deployment |
| 54 | +bash scripts/validate.sh |
| 55 | +``` |
| 56 | + |
| 57 | +## Cleanup |
| 58 | + |
| 59 | +```bash |
| 60 | +azlocal group delete --name local-aci-rg --yes |
| 61 | +``` |
| 62 | + |
| 63 | +## Application |
| 64 | + |
| 65 | +The Vacation Planner is a Flask web application with a Bootstrap UI that lets users manage vacation activities. Activities are stored as JSON blobs in Azure Blob Storage, organized by username. |
| 66 | + |
| 67 | +### Endpoints |
| 68 | + |
| 69 | +| Route | Method | Description | |
| 70 | +|-------|--------|-------------| |
| 71 | +| `/` | GET | View all activities | |
| 72 | +| `/` | POST | Add or update an activity | |
| 73 | +| `/delete/<id>` | POST | Delete an activity | |
| 74 | +| `/update/<id>` | GET | Edit an activity | |
| 75 | +| `/health` | GET | Health check | |
| 76 | + |
| 77 | +### Environment Variables |
| 78 | + |
| 79 | +| Variable | Description | |
| 80 | +|----------|-------------| |
| 81 | +| `AZURE_STORAGE_CONNECTION_STRING` | Blob Storage connection string (from Key Vault) | |
| 82 | +| `BLOB_CONTAINER_NAME` | Name of the blob container for activities | |
| 83 | +| `LOGIN_NAME` | Username for the activity list (default: "paolo") | |
0 commit comments