Skip to content

Commit 746a9b4

Browse files
committed
add draft aci sample app
1 parent 7a6ac53 commit 746a9b4

56 files changed

Lines changed: 61371 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

run-samples.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SAMPLES=(
3535
"samples/web-app-cosmosdb-mongodb-api/python|bash scripts/deploy.sh|bash scripts/validate.sh && bash scripts/call-web-app.sh"
3636
"samples/web-app-managed-identity/python|bash scripts/user-assigned.sh|bash scripts/validate.sh && bash scripts/call-web-app.sh"
3737
"samples/web-app-sql-database/python|bash scripts/deploy.sh|bash scripts/validate.sh && bash scripts/get-web-app-url.sh"
38+
"samples/aci-vacation-planner/python|bash scripts/deploy.sh|bash scripts/validate.sh"
3839
)
3940

4041
# 1a. Define Terraform Samples
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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

Comments
 (0)