Create an Azure AI services resource using Bicep

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

Azure AI services help developers and organizations rapidly create intelligent, cutting-edge, market-ready, and responsible applications with out-of-the-box and prebuilt and customizable APIs and models. Example applications include natural language processing for conversations, search, monitoring, translation, speech, vision, and decision-making.

Tip

Try Azure AI services including Azure OpenAI, Content Safety, Speech, Vision, and more in Azure AI Studio. For more information, see What is Azure AI Studio?.

Most Azure AI services are available through REST APIs and client library SDKs in popular development languages. For more information, see each service's documentation.

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.

Prerequisites

Review the Bicep file

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

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

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

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

resource account 'Microsoft.CognitiveServices/accounts@2023-05-01' = {
  name: aiServicesName
  location: location
  identity: {
    type: 'SystemAssigned'
  }
  sku: {
    name: sku
  }
  kind: 'AIServices'
  properties: {
    publicNetworkAccess: 'Disabled'
    networkAcls: {
      defaultAction: 'Deny'
    }
    disableLocalAuth: true
  }
}

One Azure resource is defined in the Bicep file. The kind field in the Bicep file defines the type of resource.

As needed, change the sku parameter value to the pricing instance you want. The sku depends on the resource kind that you use. For example, use TextAnalytics for the Azure AI Language service. The TextAnalytics kind uses S instead of S0 for the sku value.

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