Create an Azure AI services resource using Bicep

Follow this quickstart to create Azure AI services resource using Bicep.

Azure AI services are cloud-based artificial intelligence (AI) services that help developers build cognitive intelligence into applications without having direct AI or data science skills or knowledge. They are available through REST APIs and client library SDKs in popular development languages. Azure AI services enables developers to easily add cognitive features into their applications with cognitive solutions that can see, hear, speak, and analyze.

Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.

Things to consider

Using Bicep to create an Azure AI services resource lets you create a multi-service resource. This enables you to:

  • Access multiple Azure AI services with a single key and endpoint.
  • Consolidate billing from the services you use.
  • If you're planning to use Spatial Analysis in Azure AI Vision or Text Analytics for Health in Azure AI Language, then you must create your first Vision or Language resources from the Azure portal so you can review and acknowledge the terms and conditions. You can do so here: Azure AI Language, Azure AI Vision. After that, you can create subsequent resources using any deployment tool (for example, SDK, CLI, or ARM template) under the same Azure subscription.

Prerequisites

Review the Bicep file

The Bicep file used in this quickstart is from Azure Quickstart Templates.

Note

  • If you use a different resource kind (listed below), you may need to change the sku parameter to match the pricing tier you wish to use. For example, the TextAnalytics kind uses S instead of S0.
  • Many of the Azure AI services have a free F0 pricing tier that you can use to try the service.

Be sure to change the sku parameter to the pricing instance you want. The sku depends on the resource kind that you are using. For example, TextAnalytics

@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>)')
param cognitiveServiceName string = 'CognitiveService-${uniqueString(resourceGroup().id)}'

@description('Location for all resources.')
param location string = resourceGroup().location

@allowed([
  'S0'
])
param sku string = 'S0'

resource cognitiveService 'Microsoft.CognitiveServices/accounts@2021-10-01' = {
  name: cognitiveServiceName
  location: location
  sku: {
    name: sku
  }
  kind: 'CognitiveServices'
  properties: {
    apiProperties: {
      statisticsEnabled: false
    }
  }
}

One Azure resource is defined in the Bicep file: Microsoft.CognitiveServices/accounts specifies that it is an Azure AI services resource. The kind field in the Bicep file defines the type of resource.

The following tables provide information about products and pricing for Azure AI services.

Multi-service

Service Kind
Multiple services. For more information, see the pricing page. CognitiveServices

Vision

Service Kind
Vision ComputerVision
Custom Vision - Prediction CustomVision.Prediction
Custom Vision - Training CustomVision.Training
Face Face
Document Intelligence FormRecognizer

Speech

Service Kind
Speech SpeechServices

Language

Service Kind
Language Understanding (LUIS) LUIS
QnA Maker QnAMaker
Language TextAnalytics
Text Translation TextTranslation

Decision

Service Kind
Anomaly Detector AnomalyDetector
Content Moderator ContentModerator
Personalizer Personalizer

Azure OpenAI

Service Kind
Azure OpenAI OpenAI

Pricing tiers and billing

Pricing tiers (and the amount you're billed) are based on the number of transactions that you send by using your authentication information. Each pricing tier specifies the:

  • Maximum number of allowed transactions per second (TPS).
  • Service features enabled within the pricing tier.
  • Cost for a predefined number of transactions. Going above this number will cause an extra charge, as specified in the pricing details for your service.

Note

Many of the Azure AI services have a free tier that you can use to try the service. To use the free tier, use F0 as the pricing tier for your resource.

Deploy the Bicep file

  1. Save the Bicep file as main.bicep to your local computer.

  2. Deploy the Bicep file using either Azure CLI or Azure PowerShell.

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep
    

    When the deployment finishes, you should see a message indicating the deployment succeeded.

Review deployed resources

Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.

az resource list --resource-group exampleRG

Clean up resources

When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources.

az group delete --name exampleRG

See also