Provisioning of Azure Cognitive Service resources with Terraform
The Azure Cognitive services can be provisioned with Terraform building blocks using the “azurerm~>2.0” plugin.
The Azure AI cognitive services which support currently provisioning via Terraform are listed
- Azure Computer Vision
- Azure Face API
- Azure Text Analytics
- Azure Text Translator
- Azure QnA Maker
- Azure Personalizer
- Azure Custom Vision
- Azure LUIS API
- Azure Immersive reader
- Azure Form recognizer
- Azure Content Moderator
- Azure Anomaly Detector
- Azure Speech
**The Azure Cognitive Services in preview as of writing are not included
The terraform configuration starts with generic terraform “resource” declaration block followed by the type of resource & terraform resource name. Then it’s required to provide the respective Azure resource attributes like
- Name of the Azure cognitive service instance
- Dependency [with Azure Resource Group]
- Location of the Azure Resource [can be same location of Azure resource group or different]
- Kind [ which type of azure cognitive resource like Computer Vision, Face, ContentModerator, TextAnalytics etc.]
- SKU_name [pricing tier of the resource]
- Tags [if required]
The sample terraform code for provisioning the Azure Computer Vision API is as followed
resource “azurerm_cognitive_account” “computer_vision” {
depends_on = [azurerm_resource_group.example]
name = “${var.computer_vision_instance_name}”
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
kind = “ComputerVision”
sku_name = “F0”
tags = {
“Environment” = “Dev”
“CostCenter” = “ML/AI”
}
}
The repository link of the Azure cognitive services APIs provisioning through Terraform configurations is available in the following link on Github
# Happy terraforming!