top of page

Translate Text using Azure Cognitive Services in Canvas Apps


Canvas Apps have so much Power! You can make really complicated functionality and connections into the application which have near endless possibilities. Recently, I presented at Scottish Summit showing some of these possibilities and this included using the Microsoft Translate API to translate text into other languages. In this post I’ll guide you through the process of setting this up and using it in Canvas Power Apps.

First thing to note is that this is a cognitive service provided by Microsoft, meaning that you need to provision the service in Azure. As such, it is subject to fees depending on your usage. You get a certain number of translations/calls a month for free and after that, you need to pay for it. You will also need the relevant permissions to be able to do this.

Go to you portal.azure.com and login using your Office 365 credentials. From here you should see an option to “Create a Service” and you can choose Cognitive Service

Click “Add” to add a new service.

Next you will be asked what type of service you want to create, for us we can type “Translator text” into the search box and then press return. You should see the Translator Text Cognitive service, click on it.

This screen tells you about the Translator Text service from Microsoft. To create it, press “Create”.

This next screen you need to fill in all the boxes:

  • Name - This is the name you are associating with this service. If you are creating this for a specific purpose, name this accordingly so that you know what this service relates to. I’d probably recommend creating a new service per application/usage so you can track usage.

  • Azure Subscription - This is the subscription you will be using for this service.

  • Pricing Tier - You can set your pricing here, meaning you can set limits, or Pay as you go.

  • Resource Group - This is the resource group which will be running this service, you can create one here if you need to.

Once you are done, click create. You will get notifications in the top right hand corner of this provisioning.

You will be redirected to a page which will be an overview of your service. Click on “Deployment details” and expand this section. Then click on the name of your service which will be a hyperlink.

Here you will see your subscription key. Copy this to your clipboard and that’s all you need from Azure.

Next, create a new Canvas App or open an existing one that you want to add this translation functionality to. On the left, click on Data Sources and then in the search box type “Microsoft Translate”. You should see two connectors, Microsoft Translate and Microsoft Translate V2 Preview (premium). You need to choose the right one for you and your app, but in my instance, i was choosing the original non premium version.

When you click it, there it be a flyout and a button for create “Add a connection” which you need to click and then there will be a dialog box asking for your subscription key. This is the key we copied to our clipboard from Azure.

Once you add your subscription key and press connect, if everything works you are good to go. Next we can use the service. The syntax for the formula we need for this is:

MicrosoftTranslator.Translate(<text to be translated>,<Language code for text to be translated into>,<Language code for language to be translated from>,<category>)

The text to be translated can come from anywhere in your app, a label or text field.

Language codes for source and target language is from a list of language codes define by Microsoft, you can view them here.

If you don’t populate the source language, the service will try to auto detect the language from it’s known languages. If you know the language, it would probably be better to populate it so it doesn’t mistranslate anything.

I can’t find much information online for the category, I'm guessing it relates to the translation category to help accurately translate the text, but it’s not required. The only parts of this formula that are required are the text and target language.

You can run this function from a button or have it automatically run as text is being entered, that choice is up to you, but hopefully this post helps you understand. Also, translate isn’t the only function you can use with this service. Detect the language, text to speech and others are available using this service.

Ciao for now!

bottom of page