I use Terraform by deploying an Azure OpenAI resource by the following code:
resource "azurerm_cognitive_account" "openai" {
name = var.openai_name
location = var.resource_location
resource_group_name = var.resource_group_name
kind = "OpenAI"
sku_name = "S0"
}
However, this code seems to deploy an Azure OpenAI resource with a region based endpoint instead of a resource based endpoint. See here the difference when I do it via the Azure portal vs via Terraform code:
vs.
Why does this happen and how can I create an Azure OpenAI resource with a region based endpoint using Terraform?
Basically, the functionality of terraform resource azurerm_cognitive_account
open AI supports a region-based endpoints deployment as shown in the below code.
data "azurerm_resource_group" "example" {
name = "xxx"
}
resource "azurerm_cognitive_account" "openai" {
name = "regionalai"
location = data.azurerm_resource_group.example.location
resource_group_name = data.azurerm_resource_group.example.name
kind = "OpenAI"
sku_name = "S0"
}
Deployment succeeded:
If you want to explicitly specify an endpoint as resource-based or any other, you can use custom_subdomain_name
parameter available in azurerm_cognitive_account
terraform resource as shown below.
data "azurerm_resource_group" "example" {
name = "xxxx"
}
resource "azurerm_cognitive_account" "openai" {
name = "regionalai"
location = data.azurerm_resource_group.example.location
resource_group_name = data.azurerm_resource_group.example.name
kind = "OpenAI"
sku_name = "S0"
custom_subdomain_name = "testvkdomain"
}
Output: