AI and Machine Learning Azure AI Search verified

Query key

A query key is a safer API key for applications that only need to search an Azure AI Search index. It lets a website, app, or service send query requests without handing out an admin key. That distinction is important: an admin key can manage the search service, while a query key is meant for read-style search access. Query keys are still secrets, so they need secure storage, rotation planning, and careful distribution to trusted application components.

Aliases
No aliases mapped yet
Difficulty
fundamentals
CLI mappings
5
Last verified
2026-05-20

Microsoft Learn

A query key is an Azure AI Search API key intended for client applications that issue search queries against indexes. It grants query access without administrative permissions to create, change, or delete indexes, data sources, indexers, or other service objects.

Microsoft Learn: Connect to Azure AI Search using API keys2026-05-20

Technical context

In Azure architecture, a query key belongs to the Azure AI Search data-plane authentication model. It is used by client applications, backend APIs, or search connectors when they call search endpoints. It sits alongside admin keys and Microsoft Entra ID role-based access, with RBAC preferred where supported for stronger identity control. Query keys interact with indexes, semantic search, private endpoints, application secrets, Key Vault, API Management, web apps, and diagnostic logs. They are not the right credential for index management or indexer administration.

Why it matters

Query keys matter because search applications often need broad user access to search results but should not receive authority to redesign the search service. Giving a frontend or middle-tier app an admin key creates unnecessary blast radius: the same secret could delete indexes, reveal definitions, or change data sources. A query key reduces that risk by limiting what the credential can do. It also supports cleaner operational ownership because application teams can consume search without controlling service administration. The limitation does not remove the need for network controls, data filtering, index-level design, or secret handling. That makes it a practical least-privilege control for search-backed applications.

Where you see it

Signals, screens, and Azure surfaces where this term usually becomes operational.

Signal 01

Azure AI Search Keys blades show admin keys and query keys, including named query keys created for individual applications or integration paths needing search access.

Signal 02

Azure CLI query-key output lists key names and values, helping operators map consuming apps to their search credentials during rotation, review, incident response, or audits.

Signal 03

Application settings, Key Vault secrets, or API Management named values often store query keys used by backend search components and APIs handling user requests securely.

When this becomes relevant

Specific situations where this term helps solve real Azure design, operations, migration, security, reliability, cost, or governance problems.

  • Give a backend web application search-only access without exposing Azure AI Search admin keys.
  • Create separate query keys for different apps so leaked or retired credentials can be revoked independently.
  • Support legacy clients that cannot yet use Microsoft Entra ID authentication for Search data-plane calls.
  • Rotate a compromised search credential by deleting and recreating the affected query key.
  • Audit whether application teams are still using key authentication before migrating to role-based access.

Real-world case studies

Different enterprise-style examples that show the term being used to hit measurable objectives.

Case study 01

Travel booking site removes admin keys from search traffic

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A travel booking platform used Azure AI Search for destination, hotel, and policy lookups. A legacy backend searched with an admin key stored in an app setting.

Business/Technical Objectives
  • Replace admin-key query traffic with search-only credentials.
  • Reduce blast radius if an application secret leaked.
  • Create separate credentials for web, partner, and support applications.
  • Keep search latency stable during the credential change.
Solution Using Query key

Engineers created named query keys for each consuming backend and stored them in Key Vault. The web API, partner API, and support portal were updated to retrieve their assigned key at deployment time. The old admin key remained only in the secured indexing pipeline, not in query-serving applications. Azure CLI listed query keys and exported service metadata for the change record without storing key values in shared logs. After each deployment, operators ran test queries and watched Azure Monitor for authentication failures, latency changes, and unusual query volume.

Results & Business Impact
  • Admin-key use in query-serving apps dropped to zero across three production services.
  • Credential blast radius was reduced because each application had an independently revocable query key.
  • P95 search latency changed by less than two percent after the backend secret update.
  • Security review evidence that once took a day was generated in under one hour.
Key Takeaway for Glossary Readers

Query keys let application teams consume Azure AI Search without handing normal query paths the authority to administer the search service.

Case study 02

Legal knowledge portal rotates exposed search credential without outage

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A legal services firm discovered a query key for its internal case-law portal in an archived deployment log. The key could not manage the service, but it could retrieve indexed legal summaries.

Business/Technical Objectives
  • Revoke the exposed query key without breaking attorney search workflows.
  • Update the backend secret store and deployment pipeline safely.
  • Confirm no admin key was exposed in the same log archive.
  • Improve future rotation evidence and owner tracking.
Solution Using Query key

The operations team created a replacement query key with a clear application name and stored it in Key Vault. The portal backend was redeployed to use the new secret reference, then smoke tests confirmed searches worked from office and private network paths. Only after successful tests did operators delete the exposed query key with Azure CLI. They also listed admin-key status, reviewed app settings, and added a log-scrubbing rule to prevent secret values from appearing in deployment output. The incident record included key owner, rotation timestamps, and post-change authentication metrics.

Results & Business Impact
  • The exposed key was revoked within ninety minutes with no reported search outage.
  • Search authentication failures stayed below the normal daily baseline after rotation.
  • The firm identified and removed two other stale query keys during the review.
  • Deployment logs stopped capturing secret values after the pipeline masking rule was updated.
Key Takeaway for Glossary Readers

A query key limits damage compared with an admin key, but it still needs disciplined secret handling and a practiced rotation path.

Case study 03

Museum archive separates public search from curator workflows

Scenario, objectives, solution, measured impact, and takeaway.

Scenario

A digital museum archive exposed public search over artifacts while curators maintained indexes and enrichment jobs. The first design reused one credential across both public and administrative workflows.

Business/Technical Objectives
  • Give public search services only query-level access to Azure AI Search.
  • Keep curator indexing operations behind separate administrative credentials and roles.
  • Track public search traffic independently from internal research tools.
  • Prepare for a later move toward Microsoft Entra ID data-plane roles.
Solution Using Query key

The architecture team issued a dedicated query key to the public search backend and separate query keys to internal research tools. Indexing jobs retained tightly controlled administrative access through a different secret path. The public key was stored behind API Management and never delivered to browser clients. Operators used CLI to list query keys, document owners, and verify that no stale shared keys remained. Diagnostic logs and application telemetry tagged request source so public traffic spikes could be separated from curator research behavior.

Results & Business Impact
  • Public search launched without exposing index-management credentials to internet-facing components.
  • Traffic attribution improved because query keys were mapped to specific application paths.
  • Curator indexing incidents no longer required rotating the public search credential.
  • The team created a phased plan to replace key auth with Entra ID for internal tools.
Key Takeaway for Glossary Readers

Query keys are most useful when each consuming application has search-only access and administrative operations stay on a separate, better-protected path.

Why use Azure CLI for this?

As an Azure engineer with ten years of search and secret-rotation work, I use Azure CLI for query keys because key handling must be fast, scripted, and auditable. The portal is fine for learning, but it is risky during an incident when a leaked key needs deletion and dependent applications need updates. CLI can list query keys, create named keys, delete exposed keys, and export service metadata for owners. It also helps compare key-based access with private endpoint and RBAC posture. I still avoid printing key values casually and prefer secure outputs and Key Vault handoff. Automation keeps the rotation sequence consistent when several apps depend on Search.

CLI use cases

  • List query keys for a search service and map each named key to an application owner.
  • Create a new query key before updating a backend app setting or Key Vault secret.
  • Delete an exposed query key after confirming dependent clients moved to the replacement credential.
  • Show search service network, SKU, replica, and authentication settings during access troubleshooting.
  • Export key inventory evidence for a security review without exposing values in shared logs.

Before you run CLI

  • Confirm tenant, subscription, resource group, search service name, application owner, and whether key-based auth is allowed.
  • Use a secure terminal and avoid table output when command results include secret values.
  • Check whether the workload should use Microsoft Entra ID roles instead of long-lived query keys.
  • Plan rotation carefully because deleting a query key immediately breaks clients still using that value.
  • Verify private endpoint, firewall, API Management, and app setting dependencies before blaming the key.

What output tells you

  • Query key names help identify which application or integration should own a particular search credential.
  • Key values are bearer secrets and should be copied only into approved secret stores or deployment variables.
  • Search service SKU, replica, partition, and location fields provide context for capacity and traffic troubleshooting.
  • Network and authentication settings show whether key-based clients can reach the service endpoint at all.
  • Creation, deletion, and service IDs support audit trails for credential rotation and incident response.

Mapped Azure CLI commands

Query key commands

direct
az search query-key list --service-name <search-service> --resource-group <resource-group>
az search query-keydiscoverAI and Machine Learning
az search query-key create --service-name <search-service> --resource-group <resource-group> --name <key-name>
az search query-keysecureAI and Machine Learning
az search query-key delete --service-name <search-service> --resource-group <resource-group> --key-value <query-key-value>
az search query-keyremoveAI and Machine Learning
az search service show --name <search-service> --resource-group <resource-group>
az search servicediscoverAI and Machine Learning
az search admin-key show --service-name <search-service> --resource-group <resource-group>
az search admin-keydiscoverAI and Machine Learning

Architecture context

As an Azure architect, I treat query keys as an interim or constrained access pattern, not as a substitute for identity-first design. For internal applications, I prefer Microsoft Entra ID and Azure AI Search data-plane roles when the client platform supports them. When a query key is used, I keep it in Key Vault or a secure app setting, expose it only to a trusted backend, and avoid putting it in browser JavaScript. I also design indexes so a query key cannot return data the caller should never see. Network controls, private endpoints, and API gateways complete the boundary. Every key should map to an owner and rotation process.

Security

Security impact is direct. A query key is less powerful than an admin key, but it is still a bearer secret that can query indexed data. If exposed, an attacker may retrieve documents, test sensitive search terms, or scrape results until the key is deleted. Query keys should be stored in Key Vault or managed application settings, never committed to code or shipped to untrusted clients. Teams should consider Entra ID authentication, private endpoints, per-application keys, API Management, and authorization filters. Rotation means deleting and recreating query keys, so applications need a controlled cutover path. Logs should be reviewed for suspicious query patterns after any exposure.

Cost

A query key has no direct SKU charge, but it influences consumption and operational cost. A leaked key can drive unexpected query volume, increase search unit pressure, and force urgent incident response. Poorly scoped keys may encourage one shared application path, making rotations disruptive and expensive. Query keys also affect FinOps attribution because search traffic may be hard to tie to individual apps unless keys and logging are separated by owner. Cost-aware teams monitor query volume, throttling, replica pressure, and application ownership. They retire unused keys so stale integrations do not quietly consume search capacity. Leaked keys can also mask abusive traffic behind legitimate application names.

Reliability

Reliability impact is indirect but important for application continuity. If a query key is deleted without updating dependent apps, search experiences fail immediately. If every app shares one key, a rotation or leak response can break multiple services at once. Reliable designs issue distinct query keys per application where practical, document dependencies, and test fallback credentials during maintenance. Monitoring should alert on search request failures, authentication errors, and unusual query volume. Private endpoint or firewall changes can look like key failures, so operators should verify both credential validity and network reachability during incidents. Named keys make that blast radius easier to understand during incidents.

Performance

Performance impact is indirect. A query key does not change ranking, latency, or index throughput, but how it is distributed can affect traffic patterns. If multiple applications share one key, operators may struggle to identify which client is causing high query volume or throttling. Backend mediation can add latency, but it allows caching, authorization checks, query shaping, and better logging before requests reach Search. Performance troubleshooting should connect key ownership with request counts, latency, failed queries, and replica utilization. If a search app slows down, validate credential errors separately from query design, index size, semantic ranking, and capacity. That attribution is essential before adding replicas or partitions.

Operations

Operators manage query keys through inventory, secret storage, rotation, incident response, and dependency mapping. They list keys, create named keys for consuming applications, delete exposed keys, and update Key Vault references or app settings. Azure CLI is useful because it exposes query keys without navigating portal blades and can automate evidence collection. Runbooks should record which application owns each key, where the value is stored, how rotation is coordinated, and what logs confirm successful cutover. Operators should also compare key-based use with Entra ID role-based access during modernization reviews. Stale keys should be deleted after owners confirm they no longer receive traffic.

Common mistakes

  • Putting a query key directly in browser JavaScript, mobile apps, Git repositories, or shared screenshots.
  • Using an admin key for normal search queries because it was easier to copy from the portal.
  • Sharing one query key across every application, making rotation noisy and incident response risky.
  • Deleting a key before confirming all dependent app settings, Key Vault secrets, and deployments were updated.
  • Assuming query keys enforce document-level authorization without filters, security trimming, or backend checks.