Blue-green migration for Azure AI Search: aliases, routing, shadow traffic and rollback
Part 4 of 7 in the Embedding Migration in Production series (change the model, not the reliability): engineer-level, on Azure AI Search and Microsoft Foundry, mapped to Microsoft exam AI-103.
TL;DR for managers. Blue-green means running the old index (blue) and the new one (green) side by side, testing green with real but invisible traffic, moving users over gradually, and keeping blue ready to take traffic back. In Azure AI Search, an index alias can switch the index name in one step, but it can't split traffic and it doesn't switch the query model with it. So the application needs a small, versioned release configuration that always pairs an index with its matching query model.
By the end of part 3 the new index,
rag-content-v2, holds a vector for every chunk, made with the new model, and the change stream has caught
up. Production is still answering from rag-content-v1. This part is about moving users across without an
outage, without a mismatched request, and with a way back.
Blue and green, on Azure AI Search
The pattern is simple to describe:
-
Blue:
rag-content-v1with ada-002 vectors, and the ada-002 deployment for questions. -
Green:
rag-content-v2with text-embedding-3-large vectors, and its deployment. -
Application-facing name: an alias such as
rag-content-active, or a routing setting in the application.
Both indexes must sit on the same Azure AI Search service if you want to use an alias, because an alias can't redirect requests to another service. If capacity (part 2) forces the new index onto a different service, routing moves into the application anyway.
What an alias does, and what it doesn't
Index aliases are generally available in REST API version 2026-10-01 and the current SDKs. An alias is a second name
for one index: queries and document operations sent to rag-content-active go to whichever index it maps
to, and you can repoint it without changing application code. Microsoft's migration guide is precise about the limits:
| An alias can | An alias can't |
|---|---|
| Map one name to one index on the same service | Split traffic between two indexes (no canary, no shadow) |
| Be repointed with one update | Change the query embedding model, the vector field or caches with it |
| Serve queries and document operations | Be the target of an indexer or a Foundry IQ knowledge source |
| Take effect within about 10 seconds | Switch atomically with anything else |
That last row is the important one. If the application embeds questions itself, there is a window of up to 10 seconds where a new-model vector can reach the old index, or an old-model vector the new one. The guide's answer is to pause model-specific queries and writers, drain in-flight requests, update the alias, wait at least 10 seconds, switch the query side, validate through the alias, then resume. If you can't pause, it says to "use application routing that pins each query or push write to a physical index and its matching versioned embedding configuration".
A release manifest that pairs index and model
The fix for every pairing problem is to make the pair the unit of deployment. A release is a small, versioned piece of configuration:
{
"release": "r2-emb3large",
"index": "rag-content-v2",
"vector_field": "content_vector_v2",
"query_deployment": "emb-3large",
"query_contract": "9f2c41d07ab3",
"dimensions": 3072,
"semantic_configuration": "default",
"previous_release": "r1-ada002",
"canary_percent": 0
}
The application reads the release, not separate settings for "index" and "model", so the two can't drift apart.
query_contract is the embedding contract version from part 2, and the embedding cache uses it in its keys.
Rollback means pointing at previous_release, which restores the old index and the old query model
together.
Sticky routing for canaries
With routing in the application, a canary is a percentage. The router below hashes the user ID, so the same person always gets the same release. Within one request the index, vector field and query deployment all come from the same release, and retries reuse it.
import hashlib
RELEASES = load_releases() # {"r1-ada002": {...}, "r2-emb3large": {...}} from config, versioned
ACTIVE, CANDIDATE = "r1-ada002", "r2-emb3large"
def pick_release(user_id: str, canary_percent: int) -> dict:
"""Sticky: the same user always lands in the same bucket, so a conversation never mixes releases."""
bucket = int(hashlib.sha256(user_id.encode()).hexdigest(), 16) % 100
return RELEASES[CANDIDATE if bucket < canary_percent else ACTIVE]
def search(question: str, user, canary_percent: int):
release = pick_release(user.id, canary_percent)
vector = embed(question, deployment=release["query_deployment"], # query model and index chosen
dimensions=release["dimensions"]) # together, from ONE manifest
client = search_client(release["index"])
return client.search(
search_text=question,
vector_queries=[VectorizedQuery(vector=vector, k_nearest_neighbors=50,
fields=release["vector_field"])],
query_type="semantic", semantic_configuration_name=release["semantic_configuration"],
filter=security_filter(user), # same permission model on both
top=10), release["release"] # log which release answered
The percentages you step through (for example 1%, 5%, 25%, 100%) are a business decision, not a rule. Each step should need an explicit approval based on the measures in parts 5 and 7, and the router should log which release answered every request.
Shadow queries before any user sees green
Before the canary, run green in the shadow. The user is served by blue as normal. Afterwards, a background task sends the same question to green, with the same user's permissions, and records how the result compares.
async def shadow(question: str, user, served_ids: list[str], served_ms: float):
"""Runs after the user already has their answer from the active release. Never shown to anyone."""
started = time.perf_counter()
results, _ = search(question, user, canary_percent=100) # candidate, SAME user permissions
ids = [r["chunk_id"] for r in results]
leaked = [i for i in ids if not source_acl_allows(user, i)] # check against the source system's ACLs
record_shadow({ # IDs, ranks and timings only: no text
"overlap_at_10": len(set(ids) & set(served_ids)) / 10,
"candidate_ms": (time.perf_counter() - started) * 1000,
"served_ms": served_ms,
"leaks": len(leaked), # must stay at zero; alert on the first
})
Three rules keep shadow traffic safe:
- Same identity, same filters. A shadow query run with a service identity that can see everything would hide permission problems and could expose data in logs.
- Record IDs, not content. Overlap, ranks, latency and errors are enough. Query text can contain personal data, so minimise and protect what you keep.
- Check every result against the source's permissions. One shadow result that the user couldn't open in the source system blocks the release, however good the relevance looks.
Low overlap with blue isn't automatically bad: the new model is supposed to find different, hopefully better, chunks. Overlap tells you where to look; the judged evaluation in part 5 tells you which index is right.
The cutover
With an alias and application-generated query vectors, following Microsoft's sequence:
- Reach the agreed sync point: new index reconciled, deletes and permission changes applied.
- Pause model-specific queries and push writers; drain in-flight requests and queued retries.
- Repoint the alias and wait at least 10 seconds:
# Cutover through an alias (same service only). Run with writers paused and in-flight requests drained.
from azure.search.documents.indexes.models import SearchAlias
index_client.create_or_update_alias(SearchAlias(name="rag-content-active", indexes=["rag-content-v2"]))
time.sleep(10) # an alias update can take up to 10 seconds to propagate
# now switch the client-side query model to r2, validate through the alias, then resume traffic
- Switch the query embedding configuration, vector field and caches to the new release.
- Validate through the alias: a known query, a new document, an update, a delete and a permission change.
- Resume traffic. If validation fails, stay paused and roll back with the same sequence.
With application routing, the cutover is setting the canary to 100%, and no pause is needed because every request already carries its own pairing. That is why I'd use routing for any system where even a short pause matters, and keep the alias as the stable name underneath.
A rollback you've actually tested
A rollback plan that has never run is a hope. Rehearse it on the new index before cutover, and keep these true for the whole rollback window:
- The old index stays current. Writes accepted after cutover must also reach blue (dual-write) or be replayable, because rolling back an alias "doesn't copy those writes to the old index".
- The old model stays available. If the old model retires during the window, the old index can no longer answer questions and the rollback is gone. With a retirement deadline, finish the window before it.
- Nothing gets deleted. Old index, old deployment, old caches and old pipeline stay until the window closes and the release is accepted (part 7).
If you chose the second-field approach
With old and new vectors in one index, there's no alias to move: the switch is the fields value in the
vector query, plus the matching query model. The same release manifest handles it, with the index name unchanged and
vector_field changing. Keep both fields populated through the rollback window, remember the
stored: false partial-update risk from part 2, and note that the old field stays in the schema until you
rebuild the index.
Common mistakes
- Calling an alias swap "zero downtime" while the query model switches separately.
- Pointing an indexer or a knowledge source at the alias. They need the physical index name.
- Running shadow queries with an all-seeing identity.
- Letting writes go only to green after cutover, then discovering rollback would lose them.
Key takeaways
- Deploy the index and the query model as one versioned release.
- Use an alias for a stable name; use application routing for shadow, canary and pause-free cutover.
- Shadow and canary traffic run with real user permissions and log IDs, not content.
- Rehearse rollback, keep the old side current and the old model available until the window closes.
Next, part 5: did the new model actually improve retrieval? Golden sets, Recall@K, MRR, NDCG and a fair, paired comparison.
References
- Switch traffic and retain a rollback path
- Create an index alias in Foundry IQ (Azure AI Search)
- Update or rebuild an index
- Document-level access control
Learning this for AI-103? Microsoft's AI-103 exam (Azure AI Apps and Agents Developer Associate) covers implementing RAG with Azure AI Search, vector and hybrid search, and monitoring retrieval quality. Our live online AI-103 course builds these pipelines hands-on in Microsoft Foundry and Azure AI Search, on UK time, with mock assessments before you book the exam.
The Embedding Migration in Production series
Change the model, not the reliability.
- Part 1: Your embedding model is being retired
- Part 2: Why you can't simply swap embedding models
- Part 3: Re-embedding 10 million documents
- Part 4: Blue-green migration for Azure AI Search (you are here)
- Part 5: Did the new model improve retrieval?
- Part 6: BM25, hybrid and semantic ranking
- Part 7: The enterprise migration playbook
- Bonus: Document permissions in a migration