|
| 1 | +--- |
| 2 | +title: Create an Azure AI services resource using Azure PowerShell |
| 3 | +titleSuffix: Azure AI services |
| 4 | +description: Get started with Azure AI services by using Azure PowerShell commands to create and subscribe to a resource. |
| 5 | +services: cognitive-services |
| 6 | +author: mgreenegit |
| 7 | +manager: nitinme |
| 8 | +ms.service: cognitive-services |
| 9 | +keywords: Azure AI services, cognitive intelligence, cognitive solutions, ai services |
| 10 | +ms.topic: include |
| 11 | +ms.date: 08/29/2022 |
| 12 | +ms.author: migreene |
| 13 | +ms.custom: mode-api, devx-track-azurepowershell |
| 14 | +ms.devlang: azurepowershell |
| 15 | +--- |
| 16 | + |
| 17 | +Use this quickstart to create an Azure AI services resource using [Azure PowerShell](/powershell/azure/install-azure-powershell) commands. After you create the resource, use the keys and endpoint generated for you to authenticate your applications. |
| 18 | + |
| 19 | +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. |
| 20 | + |
| 21 | +## Prerequisites |
| 22 | + |
| 23 | +* A valid Azure subscription - [Create one](https://azure.microsoft.com/free/cognitive-services) for free. |
| 24 | +* [Azure PowerShell](/powershell/azure/install-azure-powershell) |
| 25 | +* [!INCLUDE [contributor-requirement](contributor-requirement.md)] |
| 26 | +* [!INCLUDE [terms-azure-portal](terms-azure-portal.md)] |
| 27 | + |
| 28 | +## Install Azure PowerShell and sign in |
| 29 | + |
| 30 | +Install [Azure PowerShell](/powershell/azure/install-azure-powershell). To sign in, run the [Connect-AzAccount](/powershell/module/az.accounts/connect-azaccount) command: |
| 31 | + |
| 32 | +```azurepowershell |
| 33 | +Connect-AzAccount |
| 34 | +``` |
| 35 | + |
| 36 | +You can also use the green **Try It** button to run these commands in your browser. |
| 37 | + |
| 38 | +## Create a new Azure AI services resource group |
| 39 | + |
| 40 | +Before you create an Azure AI services resource, you must have an Azure resource group to contain the resource. When you create a new resource, you can either create a new resource group, or use an existing one. This article shows how to create a new resource group. |
| 41 | + |
| 42 | +### Choose your resource group location |
| 43 | + |
| 44 | +To create a resource, you'll need one of the Azure locations available for your subscription. You can retrieve a list of available locations with the [Get-AzLocation](/powershell/module/az.resources/get-azlocation) command. Most Azure AI services can be accessed from several locations. Choose the one closest to you, or see which locations are available for the service. |
| 45 | + |
| 46 | +> [!IMPORTANT] |
| 47 | +> * Remember your Azure location, as you will need it when calling the Azure AI services resources. |
| 48 | +> * The availability of some Azure AI services can vary by region. For more information, see [Azure products by region](https://azure.microsoft.com/global-infrastructure/services/?products=cognitive-services). |
| 49 | +
|
| 50 | +```azurepowershell-interactive |
| 51 | +Get-AzLocation | Select-Object -Property Location, DisplayName |
| 52 | +``` |
| 53 | + |
| 54 | +After you have your Azure location, create a new resource group in Azure PowerShell using the [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup) command. In the example below, replace the Azure location `westus2` with one of the Azure locations available for your subscription. |
| 55 | + |
| 56 | +```azurepowershell-interactive |
| 57 | +New-AzResourceGroup -Name ai-services-resource-group -Location westus2 |
| 58 | +``` |
| 59 | + |
| 60 | +## Create an Azure AI services resource |
| 61 | + |
| 62 | +### Choose a service and pricing tier |
| 63 | + |
| 64 | +When you create a new resource, you'll need to know the kind of service you want to use, along with the [pricing tier](https://azure.microsoft.com/pricing/details/cognitive-services/) (or SKU) you want. You'll use this and other information as parameters when you create the resource. |
| 65 | + |
| 66 | +[!INCLUDE [SKUs and pricing](sku-pricing.md)] |
| 67 | + |
| 68 | +You can find a list of available Azure AI services "kinds" with the [Get-AzCognitiveServicesAccountType](/powershell/module/az.cognitiveservices/get-azcognitiveservicesaccounttype) command: |
| 69 | + |
| 70 | +```azurepowershell-interactive |
| 71 | +Get-AzCognitiveServicesAccountType |
| 72 | +``` |
| 73 | + |
| 74 | +### Add a new resource to your resource group |
| 75 | + |
| 76 | +To create and subscribe to a new Azure AI services resource, use the [New-AzCognitiveServicesAccount](/powershell/module/az.cognitiveservices/new-azcognitiveservicesaccount) command. This command adds a new billable resource to the resource group you created earlier. When you create your new resource, you'll need to know the "kind" of service you want to use, along with its pricing tier (or SKU) and an Azure location: |
| 77 | + |
| 78 | +You can create a Standard S0 multi-service resource named `multi-service-resource` with the command below. |
| 79 | + |
| 80 | +```azurepowershell-interactive |
| 81 | +New-AzCognitiveServicesAccount -ResourceGroupName ai-services-resource-group -Name multi-service-resource -Type CognitiveServices -SkuName F0 -Location westus2 |
| 82 | +``` |
| 83 | + |
| 84 | +> [!Tip] |
| 85 | +> If your subscription doesn't allow you to create an Azure AI services resource, you may need to enable the privilege of that [Azure resource provider](../../../azure-resource-manager/management/resource-providers-and-types.md#register-resource-provider) using the [Azure portal](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-portal), an [Azure PowerShell command](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-powershell) or an [Azure CLI command](../../../azure-resource-manager/management/resource-providers-and-types.md#azure-cli). 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. |
| 86 | +
|
| 87 | +## Get the keys for your resource |
| 88 | + |
| 89 | +Use the [Get-AzCognitiveServicesAccountKey](/powershell/module/az.cognitiveservices/get-azcognitiveservicesaccountkey) command to get the keys for your resource. |
| 90 | + |
| 91 | +```azurepowershell-interactive |
| 92 | +Get-AzCognitiveServicesAccountKey -Name multi-service-resource -ResourceGroupName ai-services-resource-group |
| 93 | +``` |
| 94 | + |
| 95 | +[!INCLUDE [environment-variables](environment-variables.md)] |
| 96 | + |
| 97 | +## Pricing tiers and billing |
| 98 | + |
| 99 | +Pricing tiers (and the amount you get billed) are based on the number of transactions you send using your authentication information. Each pricing tier specifies the: |
| 100 | +* maximum number of allowed transactions per second (TPS). |
| 101 | +* service features enabled within the pricing tier. |
| 102 | +* The cost for a predefined number of transactions. Going above this amount will cause an extra charge as specified in the [pricing details](https://azure.microsoft.com/pricing/details/cognitive-services/custom-vision-service/) for your service. |
| 103 | + |
| 104 | +## Get current quota usage for your resource |
| 105 | + |
| 106 | +Use the [Get-AzCognitiveServicesAccountUsage](/powershell/module/az.cognitiveservices/get-azcognitiveservicesaccountusage) command to get the usage for your resource. |
| 107 | + |
| 108 | +```azurepowershell-interactive |
| 109 | +Get-AzCognitiveServicesAccountUsage -ResourceGroupName ai-services-resource-group -Name multi-service-resource |
| 110 | +``` |
| 111 | + |
| 112 | +## Clean up resources |
| 113 | + |
| 114 | +If you want to clean up and remove an Azure AI services resource, you can delete it or the resource group. Deleting the resource group also deletes any other resources contained in the group. |
| 115 | + |
| 116 | +To remove the resource group and its associated resources, use the [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup) command. |
| 117 | + |
| 118 | +```azurepowershell-interactive |
| 119 | +Remove-AzResourceGroup -Name ai-services-resource-group |
| 120 | +``` |
| 121 | + |
| 122 | +If you need to recover a deleted resource, see [Recover deleted Azure AI services resources](../../manage-resources.md). |
0 commit comments