Quickstart: Create a Cognitive Services resource using the Azure portal
Article
Use this quickstart to create a Cognitive Services resource. After you create a Cognitive Service resource in the Azure portal, you'll get an endpoint and a key for authenticating your applications.
Azure Cognitive Services is 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're available through REST APIs and client library SDKs in popular development languages. Azure Cognitive Services enables developers to easily add cognitive features into their applications with cognitive solutions that can see, hear, speak, and analyze.
Types of Cognitive Services resources
You can access Azure Cognitive Services through two different resources: A multi-service resource, or a single-service one.
Multi-service resource:
Access multiple Azure Cognitive Services with a single key and endpoint.
Consolidates billing from the services you use.
Single-service resource:
Access a single Azure Cognitive Service with a unique key and endpoint for each service created.
Your Azure account must have a Cognitive Services Contributor role assigned in order for you to agree to the responsible AI terms and create a resource. To get this role assigned to your account, follow the steps in the Assign roles documentation, or contact your administrator.
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Configure other settings for your resource as needed, read and accept the conditions (as applicable), and then select Review + create.
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Select Review + create.
Select the following link to create a Content Moderator resource:
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Select Review + create.
Select the following link to create a Metrics Advisor resource:
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Storage
You can optionally use your own Azure database resource to store the data that Metrics Advisor will use.
Mark your acknowledgment of the Service Agreement and Terms and then select Review + create.
On the Select additional features page, choose whether you'd like to include the customization features that work with other services.
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Mark your acknowledgment of the Responsible AI terms and select Review + create.
Select the following link to create a LUIS resource:
On the Create page, provide the following information:
Project details
Description
Create options
LUIS uses two separate resources together. The Authoring resource lets you train models, and the Prediction resource lets you publish and query models. Select Both if you're starting the project from scratch.
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Authoring Resource Region
The location of your Authoring resource. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Authoring Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Prediction Resource Region
The location of your Prediction resource. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Prediction Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Select Review + create.
Select the following link to create a Translator resource:
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Select Review + create.
Select the following link to create a QnA Maker resource:
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Azure Search location
The location of the Azure Search instance that will go with your QnA Maker resource. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Azure Search pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the Cognitive Search pricing details.
App name
Enter a name for the App Service app that will handle your QnA Maker queries.
Website location
The location of the App Service instance that will go with your QnA Maker resource. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
App insights
Choose whether you'd like to use an Application Insights resource in tandem with your QnA Maker resource.
App insights location
Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Select Review + create.
Select the following links to create a Speech resource:
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Mark your acknowledgment of the Responsible AI terms and then select Review + create.
Select the following link to create a Face resource:
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that will contain your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Mark your acknowledgment of the Face terms of use and then select Review + create.
Select the following link to create a Custom Vision resource:
On the Create page, provide the following information:
Project details
Description
Create options
Custom Vision uses two separate resources together. The Training resource lets you train models, and the Prediction resource lets you publish and query models. Select Both if you're starting the project from scratch.
Subscription
Select one of your available Azure subscriptions.
Resource group
The Azure resource group that contains your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Training pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Prediction pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see the API pricing details.
Select Review + create.
Select the following link to create a Form Recognizer resource:
On the Create page, provide the following information:
Project details
Description
Subscription
Select one of your available Azure subscriptions.
Resource group
Select the Azure resource group that contains your Cognitive Services resource. You can create a new group or add it to a pre-existing group.
Region
The location of your cognitive service instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource.
Name
A descriptive name for your cognitive services resource. For example, MyCognitiveServicesResource.
Pricing tier
The cost of your Cognitive Services account depends on the options you choose and your usage. For more information, see service quotas and limits and pricing details.
Select Review + create.
Tip
If your subscription doesn't allow you to create a Cognitive Service resource, you may need to enable the privilege of that Azure resource provider using 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 to be granted to your account.
Get the keys for your resource
After your resource is successfully deployed, select Next Steps > Go to resource.
From the quickstart pane that opens, you can access the resource endpoint and manage keys.
Configure an environment variable for authentication
Your application must be authenticated to access Cognitive Services resources. For production, use a secure way of storing and accessing your credentials. For example, after you have a key for your resource, write it to a new environment variable on the local machine running the application.
Tip
Don't include the key directly in your code, and never post it publicly. See the Cognitive Services security article for more authentication options like Azure Key Vault.
To set the environment variable for your resource key, open a console window, and follow the instructions for your operating system and development environment. To set the COGNITIVE_SERVICE_KEY environment variable, replace your-key with one of the keys for your resource.
If you only need to access the environment variable in the current running console, you can set the environment variable with set instead of setx.
After you add the environment variable, you may need to restart any running consoles or other programs that will need to read the environment variable. For example, if you are using Visual Studio as your editor, restart Visual Studio before running the example.
export COGNITIVE_SERVICE_KEY=your-key
After you add the environment variable, run source ~/.bashrc from your console window to make the changes effective.
Bash
Edit your .bash_profile, and add the environment variable:
export COGNITIVE_SERVICE_KEY=your-key
After you add the environment variable, run source ~/.bash_profile from your console window to make the changes effective.
Xcode
For iOS and macOS development, you set the environment variables in Xcode. For example, follow these steps to set the environment variable in Xcode 13.4.1.
Select Product > Scheme > Edit scheme
Select Arguments on the Run (Debug Run) page
Under Environment Variables select the plus (+) sign to add a new environment variable.
Enter COGNITIVE_SERVICE_KEY for the Name and enter your resource key for the Value.
To set the environment variable for your Speech resource region, follow the same steps. Set COGNITIVE_SERVICE_REGION to the region of your resource. For example, westus.
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.
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.
Locate the resource group containing the resource to be deleted.
If you want to delete the entire resource group, select the resource group name. On the next page, Select Delete resource group, and confirm.
If you want to delete only the Cognitive Service resource, select the resource group to see all the resources within it. On the next page, select the resource that you want to delete, select the ellipsis menu for that row, and select Delete.