Deploying Azure AI Agent Translator in Containers

What is Azure AI Translator? Azure AI Translator is a cloud-based neural machine translation service that is part of the Azure AI services family and can be used with any operating system. Azure AI Translator features Text Translation Execute text translation between supported source and target languages in real time. Create a dynamic dictionary and learn how to prevent translations using the Translator API. Document Translation Asynchronous batch translation: Translate batch and complex files while preserving the structure and format of the original documents. The batch translation process requires an Azure Blob storage account with containers for your source and translated documents. Synchronous single file translation: Translate a single document file alone or with a glossary file while preserving the structure and format of the original document. The file translation process doesn't require an Azure Blob storage account. The final response contains the translated document and is returned directly to the calling client. Custom Translator Build customized models to translate domain- and industry-specific language, terminology, and style. Create a dictionary (phrase or sentence) for custom translations. Language Translation Support Azure AI services support over 100+ world wide. Full language support available in this docs Why deploying Azure AI Translator in containers? Flexible Deployment: You can run the Translator service anywhere in your own data center, on local devices, or in private clouds where data must stay inside. Perfect for industries with strict rules (like healthcare or finance). Low Latency: Avoid delays by doing translations directly on-site instead of sending them to the cloud. Offline Support: Can be used in places with little or no internet access (like factories, ships, or smart devices). Cost Optimization: Lower your costs for large workloads by running the service yourself instead of paying for cloud usage. Easy to Scale: Grow or shrink the translation service easily using container orchestration tools like Kubernetes. Prerequisites Please ensure you have prepare the following requirement to continue Azure Subscription Sign up at Azure Portal Find Azure AI Services and select Translator Click Create, select Create Translator, configure pricing tier (select F0 for testing) API Key and Endpoint Once the resources completed, go to Keys and Endpoint in Azure Portal Copy the (e.g xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C) Key and Endpoint URL (e.g https://.cognitiveservices.azure.com) Docker Environment Install Docker Desktop or Install using CLI Linux curl -fsSL https://get.docker.com -o install-docker.sh chmod +x install-docker.sh sudo sh install-docker.sh Command-Line Tools Terminal (Linux/macOS or PowerShell/Command Prompt (Windows) curl or Postman for testing APIs Step 1 - Prepare Azure AI Translator Container Image Open vscode, create directory and open terminal. Paste the following command to pull container from microsft registry docker pull mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latestdocker pull mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latest Make sure the docker desktop is running. Step 2 - Run the AI Translator Container Create file .env and paste API Key and Endpoint API_KEY=xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C ENDPOINT_URI=https://.cognitiveservices.azure.com LANGUAGES=en,es,fr EULA=accept Once done save and paste the following command to run the container docker run -d \ --name ai-translator \ -p 5001:5000 \ -p 8000:8000 \ --env-file .env \ --platform linux/amd64 \ mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latest Step 3 - Verify Container Health Check container Status docker ps -a Ensure the container status is up. If something goes wrong, troubleshoot using the following command docker logs ai-translator Test Health Endpoint: Run the following command to test endpoint curl -v http://localhost:8000/health Test Translation Endpoint: curl -X POST "http://localhost:5000/translate?api-version=3.0&from=en&to=es" \ -H "Ocp-Apim-Subscription-Key: xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C" \ -H "Content-Type: application/json" \ -d '[{ "Text": "Hello, world!" }]' Sample output: [ { "translations": [ { "text": "¡Hola, mundo!", "to": "es" } ] } ] Test Language Detection: curl -X POST "http://localhost:5000/detect?api-version=3.0" \ -H "Ocp-Apim-Subscription-Key: xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C" \ -H "Content-Type: application/json" \ -d '[{ "Text": "こんにちは" }]' Sample output:

Mar 18, 2025 - 18:59
 0
Deploying Azure AI Agent Translator in Containers

What is Azure AI Translator?

Azure AI Translator is a cloud-based neural machine translation service that is part of the Azure AI services family and can be used with any operating system.

Azure AI Translator features

  • Text Translation
    Execute text translation between supported source and target languages in real time. Create a dynamic dictionary and learn how to prevent translations using the Translator API.

  • Document Translation
    Asynchronous batch translation: Translate batch and complex files while preserving the structure and format of the original documents. The batch translation process requires an Azure Blob storage account with containers for your source and translated documents.
    Synchronous single file translation: Translate a single document file alone or with a glossary file while preserving the structure and format of the original document. The file translation process doesn't require an Azure Blob storage account. The final response contains the translated document and is returned directly to the calling client.

  • Custom Translator
    Build customized models to translate domain- and industry-specific language, terminology, and style. Create a dictionary (phrase or sentence) for custom translations.

