{"id":652,"date":"2026-10-12T14:28:37","date_gmt":"2026-10-12T04:28:37","guid":{"rendered":"https:\/\/www.cloudproinc.com.au\/?p=652"},"modified":"2026-10-12T14:28:37","modified_gmt":"2026-10-12T04:28:37","slug":"how-to-translate-text-using-azure-ai-translator-and-net","status":"publish","type":"post","link":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/how-to-translate-text-using-azure-ai-translator-and-net\/","title":{"rendered":"How to Translate Text Using Azure AI Translator and .NET"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Following our previous post about Azure AI Translator, this post will show how to translate text between a source and target language using C#.<\/p>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-about-azure-ai-translator\">About Azure AI Translator<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Microsoft Azure AI Translator offers translation services like language detection and translation for over 90 languages using a single API endpoint.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The process to use Azure AI Translator starts with the provisioning of an Azure AI Service (Multi-service or Translator) and using an SDK or Azure REST API to use the service.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Azure AI Translator offers two core services: Language detection and Language translations. To use the detection service, we need to send a text in a key-value pair format with the language that we would like to detect.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The translation service uses two parameters, From and To, that indicate the source (From) and target (To) languages. We can also count the number of characters in a translated sentence using built-in functions that come with the API.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-how-to-translate-text-using-azure-ai-translator-and-net\">How to Translate Text Using Azure AI Translator and .NET<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following C# program uses the Azure AI Translator REST API endpoint to translate text (Source to Target). To get started, create a C# project and install the Translation <a href=\"https:\/\/www.nuget.org\/packages\/Azure.AI.Translation.Text\/\" target=\"_blank\" rel=\"noreferrer noopener\">library<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-1\"><code>dotnet add package Azure.AI.Translation.Text --version 1.0.0-beta.1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In your .NET project, create a<code> <strong>appsettings.json<\/strong><\/code> file with the details of your access key and region.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-2\"><code>{\n    \"TranslatorKey\": \"ACCESS KEY\",\n    \"TranslatorRegion\": \"AZURE REGION\"\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In your <code>Programs.cs<\/code> file, add the following code.<\/p>\n\n\n\n<pre class=\"wp-block-code has-white-color has-black-background-color has-text-color has-background has-link-color wp-elements-3\"><code>using System;\nusing System.IO;\nusing System.Text;\nusing System.Collections.Generic;\nusing Microsoft.Extensions.Configuration;\nusing System.Threading.Tasks;\nusing Azure;\nusing Azure.AI.Translation.Text;\n\nnamespace translate_text\n{\n    \/\/\/ &lt;summary>\n    \/\/\/ Main program class for text translation.\n    \/\/\/ &lt;\/summary>\n    class Program\n    {\n        \/\/\/ &lt;summary>\n        \/\/\/ Main entry point for the application.\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"args\">Command-line arguments.&lt;\/param>\n        static async Task Main(string&#91;] args)\n        {\n            try\n            {\n                \/\/ Set console encoding to Unicode\n                Console.InputEncoding = Encoding.Unicode;\n                Console.OutputEncoding = Encoding.Unicode;\n\n                \/\/ Load configuration from appsettings.json\n                IConfiguration configuration = new ConfigurationBuilder()\n                    .AddJsonFile(\"appsettings.json\")\n                    .Build();\n                string translatorRegion = configuration&#91;\"TranslatorRegion\"];\n                string translatorKey = configuration&#91;\"TranslatorKey\"];\n\n                \/\/ Create translation client\n                AzureKeyCredential credential = new(translatorKey);\n                TextTranslationClient client = new(credential, translatorRegion);\n\n                \/\/ Fetch supported languages\n                var languagesResponse = await client.GetLanguagesAsync(scope: \"translation\");\n                var languages = languagesResponse.Value;\n                Console.WriteLine($\"{languages.Translation.Count} languages available.\");\n                Console.WriteLine(\"Enter a target language code for translation (e.g., 'EN'):\");\n\n                \/\/ Prompt user for target language code\n                string targetLanguage;\n                while (true)\n                {\n                    targetLanguage = Console.ReadLine();\n                    if (languages.Translation.ContainsKey(targetLanguage))\n                        break;\n                    Console.WriteLine($\"{targetLanguage} is not a supported language.\");\n                }\n\n                \/\/ Continuously prompt user for text to translate\n                string inputText;\n                while (true)\n                {\n                    Console.WriteLine(\"Enter text to translate ('quit' to exit):\");\n                    inputText = Console.ReadLine();\n                    if (inputText.ToLower() == \"quit\")\n                        break;\n\n                    \/\/ Translate the entered text\n                    var translationResponse = await client.TranslateAsync(targetLanguage, inputText);\n                    var translation = translationResponse.Value&#91;0];\n                    string sourceLanguage = translation?.DetectedLanguage?.Language;\n                    Console.WriteLine($\"'{inputText}' translated from {sourceLanguage.ToUpper()} to {translation?.Translations&#91;0].To.ToUpper()} as '{translation?.Translations&#91;0]?.Text}'.\");\n                }\n            }\n            catch (Exception ex)\n            {\n                \/\/ Handle exceptions\n                Console.WriteLine(ex.Message);\n            }\n        }\n    }\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-related-articles\">Related Articles<\/h2>\n\n\n\n<ul class=\"wp-block-yoast-seo-related-links yoast-seo-related-links\">\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2024\/09\/09\/setting-up-azure-ai-translator-with-rest-api-step-by-step-guide\/\">Setting Up Azure AI Translator with REST API: Step-by-Step Guide<\/a><\/li>\n\n\n\n<li><a href=\"null\">Reading Handwriting with Azure AI Vision and .NET C#<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2024\/09\/06\/how-to-create-an-azure-ai-language-account-using-rest-api\/\">How to Create an Azure AI Language Account Using REST API<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.cloudproinc.com.au\/index.php\/2024\/09\/08\/build-a-conversational-language-bot-with-azure-ai-language\/\">Build a Conversational Language Bot with Azure AI Language<\/a><\/li>\n\n\n\n<li><a href=\"null\">Five Ways to Secure Your Microsoft 365 Tenant: Tips to Keep Your Data Safe<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Following our previous post about Azure AI Translator, this post will show how to translate text between a source and target language using C#.<\/p>\n","protected":false},"author":1,"featured_media":653,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_et_pb_use_builder":"off","_et_pb_old_content":"","_et_gb_content_width":"","_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[27,24,48,13],"tags":[],"class_list":["post-652","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-net","category-ai","category-azure-ai-translator","category-blog"],"jetpack-related-posts":[{"id":631,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/setting-up-azure-ai-translator-with-rest-api-step-by-step-guide\/","url_meta":{"origin":652,"position":0},"title":"Setting Up Azure AI Translator with REST API: Step-by-Step Guide","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"This article will show how to create an Azure AI Translator service using the Azure REST API. Microsoft Azure AI Translator offers translation services like language detection and translation for over 90 languages using a single API endpoint. The process to use Azure AI Translator starts with the provisioning of\u2026","rel":"","context":"In &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/ai\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2024\/09\/create-an-Azure-AI-Translator-service-using-the-Azure-REST-API.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2024\/09\/create-an-Azure-AI-Translator-service-using-the-Azure-REST-API.webp 1x, \/wp-content\/uploads\/2024\/09\/create-an-Azure-AI-Translator-service-using-the-Azure-REST-API.webp 1.5x, \/wp-content\/uploads\/2024\/09\/create-an-Azure-AI-Translator-service-using-the-Azure-REST-API.webp 2x"},"classes":[]},{"id":53111,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/add-language-keyboards-to-windows-machines-with-intune\/","url_meta":{"origin":652,"position":1},"title":"Add Language Keyboards to Windows Machines with Intune","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"In this Microsoft Intune blog post, we will demonstrate the process of adding an additional language keyboard to a Windows machine using Microsoft Intune. Estimated reading time: 3 minutes Microsoft Intune is a cloud-based service that provides comprehensive management of devices, applications, and security for organizations. As part of the\u2026","rel":"","context":"In &quot;Blog&quot;","block_context":{"text":"Blog","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/blog\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2024\/07\/Deploy-Azure-OpenAI-GPT-4o-Resource-and-Model-using-Bicep.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2024\/07\/Deploy-Azure-OpenAI-GPT-4o-Resource-and-Model-using-Bicep.webp 1x, \/wp-content\/uploads\/2024\/07\/Deploy-Azure-OpenAI-GPT-4o-Resource-and-Model-using-Bicep.webp 1.5x, \/wp-content\/uploads\/2024\/07\/Deploy-Azure-OpenAI-GPT-4o-Resource-and-Model-using-Bicep.webp 2x"},"classes":[]},{"id":786,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/auto-generate-azure-bearer-token-with-postman\/","url_meta":{"origin":652,"position":2},"title":"Auto-Generate Azure Bearer Token with Postman","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"In this Postman and Azure REST API, I will show you how to auto-generate a bearer token for each Azure REST API request with Postman. Estimated reading time: 3 minutes Postman API client allows us to develop API requests to many cloud services using an intuitive interface. When it comes\u2026","rel":"","context":"In &quot;Azure&quot;","block_context":{"text":"Azure","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/microsoft-azure\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2024\/09\/Simplifying-Azure-Management-with-GitHub-Copilot-for-Azure.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2024\/09\/Simplifying-Azure-Management-with-GitHub-Copilot-for-Azure.webp 1x, \/wp-content\/uploads\/2024\/09\/Simplifying-Azure-Management-with-GitHub-Copilot-for-Azure.webp 1.5x, \/wp-content\/uploads\/2024\/09\/Simplifying-Azure-Management-with-GitHub-Copilot-for-Azure.webp 2x"},"classes":[]},{"id":614,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/how-to-create-an-azure-ai-language-account-using-rest-api\/","url_meta":{"origin":652,"position":3},"title":"How to Create an Azure AI Language Account Using REST API","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"This Azure AI Services article will show how to create an Azure AI Language Account using REST API. Table of contentsOut-of-the-Box FeaturesHow to Create an Azure AI Language Account Using REST APICreate POST RequestRequest BodyRelated Articles Azure AI Language allows us to build applications based on language models that can\u2026","rel":"","context":"In &quot;AI&quot;","block_context":{"text":"AI","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/ai\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2024\/09\/How-to-Create-an-Azure-AI-Language-Account-Using-REST-API.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2024\/09\/How-to-Create-an-Azure-AI-Language-Account-Using-REST-API.webp 1x, \/wp-content\/uploads\/2024\/09\/How-to-Create-an-Azure-AI-Language-Account-Using-REST-API.webp 1.5x, \/wp-content\/uploads\/2024\/09\/How-to-Create-an-Azure-AI-Language-Account-Using-REST-API.webp 2x"},"classes":[]},{"id":56794,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/flag-protected-text-with-azure-ai-content-safety\/","url_meta":{"origin":652,"position":4},"title":"Flag Protected Text with Azure AI Content Safety","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"Learn how to use Azure AI Content Safety to detect and flag sensitive or protected text in your applications without slowing teams down or over-blocking legitimate content.","rel":"","context":"In &quot;Azure AI Services&quot;","block_context":{"text":"Azure AI Services","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/azure-ai-services\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2025\/11\/flag-protected-text-with-azure-ai-content-safety.png","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2025\/11\/flag-protected-text-with-azure-ai-content-safety.png 1x, \/wp-content\/uploads\/2025\/11\/flag-protected-text-with-azure-ai-content-safety.png 1.5x, \/wp-content\/uploads\/2025\/11\/flag-protected-text-with-azure-ai-content-safety.png 2x, \/wp-content\/uploads\/2025\/11\/flag-protected-text-with-azure-ai-content-safety.png 3x, \/wp-content\/uploads\/2025\/11\/flag-protected-text-with-azure-ai-content-safety.png 4x"},"classes":[]},{"id":780,"url":"https:\/\/www.cloudproinc.com.au\/index.php\/2026\/10\/12\/creating-a-storage-container-in-azure-using-azure-sdk-for-net\/","url_meta":{"origin":652,"position":5},"title":"Creating a Storage Container in Azure Using Azure SDK for .NET","author":"CPI Staff","date":"October 12, 2026","format":false,"excerpt":"In this\u00a0\u00a0Microsoft Azure\u00a0article, we will create a storage container inside an Azure storage account using Azure SDK for .NET. Estimated reading time: 3 minutes Table of contentsCreating a Storage Container in Azure Using Azure SDK for .NETCreate Storage AccountRetrieve Storage Account Connection String Using PowerShellCreate C# Console ApplicationCreate an Environment\u2026","rel":"","context":"In &quot;.NET&quot;","block_context":{"text":".NET","link":"https:\/\/www.cloudproinc.com.au\/index.php\/category\/net\/"},"img":{"alt_text":"","src":"\/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp","width":350,"height":200,"srcset":"\/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp 1x, \/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp 1.5x, \/wp-content\/uploads\/2024\/07\/Reading-Handwriting-with-Azure-AI-Vision-and-.NET-C.webp 2x"},"classes":[]}],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"\/wp-content\/uploads\/2024\/09\/Translate-Text-With-Azure-AI-Translator.webp","_links":{"self":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/comments?post=652"}],"version-history":[{"count":1,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/652\/revisions"}],"predecessor-version":[{"id":654,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/posts\/652\/revisions\/654"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/media\/653"}],"wp:attachment":[{"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/media?parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/categories?post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cloudproinc.com.au\/index.php\/wp-json\/wp\/v2\/tags?post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}