Author avatar

Matthew Soucoup

Creating an Azure Cognitive Services Account

Matthew Soucoup

  • Aug 19, 2019
  • 6 Min read
  • Aug 19, 2019
  • 6 Min read
Azure Cognitive Services


Microsoft Azure Cognitive Services allows you to integrate machine learning into your applications. The best part is that you do not have to write any algorithms to do so!

Cognitive Services enable your app to identify objects within a photo or detect the sentiment behind a text snippet. This is done by using an SDK or calling a REST service. Those, in turn, will invoke the appropriate Cognitive Service in the Azure Cloud.

First, though, you need to create a Cognitive Services account in Azure. There are two different types of Cognitive Services accounts: single-service and multi-service subscriptions. A single-service subscription focuses on a single product, like Text Analytics. A multi-service subscription lets you access the full array of Cognitive Services through one account.

This guide will show you how to create a Cognitive Services multi-service subscription account using ARM templates.

Creating an Azure Resource Manager (ARM) Template

The Azure Resource Manager manages the deployments of resources for the Azure cloud. Whether you create resources through the Azure Portal user interface, the command line, or use REST APIs, they all use the Azure Resource Manager behind the scenes.

Azure Resource Manager (ARM) templates are JSON formatted and declaratively list out the resources to create in a single file. You can create one or many resources in an ARM template.

Having all the resources for your application defined in a single file allows you to reliably deploy them to any environment, every single time.

The Azure Command Line Interface (CLI) can execute ARM templates. Using the Azure CLI you specify any parameters needed to run the template, such as the name of the resource.

Below is an ARM template that creates a multi-service Cognitive Services account subscription.

2    "$schema": "",  
3    "contentVersion": "",  
4    "parameters": {  
5        "name": {  
6            "type": "String"  
7        },  
8        "location": {  
9            "type": "String"  
10        },  
11        "sku": {  
12            "type": "String"  
13        }  
14    },  
15    "resources": [{  
16        "type": "Microsoft.CognitiveServices/accounts",  
17        "apiVersion": "2016-02-01-preview",  
18        "name": "[parameters('name')]",  
19        "location": "[parameters('location')]",  
20        "sku": {  
21            "name": "[parameters('sku')]"  
22        },  
23        "kind": "CognitiveServices",  
24        "properties": {  
25            "apiProperties": {  
26                "statisticsEnabled": false  
27            }  
28        }  
29    }]  

This file specifies three parameters:

  • name of the resource
  • location or the Azure region it will be deployed to
  • sku or pricing level

Save this file with the name azuredeploy.json.

You will use this file when deploying the ARM Template in the next section.

Deploying via Azure Cloud Shell

To deploy the ARM Template and create the Microsoft Cognitive Services account, you will use the Cloud Shell.

The Cloud Shell is a browser-based shell located within the Azure portal. It will always have the latest Azure tools, such as the Azure CLI, applied to it.

To deploy the ARM template you created in the section above, open up the Azure portal and log in.

Then click on the button that looks like a command prompt.

cloud shell button

Once the cloud shell starts, select Bash from the dropdown.

select bash button

You will need to upload the file created in the previous step. Click the upload button, as shown below, and upload the file.

upload button

Next, you will execute a command to create a resource group; a resource group is like a folder that organizes Azure services.

Type the following in:

az group create -g MyCognitiveServicesAccount -l westus

The name which follows the -g parameter can be any name of your choosing. The value which follows the -l parameter must be an Azure region.

Next you'll run the template with this command:

1`az group deployment create -g MyCognitiveServicesAccount --template-file azuredeploy.json --parameters name=pluralsightcog location=westus2 sku=S0`

This command took several parameters:

  • The first, after the -g switch, indicated which resource group.
  • The second, --template-file, indicated the ARM template file's name.
  • And the last one, --parameters, is a space-delimited list of all the parameters defined in the ARM template, along with their values. Here, the name of the Cognitive Services account is pluralsightcog and it is deployed in the westus2 region, with the pricing or sku of S0.

After running this command, Azure will provision and create a new Multi-Service Cognitive Services account subscription.


In this guide, you learned how to create a Microsoft Cognitive Services Multi-Subscription account by using an ARM template.

The ARM template provides several advantages for creating resources over other means. The most important advantage is that you can declaratively specify one or many resources in a single template file for reliable deployments across environments.

The JSON formatted ARM template is deployed using the Azure CLI. Azure Cloud Shell will always have the latest and greatest version of the CLI, so it makes sense to use that when possible.