Language Translation Support

Azure AI services support over 100+ world wide. Full language support available in this docs

Why deploying Azure AI Translator in containers?

  • Flexible Deployment: You can run the Translator service anywhere in your own data center, on local devices, or in private clouds where data must stay inside. Perfect for industries with strict rules (like healthcare or finance).

  • Low Latency: Avoid delays by doing translations directly on-site instead of sending them to the cloud.

  • Offline Support: Can be used in places with little or no internet access (like factories, ships, or smart devices).

  • Cost Optimization: Lower your costs for large workloads by running the service yourself instead of paying for cloud usage.

  • Easy to Scale: Grow or shrink the translation service easily using container orchestration tools like Kubernetes.

Prerequisites

Please ensure you have prepare the following requirement to continue

  1. Azure Subscription
    Sign up at Azure Portal
    Find Azure AI Services and select Translator
    Click Create, select Create Translator, configure pricing tier (select F0 for testing)

  2. API Key and Endpoint
    Once the resources completed, go to Keys and Endpoint in Azure Portal
    Copy the (e.g xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C) Key and Endpoint URL (e.g https://.cognitiveservices.azure.com)

  3. Docker Environment
    Install Docker Desktop or Install using CLI Linux
    curl -fsSL https://get.docker.com -o install-docker.sh
    chmod +x install-docker.sh
    sudo sh install-docker.sh

  4. Command-Line Tools
    Terminal (Linux/macOS or PowerShell/Command Prompt (Windows)
    curl or Postman for testing APIs

Step 1 - Prepare Azure AI Translator Container Image

Open vscode, create directory and open terminal. Paste the following command to pull container from microsft registry

docker pull mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latestdocker pull mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latest

Make sure the docker desktop is running.

Step 2 - Run the AI Translator Container

Create file .env and paste API Key and Endpoint

API_KEY=xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C
ENDPOINT_URI=https://.cognitiveservices.azure.com
LANGUAGES=en,es,fr
EULA=accept

Once done save and paste the following command to run the container

docker run -d \
--name ai-translator \
-p 5001:5000 \
-p 8000:8000 \
--env-file .env \
--platform linux/amd64 \
mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latest

Step 3 - Verify Container Health

  1. Check container Status
docker ps -a

Ensure the container status is up. If something goes wrong, troubleshoot using the following command

docker logs ai-translator
  1. Test Health Endpoint: Run the following command to test endpoint
curl -v http://localhost:8000/health

Test Translation Endpoint:

curl -X POST "http://localhost:5000/translate?api-version=3.0&from=en&to=es" \
  -H "Ocp-Apim-Subscription-Key: xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C" \
  -H "Content-Type: application/json" \
  -d '[{ "Text": "Hello, world!" }]'

Sample output:

[
  {
    "translations": [
      {
        "text": "¡Hola, mundo!",
        "to": "es"
      }
    ]
  }
]

Test Language Detection:

curl -X POST "http://localhost:5000/detect?api-version=3.0" \
  -H "Ocp-Apim-Subscription-Key: xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C" \
  -H "Content-Type: application/json" \
  -d '[{ "Text": "こんにちは" }]'

Sample output:

[
  {
    "language": "ja",
    "score": 1,
    "isTranslationSupported": true,
    "isTransliterationSupported": true
  }
]

The response of the request show that the language is japanese. If we have difficulty to read the Hiragana script, we could use transliteration to render the text in Latin script

Test Transliteration:

curl -X POST "http://localhost:5000/transliterate?api-version=3.0&fromScript=Jpan&toScript=Latn" \
  -H "Ocp-Apim-Subscription-Key: xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C" \
  -H "Content-Type: application/json" \
  -d '[{ "Text": "こんにちは" }]'

Sample output:

[
  {
    "script": "Latn",
    "text": "Kon'nichiwa"
  }
]

Conclusion

The Azure AI Translator container lets you use cloud AI technology while running it locally. This guide will help you easily add translation, language detection, transliteration features to your systems while keeping full control of your data and setup. For more complex use cases, check out the official docs.

References: