Azure AI Search
Azure AI Search provides a local model of the Microsoft.Search management plane and a data plane for index and document work. It lets clients create services, manage keys, define indexes, store documents, and read service statistics while keeping the related state in the emulator.
Service Management
The search service is the main ARM resource. The ARM surface supports create, read, update, delete, and list actions for services in a resource group or subscription. It also exposes name checks and the key actions that clients need after a service is created.
The service is ready in the response to its create request. A new service reports provisioningState: succeeded and status: running, so clients do not need a long provisioning cycle before they can read it. A create returns 201; a later full update returns 200.
The main lifecycle is:
flowchart LR
A[Create service] --> B[Ready local resource]
B --> C[Read or list service]
B --> D[Update service]
B --> E[Manage keys]
B --> F[Use indexes and documents]
F --> G[Read statistics]
B --> H[Delete service]
H --> I[Resource and search data removed]
ARM Resource Operations
The ARM resource uses the Microsoft.Search/searchServices type. A full update replaces the sent service settings but keeps identity that belongs to the service, such as its creation time and keys. A patch changes only the fields it sends and keeps the rest of the local state.
Listing follows ARM scope. A resource-group list returns services in that group, while a subscription list returns all services in the subscription. The generic resource index also exposes each service under its canonical location.
References: src/…/SearchArmService.java• L160-213 src/…/SearchArmService.java• L218-317 src/…/SearchArmService.java• L319-325 src/…/SearchArmService.java• L421-426
Lifecycle Rules
Some service choices are fixed after creation. The service cannot move to another location, and its hosting mode cannot change. Updates are checked against the service state that would remain after the request, so an update cannot leave a service above its SKU capacity.
Deletion removes the service from ARM reads, lists, the resource index, and name ownership. It also removes the service's indexes and documents. A delete of an existing service returns 200; a repeat delete returns 204. A read or key action for a missing service returns 404.
References: src/…/SearchArmService.java• L239-260 src/…/SearchArmService.java• L274-317 src/…/SearchArmService.java• L476-509 src/…/SearchArmService.java• L658-691
Service Naming
Search service names are global DNS labels. The name becomes the host label in the service endpoint, so the same name cannot belong to two services even when they use different subscriptions or resource groups.
Name Rules
The name rule accepts 2 to 60 lowercase letters, digits, and single hyphens. The name starts with two letters or digits, does not end with a hyphen, and does not contain adjacent hyphens. When strict name checks apply, a name outside this rule is rejected with InvalidResourceName.
References: src/…/SearchArmService.java• L512-539 src/…/SearchArmService.java• L694-707
Name Availability
checkNameAvailability separates a malformed name from a name already owned by another service. A valid unused name is available. A valid name held anywhere in the local service state returns AlreadyExists, and the name becomes available after its owner is deleted.
References: src/…/SearchArmService.java• L327-348 src/…/SearchArmService.java• L429-449 src/…/SearchHandler.java• L100-110
Request Routing
The handler joins the ARM and data-plane surfaces under the Azure Search service identity. It claims a cloud search host such as {service}.search.windows.net and the emulator's -search account form, then sends provider paths to ARM and all other search paths to the data plane.
The request split is:
flowchart TD
A[Search request] --> B{Microsoft.Search provider path?}
B -->|Yes| C[ARM service and key operations]
B -->|No| D[Search data plane]
D --> E[Index, document, or statistics operation]
D --> F[Unsupported operation: 404]
ARM and Data Plane Boundaries
The ARM surface manages service resources and keys. The data plane uses the service name from the host or path and requires an api-version query parameter before it processes an index, document, or statistics request.
The handler also supports the emulator's path form for local calls. Response links use the service URL that the caller used, so host-based and path-based requests keep their own address form.
References: src/…/SearchHandler.java• L23-35 src/…/SearchHandler.java• L69-86 src/…/SearchDataPlane.java• L92-114 src/…/SearchDataPlane.java• L260-265
Index Operations
Indexes describe the fields and search features that documents must follow. The data plane supports index create, list, get, replace, delete, and per-index statistics through the indexes collection.
Index names use lowercase letters, digits, dashes, and underscores. Each index needs exactly one top-level string key field. Field definitions are checked against their types and roles, including complex and vector fields, and the response fills the service defaults.
Updates preserve the indexing choices of existing fields. They can add fields but cannot remove an existing field or change its indexing behavior. New analysis components and similarity changes need allowIndexDowntime=true, because the index may be unavailable during that change.
Index writes use ETags and support If-Match and If-None-Match. Deleting an index also deletes its documents, so a new index with the same name starts empty.
References: src/…/SearchIndexes.java• L38-59 src/…/SearchIndexes.java• L176-211 src/…/SearchIndexes.java• L220-319 src/…/SearchIndexes.java• L353-369 src/…/SearchIndexes.java• L760-817
Document Operations
Documents are records stored under an index. The data plane supports batch indexing with upload, merge, mergeOrUpload, and delete, plus document lookup and document count.
When the service processes an indexing batch, it validates the whole request before it writes. An invalid field, value, action, vector length, or key rejects the batch without partial writes. A missing document on merge is the per-action exception and appears as a failed result in a 207 response. A delete of a missing key succeeds.
Document keys are case-sensitive. Lookups can use either keyed OData paths or simple path segments, and $select limits the response to retrievable fields. Complex fields merge by sub-field, while a collection is replaced as a whole.
References: src/…/SearchDocuments.java• L37-57 src/…/SearchDocuments.java• L158-203 src/…/SearchDocuments.java• L208-314 src/…/SearchDocuments.java• L351-410 src/…/SearchDocuments.java• L625-735
Service Statistics
Service statistics connect local index and document state to the service's reported capacity. servicestats returns document count, index count, storage use, vector index use, and counters for features that are not served.
Per-index statistics return document count, storage size, and vector index size. The size values describe the local representation, so they are useful for emulator state and request behavior rather than as a physical Azure capacity measure. Quotas vary with the service SKU, partition count, and high-density hosting mode.
The counters included in a response depend on the requested API version. Newer versions can add alias and knowledge counters without changing the core counts.
References: src/…/SearchDataPlane.java• L146-207 src/…/SearchDataPlane.java• L218-250 src/…/SearchIndexes.java• L322-337
Data-Plane Authentication
Data-plane authentication controls access to index management and document operations. The default emulator mode permits requests without checking a service declaration or credential, while strict search-key mode applies the service's stored authentication settings.
Credential Modes
In strict mode, management requests require a primary or secondary admin key, or a Microsoft Entra bearer token when the service accepts Entra authentication. Document reads also accept a query key. Document writes and index management do not accept query keys.
The service accepts bearer tokens when authOptions.aadOrApiKey is present or when disableLocalAuth is true. The emulator checks whether the request has a bearer credential but does not validate the token itself. With local authentication disabled, API keys are refused. A missing credential returns 401 with a challenge; an unusable bearer token returns 401; and a wrong API key returns 403.
An undeclared service is available in permissive mode. Strict mode requires the service to exist before it grants data-plane access.
References: src/…/SearchAuth.java• L17-31 src/…/SearchAuth.java• L50-95 src/…/SearchAuth.java• L101-125 src/…/SearchErrors.java• L82-95
Local Resource State
The emulator stores each search service as local ARM state and keeps its indexes and documents as related data-plane state. These views share service names and lifecycles, so service deletion and reset remove the search data that belongs to them.
Service Properties
The resource response gives clients a provisioned view of the service. It includes the endpoint, current scale, network and authentication settings, SKU, tags, identity, and service status. Defaults fill fields that a request does not set, while a patch keeps stored values that it does not change.
The local model also applies the main capacity rules. SKU choice limits replicas and partitions, valid partition sizes are constrained, and the product of replicas and partitions cannot exceed 36 search units. High-density hosting is limited to the supported SKU and partition range.
References: src/…/SearchArmService.java• L658-691 src/…/SearchArmService.java• L712-755
Managed Identity State
A service can have no identity, a system-assigned identity, a user-assigned identity, or both kinds. A system-assigned principal stays stable across updates. A user-assigned identity reads its principal and client identifiers from the managed identity state rather than from caller-supplied values.
References: src/…/SearchArmService.java• L781-835
Index and Document State
Index definitions and documents belong to the cloud and service name that the data-plane request addresses. Index deletion removes its documents, and service deletion removes every index and document for that service. Statistics read these same local records, so counts change as the data plane changes.
References: src/…/SearchIndexes.java• L342-369 src/…/SearchDocuments.java• L318-347 src/…/SearchArmService.java• L305-316
Reset and Resource Index
The handler exposes service state to the shared resource index and global name registry. A reset clears all stored search services, indexes, and documents, which also removes the related indexed entries and name claims when those shared views rebuild.
References: src/…/SearchHandler.java• L88-117 src/…/SearchArmService.java• L419-454 src/…/SearchIndexes.java• L353-380
Key Management
Keys are separate child actions of a search service. A new service has two admin keys and one unnamed query key. Admin key regeneration replaces only the selected key, while query key creation adds a named key and query key deletion is safe to repeat for a key that is already absent. These keys are used by the strict data-plane authentication rules.
References: src/…/SearchArmService.java• L351-417 src/…/SearchAuth.java• L80-95
Related Services
Azure AI Search fits into the wider Azure platform surface through shared ARM scope, resource indexing, naming, policy, and authorization behavior. For the platform view, see Azure platform services. Related service and control-plane pages include Azure IoT Hub, Azure SignalR Service, Azure Policy Service, Azure Policy Insights, Azure Resource Graph, and Azure Authorization RBAC.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the ARM service delete and reset paths aligned with index and document cleanup.
- Keep the service name, host suffix,
-searchaccount form, and data-plane service lookup aligned. - Keep
disableLocalAuthandauthOptions.aadOrApiKeyaligned with the credential rules for management and document reads. - Keep index field validation aligned with document value conversion and vector usage counters.
- Keep ETag conditions and immutable-field rules aligned with index update behavior.
- Keep API-version additions in statistics and OData links aligned with the data-plane response shape.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Reuse a service name in another scope | The create request returns 409 Conflict. | Check global ownership before accepting the service. |
| Move an existing service to another location | The update returns 400 InvalidResourceLocation. | Treat location as fixed after creation. |
| Request a scale beyond the SKU or 36 search units | The write returns 400 InvalidRequestContent and keeps old state. | Validate the resulting service state before storing it. |
Send disableLocalAuth: true with authOptions | The write returns 400 InvalidRequestContent. | Do not combine those fields in one request. |
Omit api-version from a data-plane request | The request returns 400 MissingRequiredParameter. | Include the API version on every data-plane call. |
| Use a query key for index management or document writes in strict mode | The request returns 403. | Use an admin key for management and writes. |
| Send an invalid indexing batch | The whole batch returns 400 and no batch data is written. | Validate fields, actions, keys, and vector lengths before the write. |
| Delete an index or service | Its documents are removed and cannot be read after deletion. | Treat deletion as a data operation, not only a metadata operation. |
| Call an unsupported query, synonym-map, or indexer operation | The data-plane request returns 404. | Use only the data-plane operations currently served. |
Key files
| File | Why to read it |
|---|---|
| src/…/SearchHandler.java | Shows the ARM/data-plane split, host routes, resource index, name claims, and reset boundary. |
| src/…/SearchArmService.java | Describes service lifecycle, request behavior, capacity checks, keys, identities, and local ARM state. |
| src/…/SearchDataPlane.java | Shows data-plane routing, authentication placement, statistics, and service URL behavior. |
| src/…/SearchAuth.java | Defines strict-mode credential rules for management and document reads. |
| src/…/SearchIndexes.java | Describes index lifecycle, field rules, ETags, update limits, and cascade deletion. |
| src/…/SearchDocuments.java | Describes batch indexing, document reads, key rules, and local usage counts. |
| src/…/SearchErrors.java | Defines the common data-plane response and error shapes. |
| src/…/SearchArmSurface.java | Defines the Microsoft.Search resource type, location rule, service name rule, and global DNS name. |
| src/…/SearchModels.java | Defines the public service shape and the separate query-key state. |