A Java Spring Boot web application that generates Sora videos using Azure OpenAI API. This application provides a user-friendly web interface for creating AI-generated videos with configurable video specifications including resolution and duration.
- 🎥 Video Generation: Create videos using Azure OpenAI's Sora model
- ⚙️ Configurable Specifications: Choose from 9 supported resolutions and duration (1-20 seconds)
- 🔧 Smart Validation: Automatic restrictions for resolution-specific limitations (e.g., 1920x1080 max 10 seconds)
- 🖥️ Web Interface: Modern, responsive UI built with Bootstrap and Thymeleaf
- ⚡ Reactive Architecture: Built with Spring WebFlux for optimal performance with 100MB buffer for large video downloads
- 🔒 Secure: Uses Azure managed identity for authentication in production
- 📊 Monitoring: Includes health checks and logging for production deployment
- 🚀 Container Ready: Dockerized for easy deployment to Azure Container Apps
- 💰 Cost Estimation: Real-time cost preview and detailed cost breakdown with warnings
The cost estimator is based on Azure OpenAI Sora per-second pricing as of June 2025:
- Java 17 or later
- Maven 3.6 or later
- Azure CLI (for deployment)
- Azure Developer CLI (recommended)
- Azure subscription with permission to create OpenAI resources
For the one-click deployment script, the Azure OpenAI resource and Sora model will be created automatically. Otherwise, you'll need Azure OpenAI API access with the Sora model.
-
Clone the repository
git clone <repository-url> cd sora-video-generator
-
Set up environment variables Create a
.envfile in the root directory with your Azure OpenAI credentials:# Azure OpenAI Configuration AZURE_OPENAI_ENDPOINT=https://your-resource.cognitiveservices.azure.com AZURE_OPENAI_API_KEY=your_api_key_here AZURE_OPENAI_API_VERSION=preview # Azure Configuration AZURE_ENV_NAME=your-env-name AZURE_LOCATION=eastus # Application Configuration SERVER_PORT=8080 SPRING_PROFILES_ACTIVE=dev
Important: Use only the base URL for the endpoint (e.g.,
https://your-resource.cognitiveservices.azure.com). Do not include the full API path like/openai/v1/video/generations/jobs?api-version=preview. -
Environment Variable Loading The application automatically loads environment variables from the
.envfile using the dotenv-java library. No manual configuration ofapplication.propertiesis required - all sensitive configuration is handled through environment variables for security. -
Run the application
./mvnw spring-boot:run
-
Access the application Open your browser and go to
http://localhost:8080
-
Build the JAR file
./mvnw clean package
-
Build Docker image
docker build -t sora-video-generator .
This application is designed to be deployed to Azure Container Apps using Azure Developer CLI.
The simplest way to deploy the entire application, including creating the Azure OpenAI resource with Sora model:
-
Run the deployment script
# Using PowerShell script ./deploy.ps1 # Or using the batch file (Windows) deploy.bat
-
What the one-click deployment does:
- Creates the Azure OpenAI resource in East US 2
- Deploys the Sora model
- Updates the .env file with actual credentials
- Builds the Java application
- Deploys all infrastructure to Azure
- Provides the URL to access your application
-
Custom deployment options
# Specify resource group name and location ./deploy.ps1 -ResourceGroupName "MySoraRG" -Location "eastus2" # Specify OpenAI resource name and environment name ./deploy.ps1 -OpenAIResourceName "my-sora-openai" -EnvironmentName "production"
-
Install Azure Developer CLI
# Windows (PowerShell) winget install Microsoft.AzureDeveloperCLI # macOS brew tap azure/azd && brew install azd # Linux curl -fsSL https://aka.ms/install-azd.sh | bash
-
Initialize the project
azd init
-
Set environment variables
azd env set AZURE_OPENAI_ENDPOINT "https://your-resource.cognitiveservices.azure.com" azd env set AZURE_OPENAI_API_KEY "your_api_key_here" azd env set AZURE_OPENAI_API_VERSION "preview" azd env set AZURE_LOCATION "eastus"
Important: Use only the base URL for the endpoint (e.g.,
https://your-resource.cognitiveservices.azure.com). Do not include the full API path like/openai/v1/video/generations/jobs?api-version=preview. -
Deploy to Azure
azd up
The application uses environment variables for all configuration to ensure security and flexibility across different environments (local development, Azure deployment). All sensitive configuration is loaded from .env files locally or Azure environment variables in production.
| Variable | Description | Default |
|---|---|---|
AZURE_OPENAI_ENDPOINT |
Azure OpenAI service endpoint (base URL only) | Required |
AZURE_OPENAI_API_KEY |
Azure OpenAI API key | Required |
AZURE_OPENAI_API_VERSION |
API version | preview |
SERVER_PORT |
Application port | 8080 |
SPRING_PROFILES_ACTIVE |
Spring profile | dev |
AZURE_ENV_NAME |
Azure environment name | Required for deployment |
AZURE_LOCATION |
Azure region | Required for deployment |
-
Azure OpenAI API Key Issues
- Verify your API key is correct and has Sora access
- Check endpoint URL format (use base URL only, not full API path)
- Ensure environment variables are properly set in
.envfile or Azure environment - Verify that Azure environment and local
.envuse the same endpoint
-
Container App Deployment Issues
- Check container registry permissions
- Verify managed identity configuration
- Review application logs in Azure portal
- Ensure Azure location consistency between environment variables and existing resources
-
Environment Variable Loading Issues
- Verify
.envfile is in the project root directory - Check that environment variables are correctly set in Azure (use
azd env get-values) - Ensure no hardcoded URLs remain in configuration files
- Verify dotenv-java dependency is included in Maven build
- Verify
-
Video Generation Timeouts
- Video generation can take 2-5 minutes
- Check job status regularly
- Ensure adequate timeout settings
-
Video Download Buffer Errors
- Application configured with 100MB buffer for large video files
- If encountering buffer limit issues, videos may be too large
- Try shorter durations or lower resolutions
-
Resolution-Duration Restrictions
- 1920x1080 resolution limited to maximum 10 seconds
- Frontend automatically enforces these restrictions
- Backend validation prevents invalid combinations
View application logs:
# Azure Developer CLI
azd logs
# Azure CLI
az containerapp logs show --name <app-name> --resource-group <rg-name>This project is licensed under the MIT License. See the LICENSE file for details.