A modern web application for translating documents and text using Azure Translator Service. This application can be deployed to Azure Container Apps.
- Text Translation: Translate text in real-time between supported languages
- Document Translation: Upload and translate documents (PDF, DOCX, XLSX, PPTX, TXT, HTML, RTF, ODT, ODS, ODP)
- Batch Translation: Process multiple documents at once
- Modern Web UI: Clean, responsive interface built with Bootstrap 5
- Real-time Progress: Track translation progress for batch operations
- Secure: Uses Azure Managed Identity for secure access to Azure services
The application consists of:
- ASP.NET Core Web API: Backend service providing translation APIs
- Static Web Frontend: Modern HTML/CSS/JavaScript frontend
- Azure Container Apps: Hosting platform with auto-scaling
- Azure Translator: AI-powered translation service
- Azure Storage: Document storage and processing
- Azure Key Vault: Secure secrets management
- Azure Container Registry: Container image storage
Before deploying this application, ensure you have:
- Azure CLI installed (
az --version) - Azure Developer CLI installed (
azd version) - Docker installed and running (
docker version) - An Azure subscription with appropriate permissions
cd DocumentTranslationazd initazd upThis will:
- Create all necessary Azure resources
- Build and push the container image
- Deploy the application to Azure Container Apps
- Configure all security and networking
After deployment, you'll need to configure the secrets in Key Vault:
# Get the Translator key and store it in Key Vault
TRANSLATOR_KEY=$(az cognitiveservices account keys list --name $AZURE_TRANSLATOR_NAME --resource-group $AZURE_RESOURCE_GROUP --query "key1" -o tsv)
az keyvault secret set --vault-name $AZURE_KEY_VAULT_NAME --name "TranslatorKey" --value "$TRANSLATOR_KEY"
# Get the Storage connection string and store it in Key Vault
STORAGE_CONN_STRING=$(az storage account show-connection-string --name $AZURE_STORAGE_ACCOUNT_NAME --resource-group $AZURE_RESOURCE_GROUP --query "connectionString" -o tsv)
az keyvault secret set --vault-name $AZURE_KEY_VAULT_NAME --name "StorageConnectionString" --value "$STORAGE_CONN_STRING"If you prefer to deploy manually or need more control:
az group create --name rg-document-translation --location eastusaz deployment group create \
--resource-group rg-document-translation \
--template-file infra/main.bicep \
--parameters environmentName=myapp location=eastus# Build the container image
docker build -t document-translation-web .
# Tag and push to Azure Container Registry
az acr login --name <your-registry-name>
docker tag document-translation-web <your-registry-name>.azurecr.io/document-translation-web:latest
docker push <your-registry-name>.azurecr.io/document-translation-web:latestaz containerapp update \
--name <your-container-app-name> \
--resource-group rg-document-translation \
--image <your-registry-name>.azurecr.io/document-translation-web:latestThe application uses the following environment variables:
| Variable | Description | Required |
|---|---|---|
DocumentTranslation__AzureResourceName |
Azure Translator endpoint | Yes |
DocumentTranslation__SubscriptionKey |
Azure Translator API key | Yes |
DocumentTranslation__AzureRegion |
Azure region | Yes |
DocumentTranslation__StorageConnectionString |
Azure Storage connection string | Yes |
DocumentTranslation__AzureKeyVaultName |
Azure Key Vault name | Yes |
DocumentTranslation__TextTransEndpoint |
Text translation endpoint | No |
DocumentTranslation__ShowExperimental |
Show experimental languages | No |
DocumentTranslation__Category |
Custom Translator category | No |
DocumentTranslation__FlightString |
Experimental flights | No |
cd DocumentTranslation.Web
dotnet user-secrets set "DocumentTranslation:AzureResourceName" "your-translator-resource"
dotnet user-secrets set "DocumentTranslation:SubscriptionKey" "your-translator-key"
dotnet user-secrets set "DocumentTranslation:StorageConnectionString" "your-storage-connection-string"
# ... other settingsdotnet runThe application will be available at https://localhost:5001 or http://localhost:5000.
- Navigate to the "Text Translation" tab
- Select source and target languages
- Enter text to translate
- Click "Translate Text"
- Navigate to the "Document Translation" tab
- Select source and target languages
- Choose a document file
- Click "Translate Document"
- Download the translated document
- Navigate to the "Batch Translation" tab
- Select source and target languages
- Choose multiple document files
- Click "Start Batch Translation"
- Monitor progress and download results
- Documents: PDF, DOCX, XLSX, PPTX, ODT, ODS, ODP
- Text Files: TXT, HTML, RTF
- Maximum Size: 50MB per file
- Docker not available: Ensure Docker Desktop is running and WSL integration is enabled
- Authentication errors: Verify Azure CLI login with
az account show - Permission errors: Ensure your account has Contributor access to the subscription
- Translation errors: Check Azure Translator service quotas and limits
View application logs:
azd logsOr check in Azure Portal:
- Container Apps → Your App → Log stream
- Application Insights → Live metrics
The application follows Azure security best practices:
- Managed Identity: No credentials stored in code
- Key Vault: Secure secret storage
- Private Networking: Optional VNET integration
- HTTPS: Enforced for all communications
- RBAC: Principle of least privilege
- Container Apps scale to zero when not in use
- Azure Translator charges per character translated
- Storage costs are minimal for typical usage
- Consider Azure Translator free tier for development
For issues and questions:
- Check the Azure Translator documentation
- Review Container Apps documentation
- File issues in the project repository
This project is licensed under the MIT License - see the LICENSE file for details.