Azure / terraform-azurerm-openai

Terraform module for deploying Azure OpenAI Service.
MIT License
44 stars 33 forks source link

Unable to create a GPT-4o deployment via the terraform-azurerm-openai module #87

Closed lonegunmanb closed 4 months ago

lonegunmanb commented 4 months ago

Is there an existing issue for this?

Greenfield/Brownfield provisioning

greenfield

Terraform Version

1.7.4

Module Version

v0.1.3

AzureRM Provider Version

3.112.0

Affected Resource(s)/Data Source(s)

azurerm_cognitive_deployment

Terraform Configuration Files

locals {
  deployment_map = {
    dev = {
      "chat_model_gpt_4o_2024_05_13" = {
        name          = "gpt-4o-2024-05-13"
        model_format  = "OpenAI"
        model_name    = "gpt-4o"
        model_version = "2024-05-13"
        scale_type    = "Standard"
        capacity      = 2
      },
    }
    prod = {
      "chat_model_gpt_4o_2024_05_13" = {
        name          = "gpt-4o-2024-05-13"
        model_format  = "OpenAI"
        model_name    = "gpt-4o"
        model_version = "2024-05-13"
        scale_type    = "Standard"
        capacity      = 6
      },
    }
  }
}

module "openai" {
  source                        = "Azure/openai/azurerm"
  version                       = "0.1.3"
  account_name                  = "${replace(var.namespace, "_", "-")}-openai-service-${var.environment}"
  custom_subdomain_name         = "${replace(var.namespace, "_", "-")}-openai-service-${var.environment}"
  resource_group_name           = azurerm_resource_group.resource_group.name
  location                      = azurerm_resource_group.resource_group.location
  public_network_access_enabled = true
  deployment                    = local.deployment_map[var.environment]
  depends_on = [
    azurerm_resource_group.resource_group,
  ]
}

tfvars variables values

none

Debug Output/Panic Output

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Expected Behaviour

No response

Actual Behaviour

No response

Steps to Reproduce

No response

Important Factoids

No response

References

https://github.com/hashicorp/terraform-provider-azurerm/issues/26681

lonegunmanb commented 4 months ago

I've tried to reproduce this issue by the following config bug I was failed to reproduce any issue:

# Azure provider version
terraform {
  required_version = ">= 1.3.0"

  required_providers {
    azurerm = {
      source  = "hashicorp/azurerm"
      version = "~> 3.0"
    }
    modtm = {
      source  = "Azure/modtm"
      version = ">= 0.1.8, < 1.0"
    }
  }
}

provider "azurerm" {
  features {}
}

provider "modtm" {
  enabled = false
}

locals {
  deployment_map = {
    dev = {
      "chat_model_gpt_4o_2024_05_13" = {
        name          = "gpt-4o-2024-05-13"
        model_format  = "OpenAI"
        model_name    = "gpt-4o"
        model_version = "2024-05-13"
        scale_type    = "Standard"
        capacity      = 2
      },
    }
    prod = {
      "chat_model_gpt_4o_2024_05_13" = {
        name          = "gpt-4o-2024-05-13"
        model_format  = "OpenAI"
        model_name    = "gpt-4o"
        model_version = "2024-05-13"
        scale_type    = "Standard"
        capacity      = 6
      },
    }
  }
}

variable "namespace" {
    type        = string
    description = "The namespace for the resources"
    default = "openai"
}

variable "environment" {
    type        = string
    description = "The environment for the resources"
    default = "dev"
}

resource "random_pet" "this" {}

resource "azurerm_resource_group" "resource_group" {
  location = "Sweden Central"
  name     = "f26681${random_pet.this.id}"
}

module "openai" {
  source                        = "Azure/openai/azurerm"
  version                       = "0.1.3"
  account_name                  = "${replace(var.namespace, "_", "-")}-openai-service-${var.environment}-${random_pet.this.id}"
  custom_subdomain_name         = "${replace(var.namespace, "_", "-")}-openai-service-${var.environment}-${random_pet.this.id}"
  resource_group_name           = azurerm_resource_group.resource_group.name
  location                      = azurerm_resource_group.resource_group.location
  public_network_access_enabled = true
  deployment                    = local.deployment_map[var.environment]
  depends_on = [
    azurerm_resource_group.resource_group,
  ]
}

Both cognitive account and deployment have been created in Sweden Central:

image

@MBKraus would you please try this config on your side? Thanks!

MBKraus commented 4 months ago

Many thanks @lonegunmanb ! When changing any of the model deployments in the infra base nothing changed on Azure ; I went through my code, and it was a bug in my code :) I've got multiple modules running, and this one was pointing to the wrong one :) Apologies for the hassle - and many thanks for pointing me in the right direction!

zioproto commented 4 months ago

@MBKraus based on the information in your latest comment I am going to close this issue. Please let us know if you have any additional questions. Thanks

cffranco94 commented 3 months ago

Hello @zioproto ,

I am also having troubles deploying gpt4o. Should I open another issue? I am getting an error related to the scale_type being Standard: "InvalidResourceProperties: The specified scale type 'Standard' of account deployment is not supported by the model 'gpt-4o'." I also tried "Global-Standard" but the issue persisted. Can you please help?

module "openai" {
  source              = "Azure/openai/azurerm"
  resource_group_name = azurerm_resource_group.rg.name
  location            = "Switzerland North"
  private_endpoint = {
    "pe_endpoint" = {
      private_dns_entry_enabled       = true
      dns_zone_virtual_network_link   = "dns_zone_link_openai"
      is_manual_connection            = false
      name                            = "openai_pe"
      private_service_connection_name = "openai_pe_connection"
      subnet_name                     = azurerm_subnet.subnet.name
      vnet_name                       = azurerm_virtual_network.vnet.name
      vnet_rg_name                    = azurerm_resource_group.rg.name
    }
  }
  deployment = {
    "chat_3_model" = {
      name          = "gpt-35-turbo"
      model_format  = "OpenAI"
      model_name    = "gpt-35-turbo"
      model_version = "0613"
      scale_type    = "Standard"
      capacity      = 120
    },
    "chat_4_model" = {
      name          = "gpt-4o"
      model_format  = "OpenAI"
      model_name    = "gpt-4o"
      model_version = "2024-05-13"
      scale_type    = "Standard"
      capacity      = 10
    },
    "embedding_model" = {
      name          = "text-embedding-ada-002"
      model_format  = "OpenAI"
      model_name    = "text-embedding-ada-002"
      model_version = "2"
      scale_type    = "Standard"
      capacity      = 120
    },
  }
  depends_on = [
    azurerm_resource_group.rg
  ]
}
zioproto commented 3 months ago

If you want to use Switzerland North please set the scale_type to GlobalStandard

cffranco94 commented 3 months ago

@zioproto , thank you!