<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Adi Purnomo</title>
    <description>The latest articles on DEV Community by Adi Purnomo (@medival).</description>
    <link>https://dev.to/medival</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F382069%2Ff32cb629-f34d-4ade-8806-d3999171bd47.jpg</url>
      <title>DEV Community: Adi Purnomo</title>
      <link>https://dev.to/medival</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/medival"/>
    <language>en</language>
    <item>
      <title>Deploying Azure AI Agent Translator in Containers</title>
      <dc:creator>Adi Purnomo</dc:creator>
      <pubDate>Tue, 18 Mar 2025 17:44:06 +0000</pubDate>
      <link>https://dev.to/medival/deploying-azure-ai-agent-translator-in-containers-1dgm</link>
      <guid>https://dev.to/medival/deploying-azure-ai-agent-translator-in-containers-1dgm</guid>
      <description>&lt;h2&gt;
  
  
  What is Azure AI Translator?
&lt;/h2&gt;

&lt;p&gt;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. &lt;/p&gt;

&lt;h2&gt;
  
  
  Azure AI Translator features
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Text Translation&lt;br&gt;
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.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Document Translation&lt;br&gt;
&lt;strong&gt;Asynchronous batch translation:&lt;/strong&gt; 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.&lt;br&gt;
&lt;strong&gt;Synchronous single file translation:&lt;/strong&gt; 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.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Custom Translator&lt;br&gt;
Build customized models to translate domain- and industry-specific language, terminology, and style. Create a dictionary (phrase or sentence) for custom translations.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Language Translation Support
&lt;/h2&gt;

&lt;p&gt;Azure AI services support over 100+ world wide. Full language support available in this &lt;a href="https://learn.microsoft.com/en-us/azure/ai-services/translator/language-support" rel="noopener noreferrer"&gt;docs&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Why deploying Azure AI Translator in containers?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;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).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Low Latency: Avoid delays by doing translations directly on-site instead of sending them to the cloud.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Offline Support: Can be used in places with little or no internet access (like factories, ships, or smart devices).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cost Optimization: Lower your costs for large workloads by running the service yourself instead of paying for cloud usage.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Easy to Scale: Grow or shrink the translation service easily using container orchestration tools like Kubernetes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Please ensure you have prepare the following requirement to continue&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Azure Subscription&lt;br&gt;
Sign up at &lt;a href="https://portal.azure.com/" rel="noopener noreferrer"&gt;Azure Portal&lt;/a&gt;&lt;br&gt;
Find Azure AI Services and select Translator&lt;br&gt;
Click Create, select Create Translator, configure pricing tier (select F0 for testing)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;API Key and Endpoint&lt;br&gt;
Once the resources completed, go to Keys and Endpoint in Azure Portal&lt;br&gt;
Copy the (e.g &lt;code&gt;xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C&lt;/code&gt;) Key and Endpoint URL (e.g &lt;code&gt;https://&amp;lt;resource-name&amp;gt;.cognitiveservices.azure.com&lt;/code&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Docker Environment&lt;br&gt;
Install &lt;a href="https://www.docker.com/products/docker-desktop/" rel="noopener noreferrer"&gt;Docker Desktop&lt;/a&gt; or Install using CLI Linux &lt;br&gt;
&lt;code&gt;curl -fsSL https://get.docker.com -o install-docker.sh&lt;/code&gt;&lt;br&gt;
&lt;code&gt;chmod +x install-docker.sh&lt;/code&gt;&lt;br&gt;
&lt;code&gt;sudo sh install-docker.sh&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Command-Line Tools&lt;br&gt;
Terminal (Linux/macOS or PowerShell/Command Prompt (Windows)&lt;br&gt;
curl or Postman for testing APIs&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 1 - Prepare Azure AI Translator Container Image
&lt;/h3&gt;

&lt;p&gt;Open vscode, create directory and open terminal. Paste the following command to pull container from microsft registry&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker pull mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latestdocker pull mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure the docker desktop is running.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2 - Run the AI Translator Container
&lt;/h3&gt;

&lt;p&gt;Create file .env and paste API Key and Endpoint&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;API_KEY=xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C
ENDPOINT_URI=https://&amp;lt;resource-name&amp;gt;.cognitiveservices.azure.com
LANGUAGES=en,es,fr
EULA=accept
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once done save and paste the following command to run the container&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -d \
--name ai-translator \
-p 5000:5000 \
--env-file .env \
--platform linux/amd64 \
mcr.microsoft.com/azure-cognitive-services/translator/text-translation:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3 - Verify Container Health
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Check container Status
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker ps -a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ensure the container status is up. If something goes wrong, troubleshoot using the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker logs ai-translator
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Test Health Endpoint:
Run the following command to test endpoint
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -v http://localhost:5000/health
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test Translation Endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X POST "http://localhost:5000/translate?api-version=3.0&amp;amp;from=en&amp;amp;to=es" \
  -H "Ocp-Apim-Subscription-Key: xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C" \
  -H "Content-Type: application/json" \
  -d '[{ "Text": "Hello, world!" }]'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "translations": [
      {
        "text": "¡Hola, mundo!",
        "to": "es"
      }
    ]
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Test Language Detection:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -X POST "http://localhost:5000/detect?api-version=3.0" \
  -H "Ocp-Apim-Subscription-Key: xt32qsRRVk9SEyoX327KUHFRBIFNd9HF0iMLLpZ5qz2zjmRKVOI7bJQQJ99BCACYeBjFXJ3w3AAAdGcA32C" \
  -H "Content-Type: application/json" \
  -d '[{ "Text": "こんにちは" }]'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sample output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "language": "ja",
    "score": 1,
    "isTranslationSupported": true,
    "isTransliterationSupported": true
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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 &lt;/p&gt;

&lt;p&gt;Test Transliteration:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Sample output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "script": "Latn",
    "text": "Kon'nichiwa"
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;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 &lt;a href="https://learn.microsoft.com/en-us/azure/ai-services/translator/" rel="noopener noreferrer"&gt;official docs&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;References:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/azure/ai-services/translator/containers/install-run?tabs=connected" rel="noopener noreferrer"&gt;https://learn.microsoft.com/en-us/azure/ai-services/translator/containers/install-run?tabs=connected&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/training/modules/translate-text-with-translator-service/" rel="noopener noreferrer"&gt;https://learn.microsoft.com/en-us/training/modules/translate-text-with-translator-service/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
