Zero downtime patch deployments with newer Azure OpenAI Model support
The cb-ai-service uses Azure OpenAI model deployments provisioned using Terraform
During patches, newer versions of the cb-ai-service may require newer AI models. If existing model is deleted directly, then the running cb-ai-service may temporarily lose access, causing downtime.
To avoid this, patches with change in models must follow a three-step deployment:
1. Assume version 1.2.0.0 of the cb-ai-service requires models gpt-5.4-mini and gpt-5.4-nano:
To avoid downtime, follow the Model Transition Strategy below.
Provision infrastructure with new models, keeping existing model deployments as is.
2. Deploy the newer version of service which uses the new models.
3. Remove old models after successfully completing the service deployment.
This ensures the service always has valid models during the patch deployment.
Example Scenario
Initial Deployment (cb-ai-service v-1.1.0.0)
#-----------------OpenAI MODELS--------------------#
module "cognitive_deployment-gpt5-mini" {
source = "../../modules/cognitive/deployment"
name = "gpt-5-mini-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5-mini"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_mini_sku_name
sku_capacity = var.openai_gpt5_mini_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.content_filter]
}

module "cognitive_deployment-gpt5-nano" {
source = "../../modules/cognitive/deployment"
name = "gpt-5-nano-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5-nano"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_nano_sku_name
sku_capacity = var.openai_gpt5_nano_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.cognitive_deployment-gpt5-mini]
}
These deployments are created when the infrastructure for version 1.1.0.0 was provisioned. The cb-ai-service version 1.1.0.0 references these models.
Model Upgrade Scenario
Assume version 1.2.0.0 of the cb-ai-service requires models gpt-5.4-mini and gpt-5.4-nano.
To avoid downtime, follow the model transition strategy as follows..
Step 1: Deploy New Models Without Removing Old Ones
1. Update Terraform input variables to add the new model parameters while keeping existing models. For more information, refer Step 3: Configure Terraform infrastructure input parameters.
Example:
#-------------------OpenAI Models-------------------#
module "cognitive_deployment-gpt5-mini" {
source = "../../modules/cognitive/deployment"
name = "gpt-5-mini-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5-mini"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_mini_sku_name
sku_capacity = var.openai_gpt5_mini_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.content_filter]
}

module "cognitive_deployment-gpt5-nano" {
source = "../../modules/cognitive/deployment"
name = "gpt-5-nano-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5-nano"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_nano_sku_name
sku_capacity = var.openai_gpt5_nano_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.cognitive_deployment-gpt5-mini]
}
#---------------------------------------------------#

#-------------------ADD NEW MODEL-------------------#
module "cognitive_deployment-gpt5_4-mini" {
source = "../../modules/cognitive/deployment"
name = "gpt-5.4-mini-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5.4-mini"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_4_mini_sku_name
sku_capacity = var.openai_gpt5_4_mini_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.content_filter]
}

module "cognitive_deployment-gpt5_4-nano" {
source = "../../modules/cognitive/deployment"
name = "gpt-5.4-nano-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5.4-nano"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_4_nano_sku_name
sku_capacity = var.openai_gpt5_4_nano_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.cognitive_deployment-gpt5_4-mini]
}
#---------------------------------------------------#
2. Initialize Terraform.
terraform init -backend-config=backend.conf
3. Plan Terraform.
terraform plan -var-file=infra.tfvars
4. Apply Terraform.
terraform apply -var-file=infra.tfvars
This results into the following:
Model
Status
gpt-5-mini
Active
gpt-5-nano
Active
gpt-5.4-mini
Newly deployed
gpt-5.4-nano
Newly deployed
The running service continues using the old models gpt-5-mini and gpt-5-nano, and new models are provisioned.
Step 2: Deploy Respective Service Patch
For example, deploy the cb-ai-service image archive for version 1.2.0.0.
Follow the steps mentioned on Deploy CBAI Service Patch.
This deployment updates cb-ai-service to use the new models, gpt-5.4-mini and gpt-5.4-nano.
This results into the following:
Component
Status
Service
Running v-1.2.0.0
Model used by service
gpt-5.4-mini and gpt-5.4-nano
Old models
gpt-5-mini and gpt-5-nano still deployed
At this stage, the service is fully operational using the new model.
Step 3: Handling OpenAI Model Dependency Changes in Terraform
If OpenAI models are getting replaced or removed, in such cases, ensure that all model references are updated consistently across Terraform files.
Whenever model changes are introduced, verify the following:
terraform/deployment-profiles/infra-templates/main.tf— This has dependency references. Ensure that the depends_on only references active model modules.
For example, you have depends_on = [module.cognitive_deployment-gpt5-mini] and if gpt-5-mini is removed or not deployed, remove or update this dependency.
terraform/deployment-profiles/infra-templates/outputs.tf – This has model iutputs. Ensure that the outputs reference only active models.
For example, you have gpt5_mini = module.cognitive_deployment-gpt5-mini.name. Remove or update if the model is no longer deployed.
For downstream dependencies, ensure that the modules depending on model deployments reference only valid modules.
For example, you have depends_on = [module.cognitive_deployment-gpt5_4-mini]. This should always point to an existing model deployment.
The key rule is that all the model references in the following files must match the models defined in terraform/deployment-profiles/infra-templates/main.tf.
terraform/deployment-profiles/infra-templates/main.tf - depends_on
terraform/deployment-profiles/infra-templates/outputs.tf
Validation
Run terraform validate command. There must be no missing module errors and no invalid references.
Step 4: Remove Old Models
After the upgraded cb-ai-service service version is verified and stable, the old models can safely be removed.
1. Update Terraform configuration by removing the unused model modules:
#-------------------REMOVE THESE MODELS-------------------# 
module "cognitive_deployment-gpt5-mini" {
source = "../../modules/cognitive/deployment"
name = "gpt-5-mini-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5-mini"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_mini_sku_name
sku_capacity = var.openai_gpt5_mini_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.content_filter]
}

module "cognitive_deployment-gpt5-nano" {
source = "../../modules/cognitive/deployment"
name = "gpt-5-nano-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5-nano"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_nano_sku_name
sku_capacity = var.openai_gpt5_nano_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.cognitive_deployment-gpt5-mini]
}
#---------------------------------------------------#

#-------------------OpenAI Models-------------------#
module "cognitive_deployment-gpt5_4-mini" {
source = "../../modules/cognitive/deployment"
name = "gpt-5.4-mini-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5.4-mini"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_4_mini_sku_name
sku_capacity = var.openai_gpt5_4_mini_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.content_filter]
}

module "cognitive_deployment-gpt5_4-nano" {
source = "../../modules/cognitive/deployment"
name = "gpt-5.4-nano-2025-08-07"
cognitive_account_id = module.cognitive_account.id
model_name = "gpt-5.4-nano"
model_version = "2025-08-07"
sku_name = var.openai_gpt5_4_nano_sku_name
sku_capacity = var.openai_gpt5_4_nano_capacity
rai_policy_name = module.content_filter.rai_policy_name
depends_on = [module.cognitive_deployment-gpt5_4-mini]
}
#---------------------------------------------------#
2. Initialize Terraform.
terraform init -backend-config=backend.conf
3. Plan Terraform.
terraform plan -var-file=infra.tfvars
Review the plan to ensure only the older models, gpt-5-mini and gpt-5-nano, are removed.
4. Apply Terraform.
terraform apply -var-file=infra.tfvars
This results in the following:
Model
Status
gpt-5.4-mini
Active
gpt-5.4-nano
Active
gpt-5-mini
Removed
gpt-5-nano
Removed
Was this helpful?