Skip to content

Commit 52126fb

Browse files
authored
IaC Adjustments (#28)
* feat: add Azure deployment configuration and documentation * refactor: update Azure deployment documentation for clarity and detail * fix: update repository URL in README for Azure deployment instructions
1 parent 3ad402f commit 52126fb

File tree

9 files changed

+424
-28
lines changed

9 files changed

+424
-28
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Azure Developer CLI
2+
.azure/
3+
14
# Byte-compiled / optimized / DLL files
25
__pycache__/
36
*.py[cod]

DEPLOYMENT.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Azure Deployment with Azure Developer CLI (azd)
2+
3+
This guide shows how to deploy the Visionary Lab to Azure using the Azure Developer CLI for one-click deployments.
4+
5+
## Prerequisites
6+
7+
- [Azure Developer CLI (azd)](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd) installed
8+
- Azure subscription with access to:
9+
- Azure Container Apps
10+
- Azure OpenAI Service (with GPT-4o, DALL-E 3, and Sora deployments)
11+
- Azure Storage Account
12+
- Azure Log Analytics
13+
14+
## Quick Start (One-Click Deployment)
15+
16+
1. **Clone the repository**:
17+
```bash
18+
git clone <repository-url>
19+
cd visionary-lab
20+
```
21+
22+
2. **Authenticate and deploy**:
23+
```bash
24+
azd auth login
25+
azd up
26+
```
27+
28+
3. **Configure during deployment**:
29+
When prompted by `azd up`, provide your Azure OpenAI service details in this order:
30+
31+
**LLM Configuration:**
32+
- **LLM_AOAI_RESOURCE**: Your Azure OpenAI resource name for LLM
33+
- **LLM_DEPLOYMENT**: Your GPT deployment name (e.g., "gpt-4.1")
34+
- **LLM_AOAI_API_KEY**: Your LLM API key
35+
36+
**Image Generation Configuration:**
37+
- **IMAGEGEN_AOAI_RESOURCE**: Your Azure OpenAI resource name for image generation
38+
- **IMAGEGEN_DEPLOYMENT**: Your image generation deployment name (e.g., "gpt-image-1")
39+
- **IMAGEGEN_AOAI_API_KEY**: Your image generation API key
40+
41+
**Sora Configuration:**
42+
- **SORA_AOAI_RESOURCE**: Your Azure OpenAI resource name for Sora
43+
- **SORA_DEPLOYMENT**: Your Sora deployment name (e.g., "sora")
44+
- **SORA_AOAI_API_KEY**: Your Sora API key
45+
46+
That's it! The `azd up` command will:
47+
- Create a new environment
48+
- Prompt for required Azure OpenAI configuration (resource names, deployments, API keys)
49+
- Provision all Azure resources (Container Registry, Container Apps, Storage, etc.)
50+
- Build Docker images for frontend and backend
51+
- Push images to your private Azure Container Registry
52+
- Deploy both services to Azure Container Apps
53+
- Configure networking, authentication, and environment variables
54+
- Provide you with the application URLs
55+
56+
## Manual Steps
57+
58+
If you prefer manual control over the deployment process:
59+
60+
### 1. Initialize Environment
61+
```bash
62+
azd env new <environment-name>
63+
```
64+
65+
### 2. Configure Environment Variables
66+
Set your Azure OpenAI service details:
67+
```bash
68+
# LLM OpenAI
69+
azd env set LLM_AOAI_RESOURCE "your-openai-resource-name"
70+
azd env set LLM_DEPLOYMENT "gpt-4.1"
71+
azd env set LLM_AOAI_API_KEY "your-gpt-key"
72+
73+
# Image Generation OpenAI
74+
azd env set IMAGEGEN_AOAI_RESOURCE "your-openai-resource-name"
75+
azd env set IMAGEGEN_DEPLOYMENT "gpt-image-1"
76+
azd env set IMAGEGEN_AOAI_API_KEY "your-image-gen-key"
77+
78+
# Sora OpenAI
79+
azd env set SORA_AOAI_RESOURCE "your-openai-resource-name"
80+
azd env set SORA_DEPLOYMENT "sora"
81+
azd env set SORA_AOAI_API_KEY "your-sora-key"
82+
```
83+
84+
### 3. Deploy Infrastructure
85+
```bash
86+
azd provision
87+
```
88+
89+
### 4. Deploy Application
90+
```bash
91+
azd deploy
92+
```
93+
94+
## Architecture
95+
96+
The deployment creates:
97+
98+
- **Azure Container Apps Environment**: Serverless container hosting
99+
- **Backend Container App**: FastAPI application (Python)
100+
- **Frontend Container App**: Next.js application (Node.js)
101+
- **Azure Container Registry**: Private registry for storing Docker images
102+
- **Azure Storage Account**: For storing generated images and videos
103+
- **Log Analytics Workspace**: For monitoring and logging
104+
105+
## Environment Variables
106+
107+
The following environment variables are automatically configured:
108+
109+
### Backend & Frontend
110+
- `AZURE_STORAGE_ACCOUNT_NAME`: Auto-generated storage account
111+
- `AZURE_BLOB_SERVICE_URL`: Storage endpoint URL
112+
- `AZURE_STORAGE_ACCOUNT_KEY`: Storage access key
113+
- `AZURE_BLOB_IMAGE_CONTAINER`: Container for images (default: "images")
114+
- `AZURE_CONTAINER_REGISTRY_ENDPOINT`: Container registry login server
115+
116+
### AI Services (All Configurable)
117+
**LLM Configuration:**
118+
- `LLM_AOAI_RESOURCE`: LLM OpenAI resource name
119+
- `LLM_DEPLOYMENT`: LLM deployment name
120+
- `LLM_AOAI_API_KEY`: LLM API key
121+
122+
**Image Generation Configuration:**
123+
- `IMAGEGEN_AOAI_RESOURCE`: Image generation OpenAI resource name
124+
- `IMAGEGEN_DEPLOYMENT`: Image generation deployment name
125+
- `IMAGEGEN_AOAI_API_KEY`: Image generation API key
126+
127+
**Sora Configuration:**
128+
- `SORA_AOAI_RESOURCE`: Sora OpenAI resource name
129+
- `SORA_DEPLOYMENT`: Sora deployment name
130+
- `SORA_AOAI_API_KEY`: Sora API key
131+
132+
## Monitoring
133+
134+
Access your deployment logs and metrics:
135+
136+
```bash
137+
# View application logs
138+
azd logs
139+
140+
# Monitor resources in Azure Portal
141+
azd show --output table
142+
```
143+
144+
## Cleanup
145+
146+
To remove all Azure resources:
147+
148+
```bash
149+
azd down
150+
```
151+
152+
## Troubleshooting
153+
154+
### Common Issues
155+
156+
1. **Missing OpenAI Resources**: Ensure you have created Azure OpenAI resources with the required model deployments
157+
2. **Permission Issues**: Verify your Azure account has Contributor access to the subscription
158+
3. **Region Availability**: Some OpenAI models may not be available in all regions
159+
160+
### Getting Help
161+
162+
```bash
163+
# Check azd status
164+
azd env list
165+
166+
# View detailed logs
167+
azd logs --follow
168+
169+
# Get environment info
170+
azd env get-values
171+
```
172+
173+
For more information, see the [Azure Developer CLI documentation](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/).

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,31 @@ Once everything is set up:
139139
```
140140

141141
The frontend will be available at http://localhost:3000.
142+
143+
## 🚀 Deploy to Azure
144+
145+
For production deployment, use Azure Developer CLI to deploy the entire application to Azure with one command:
146+
147+
**Prerequisites**: [Azure Developer CLI (azd)](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd) installed
148+
149+
```bash
150+
# Clone and deploy
151+
git clone https://github.com/Azure-Samples/visionary-lab
152+
cd visionary-lab
153+
154+
# Authenticate and deploy everything in one command
155+
azd auth login
156+
azd up
157+
```
158+
159+
During `azd up`, you'll be prompted to configure your Azure OpenAI resources:
160+
- **LLM Configuration**: Resource name, deployment name (e.g., "gpt-4.1"), and API key
161+
- **Image Generation Configuration**: Resource name, deployment name (e.g., "gpt-image-1"), and API key
162+
- **Sora Configuration**: Resource name, deployment name (e.g., "sora"), and API key
163+
164+
✨ That's it! Your Visionary Lab will be running on Azure Container Apps with:
165+
- Azure Container Registry for Docker images
166+
- Azure Storage for generated content
167+
- Automatic scaling and monitoring
168+
169+
📖 For detailed deployment instructions, see [DEPLOYMENT.md](DEPLOYMENT.md)

azure.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2+
3+
name: visionary-lab
4+
metadata:
5+
6+
services:
7+
backend:
8+
project: .
9+
language: python
10+
host: containerapp
11+
docker:
12+
path: ./backend/Dockerfile
13+
context: .
14+
frontend:
15+
project: ./frontend
16+
language: js
17+
host: containerapp
18+
docker:
19+
path: ./Dockerfile
20+
context: .
21+
22+
hooks:
23+
postprovision:
24+
posix:
25+
shell: sh
26+
run: echo "Infrastructure provisioned successfully"
27+
windows:
28+
shell: pwsh
29+
run: echo "Infrastructure provisioned successfully"
30+
31+
infra:
32+
provider: bicep
33+
path: infra
34+
35+
pipeline:
36+
provider: github

backend/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ FROM python:3.12-slim
33

44
# Install system dependencies needed for OpenCV
55
RUN apt-get update && apt-get install -y --no-install-recommends \
6-
libgl1-mesa-glx \
6+
libgl1 \
77
libglib2.0-0 \
8+
libgthread-2.0-0 \
89
curl \
910
&& rm -rf /var/lib/apt/lists/*
1011

0 commit comments

Comments
 (0)