When you need this
You have to move Azure OpenAI workloads to a different resource. Common reasons are a region change for data residency or capacity, moving to a new subscription or landing zone, swapping a public resource for one behind Private Link, or splitting a shared resource by team.
You can't move model deployments between resources. You have to recreate them and switch the apps across. Here's the order:
- Inventory the old resource.
- Check that quota and models are available in the target.
- Create the target resource with the same network and identity settings.
- Recreate content filters, then deployments.
- Smoke test, switch traffic, keep the old resource as rollback.
SUB=<subscription-id>
OLD_RG=rg-ai-prod; OLD=aoai-prod-weu
NEW_RG=rg-ai-prod2; NEW=aoai-prod-swc; NEW_LOC=swedencentral
API=2024-10-01
az account set --subscription $SUB
Step 1: Inventory the old resource
# Deployments: name, model, version, type, capacity, filter, upgrade policy
az cognitiveservices account deployment list -g $OLD_RG -n $OLD \
--query "[].{name:name, model:properties.model.name, version:properties.model.version, format:properties.model.format, sku:sku.name, capacity:sku.capacity, rai:properties.raiPolicyName, upgrade:properties.versionUpgradeOption}" \
-o table
# Full JSON for the recreate step
az rest --method get \
--url "https://management.azure.com/subscriptions/$SUB/resourceGroups/$OLD_RG/providers/Microsoft.CognitiveServices/accounts/$OLD/deployments?api-version=$API" \
> old-deployments.json
# Custom content filters (raiPolicies) and blocklists
az rest --method get \
--url "https://management.azure.com/subscriptions/$SUB/resourceGroups/$OLD_RG/providers/Microsoft.CognitiveServices/accounts/$OLD/raiPolicies?api-version=$API" \
> old-raipolicies.json
az rest --method get \
--url "https://management.azure.com/subscriptions/$SUB/resourceGroups/$OLD_RG/providers/Microsoft.CognitiveServices/accounts/$OLD/raiBlocklists?api-version=$API" \
> old-blocklists.json
# Network, identity and auth settings you must copy
az cognitiveservices account show -g $OLD_RG -n $OLD \
--query "{kind:kind, sku:sku.name, subdomain:properties.customSubDomainName, publicAccess:properties.publicNetworkAccess, localAuthDisabled:properties.disableLocalAuth, networkAcls:properties.networkAcls, identity:identity.type}"
# Who has data-plane access
az role assignment list --all --scope $(az cognitiveservices account show -g $OLD_RG -n $OLD --query id -o tsv) \
--query "[].{who:principalName, type:principalType, role:roleDefinitionName}" -o table
Also record what lives outside the resource but depends on it:
| Item | Where to look |
|---|---|
| Private endpoint and private DNS zone link | az network private-endpoint list, zone privatelink.openai.azure.com |
| Diagnostic settings | az monitor diagnostic-settings list --resource <id> |
| Alerts on the old resource ID | az monitor metrics alert list |
| Gateway backends (APIM, LiteLLM) | Backend URLs and named values |
| App settings with the endpoint or key | App Service, Functions, AKS secrets, Key Vault |
| Fine-tuned models | These need their own copy step; check what your region supports |
| Data on the resource (files, batch jobs, stored completions, assistants) | These aren't copied; finish or re-upload them |
Step 2: Check models and quota in the target
# Is the model and version offered in the target region?
az cognitiveservices model list -l $NEW_LOC \
--query "[?model.name=='gpt-4o'].{version:model.version, skus:model.skus[].name, retire:model.deprecation.inference}" -o table
# Quota used and limit in the target region
az cognitiveservices usage list -l $NEW_LOC \
--query "[?contains(name.value,'gpt-4o')].{name:name.value, used:currentValue, limit:limit}" -o table
Add up the capacity of the deployments you plan to move, per model and deployment type. Then check that the target region's quota covers it. Quota is per subscription, per region and per deployment type, so moving to a new subscription starts you from that subscription's quota.
Warning
Model versions offered in a region change over time. If the old resource runs a version the target no longer offers, you will also be upgrading the model. Treat it as a model change: run your evaluation set against the new version before the cut-over, not after.
Step 3: Create the target resource
az cognitiveservices account create -g $NEW_RG -n $NEW -l $NEW_LOC \
--kind OpenAI --sku S0 --custom-domain $NEW --yes
# Match the old auth and network posture
az resource update --ids $(az cognitiveservices account show -g $NEW_RG -n $NEW --query id -o tsv) \
--set properties.disableLocalAuth=true properties.publicNetworkAccess=Disabled
az cognitiveservices account identity assign -g $NEW_RG -n $NEW
If your old resource is the newer AI Foundry kind (AIServices), create the same kind. Then create the private endpoint, link the DNS zone, add diagnostic settings and grant the same roles (Cognitive Services OpenAI User for apps, Cognitive Services OpenAI Contributor for operators) to the same identities.
Caution
If you set
publicNetworkAccess=Disabledbefore the private endpoint and DNS are working, your own smoke tests will fail from outside the VNet. Run the tests from inside the network, or open access to your IP for a short time and close it again afterwards.
Step 4: Recreate content filters, then deployments
Deployments refer to content filters by name, so create the filters first. Strip the read-only fields and PUT each policy:
for name in $(jq -r '.value[] | select(.properties.type != "SystemManaged") | .name' old-raipolicies.json); do
jq --arg n "$name" '.value[] | select(.name==$n) | {properties: (.properties | del(.type))}' old-raipolicies.json > p.json
az rest --method put --body @p.json \
--url "https://management.azure.com/subscriptions/$SUB/resourceGroups/$NEW_RG/providers/Microsoft.CognitiveServices/accounts/$NEW/raiPolicies/$name?api-version=$API"
done
Recreate blocklists and their items the same way, before any policy that references them. Built-in policies such as Microsoft.DefaultV2 already exist and are skipped above.
Now the deployments, keeping the same names so apps only change the endpoint:
for name in $(jq -r '.value[].name' old-deployments.json); do
jq --arg n "$name" '.value[] | select(.name==$n) |
{sku: .sku,
properties: {model: .properties.model,
raiPolicyName: .properties.raiPolicyName,
versionUpgradeOption: .properties.versionUpgradeOption}}' old-deployments.json > d.json
az rest --method put --body @d.json \
--url "https://management.azure.com/subscriptions/$SUB/resourceGroups/$NEW_RG/providers/Microsoft.CognitiveServices/accounts/$NEW/deployments/$name?api-version=$API" \
|| echo "FAILED: $name"
done
az cognitiveservices account deployment list -g $NEW_RG -n $NEW \
--query "[].{name:name, state:properties.provisioningState, sku:sku.name, capacity:sku.capacity}" -o table
Deployments are created one at a time per resource. If a PUT fails with a conflict because another operation is running, wait and rerun it for that name.
| Error during recreate | Cause | Fix |
|---|---|---|
InsufficientQuota | Target region quota below the copied capacity | Lower sku.capacity or request quota |
| Model or version not supported | Version not offered in the target region or deployment type | Pick an offered version and re-evaluate |
raiPolicyName not found | Filter not created yet, or name differs | Create the policy first |
RequestDisallowedByPolicy | Azure Policy on the new subscription or RG | Read the policy assignment in the error; fix tags, region or SKU |
If you manage the resource with Bicep or Terraform, use this export to fill in the template, and deploy from code instead of the loop. Otherwise the next IaC run may reset what you just created.
Step 5: Smoke test and switch
TOKEN=$(az account get-access-token --resource https://cognitiveservices.azure.com --query accessToken -o tsv)
for name in $(jq -r '.value[].name' old-deployments.json); do
code=$(curl -s -o /dev/null -w '%{http_code}' \
"https://$NEW.openai.azure.com/openai/deployments/$name/chat/completions?api-version=2024-10-21" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Say OK"}],"max_tokens":5}')
echo "$name $code"
done
Embedding deployments need the /embeddings path instead; expect a 400 from the chat call for those.
Then switch traffic gradually:
- Behind APIM or another gateway: add the new resource as a backend with a low weight or as a lower-priority pool member. Watch 4xx and 5xx counts, latency and content filter rejections, then raise the weight.
- Direct from apps: change the endpoint setting one app at a time, starting with the least critical.
- Run your evaluation set against the new endpoint before moving the main chat traffic.
Rollback and clean-up
Rollback means pointing apps or gateway weights back to the old endpoint. Keep the old resource, its deployments and its role assignments until the new one has handled normal peak traffic for at least a week.
Caution
Deleting the old resource frees its quota, but the name stays reserved while the resource is soft-deleted. Purging it is permanent. Check gateway backends, app settings and metrics for any traffic still reaching the old endpoint before you delete it.
az monitor metrics list --resource $(az cognitiveservices account show -g $OLD_RG -n $OLD --query id -o tsv) \
--metric ProcessedPromptTokens --interval PT1H --aggregation Total -o table
The metric name above may differ in your build. Use az monitor metrics list-definitions to see the names available for your resource.
Prevent it next time
- Keep deployments, content filters and role assignments in IaC so a new resource is a parameter change, not a weekend of work.
- Put a gateway in front of Azure OpenAI so apps never hold a resource URL directly.
- Use Entra ID rather than keys; a new resource then needs role assignments, not secret rotation in every app.
- Export the deployment inventory on a schedule and diff it, so you always know what you'd have to rebuild.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get