Quickstart: Create a Cognitive Services resource using an ARM template

This quickstart describes how to use an Azure Resource Manager template (ARM template) to create Cognitive Services.

Azure Cognitive Services are cloud-base services with REST APIs, and client library SDKs available to help developers build cognitive intelligence into applications without having direct artificial intelligence (AI) or data science skills or knowledge. Azure Cognitive Services enables developers to easily add cognitive features into their applications with cognitive solutions that can see, hear, speak, understand, and even begin to reason.

Create a resource using an Azure Resource Manager template (ARM template). This multi-service resource lets you:

  • Access multiple Azure Cognitive Services with a single key and endpoint.
  • Consolidate billing from the services you use.
  • You must create your first Face, Language service, or Computer Vision resources from the Azure portal to review and acknowledge the terms and conditions. You can do so here: Face, Language service, Computer Vision. After that, you can create subsequent resources using any deployment tool (SDK, CLI, or ARM template, etc) under the same Azure subscription.

An ARM template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. In declarative syntax, you describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.

Deploy your cognitive service to Azure

Prerequisites

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.5.6.12127",
      "templateHash": "15212843909029853621"
    }
  },
  "parameters": {
    "cognitiveServiceName": {
      "type": "string",
      "defaultValue": "[format('CognitiveService-{0}', uniqueString(resourceGroup().id))]",
      "metadata": {
        "description": "That name is the name of our application. It has to be unique.Type a name followed by your resource group name. (<name>-<resourceGroupName>)"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    },
    "sku": {
      "type": "string",
      "defaultValue": "S0",
      "allowedValues": [
        "S0"
      ]
    }
  },
  "resources": [
    {
      "type": "Microsoft.CognitiveServices/accounts",
      "apiVersion": "2021-10-01",
      "name": "[parameters('cognitiveServiceName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "[parameters('sku')]"
      },
      "kind": "CognitiveServices",
      "properties": {
        "apiProperties": {
          "statisticsEnabled": false
        }
      }
    }
  ]
}

One Azure resource is defined in the template:

Deploy the template

  1. Click the Deploy to Azure button.

    Deploy to Azure

  2. Enter the following values.

    Value Description
    Subscription Select an Azure subscription.
    Resource group Select Create new, enter a unique name for the resource group, and then click OK.
    Region Select a region. For example, East US
    Cognitive Service Name Replace with a unique name for your resource. You will need the name in the next section when you validate the deployment.
    Location Replace with the region used above.
    Sku The pricing tier for your resource.

    Resource creation screen.

  3. Select Review + Create, then Create. After the resource has successfully finished deploying, the Go to resource button will be highlighted.

Tip

If your subscription doesn't allow you to create a Cognitive Service resource, you may need to enable that ability of the Azure resource provider with the Azure portal, PowerShell command or an Azure CLI command. If you are not the subscription owner, ask the Subscription Owner or someone with a role of admin to complete the registration for you or ask for the /register/action privileges granted to your account.

Review deployed resources

When your deployment finishes, you will be able to click the Go to resource button to see your new resource. You can also find the resource group by:

  1. Selecting Resource groups from the left navigation menu.
  2. Selecting the resource group name.

Clean up resources

If you want to clean up and remove a Cognitive Services subscription, you can delete the resource or resource group. Deleting the resource group also deletes any other resources contained in the group.

  1. In the Azure portal, expand the menu on the left side to open the menu of services, and choose Resource Groups to display the list of your resource groups.
  2. Locate the resource group containing the resource to be deleted
  3. Right-click on the resource group listing. Select Delete resource group, and confirm.

If you need to recover a deleted resource, see Recover deleted Cognitive Services resources.

See also