Edit

Share via


Connect to Azure AI Search using roles

Azure AI Search supports role-based access control through Microsoft Entra ID. Role-based access is optional but recommended. The alternative is key-based authentication, which is the default.

If you assign multiple roles to a security principal, permissions are combined. Role assignments apply across all tools and client libraries. You can assign roles using any supported approach.

This article explains how to assign built-in roles for service administration, development, and read-only query and retrieval access. It also provides steps for creating custom roles and testing role assignments.

Tip

Prerequisites

Built-in roles

Roles are a collection of permissions that affect the control plane or data plane:

  • Control plane: Operations for service provisioning, configuration, and administration. Control plane operations include creating or deleting search services, listing API keys, and managing network and authentication settings. Available through the Azure Resource Manager REST APIs, Search Management REST APIs, and equivalent Azure SDK client libraries.

  • Data plane: Operations against the search service endpoint. Data plane operations fall into two categories: object management and content access. Available through the Search Service REST APIs and equivalent Azure SDK client libraries.

Role descriptions

The following built-in roles grant permissions to Azure AI Search. Control plane roles are always available, while data plane roles require role-based access to be enabled on your search service. You can combine built-in roles for broader access or create a custom role with the specific permissions you need.

Role Plane Description
Owner Control
  • Full control plane access, including the ability to assign roles and change authentication settings.
  • Subscription administrators have this role by default.
  • Can manage API keys.
  • Can't create search objects, load documents, query indexes, or retrieve from knowledge bases.
Contributor Control
  • Same level of control plane access as Owner, minus the ability to assign roles.
Reader Control
  • Read-only control plane access.
  • Can view service metrics and object definitions.
  • Can't view or manage API keys, load documents, query indexes, or retrieve from knowledge bases.
Search Service Contributor Control & Data
  • Full control plane access. Data plane access is limited to object management.
  • Can create indexes, indexers, skillsets, knowledge bases, and other search objects.
  • Can't load documents, query indexes, or retrieve from knowledge bases.
  • For the full permissions list, see Microsoft.Search/searchServices/*.
Search Index Data Contributor Data
  • Read-write content access.
  • Can load documents, query indexes, and retrieve from knowledge bases.
  • Can't modify object definitions or retrieve admin keys.
Search Index Data Reader Data
  • Read-only content access.
  • Can query indexes and retrieve from knowledge bases.
  • Can't load documents, modify object definitions, or retrieve admin keys.

Important

  • Owner, Contributor, and Search Service Contributor can retrieve admin keys, which provide full read-write access to the data plane. Only grant these roles to trusted users.
  • By default, data plane roles apply to all indexes on the search service. To scope Search Index Data Contributor or Search Index Data Reader to a single index, see Grant access to a single index.

Summary of permissions

Use the following table to quickly find which role provides the permissions you need.

Permissions Owner/Contributor Reader Search Service Contributor Search Index Data Contributor Search Index Data Reader
Create and configure Azure AI Search services
Access service in the Azure portal
View service properties, metrics, and endpoint
List all objects on the service
Access quotas and service statistics
View, copy, and regenerate keys
Set authentication options
View roles, policies, and definitions
Configure network security and private connections
Create, run, and manage search objects 1
Upload data for indexing 2
Query an index
Retrieve from a knowledge base
Bypass permission filters with elevated read

1 Includes indexes, indexers, data sources, skillsets, aliases, synonym maps, debug sessions, knowledge bases, and knowledge sources. Indexers also support run and reset operations.

2 An Owner or Contributor can run the Import data wizard to create and load indexes, even though they can't upload documents in other clients. Similarly, indexers can write to any index on the search service, regardless of per-index role assignments. In both cases, the search service (not the user) performs the data plane actions using its Microsoft.Search/searchServices/indexes/documents/* permissions.

Assign built-in roles

In this section, you assign roles for:

Assign roles for service administration

The following roles let you create, configure, and manage a search service. These roles are hierarchical, so select one based on the access level you need.

Role ID
Owner 8e3af657-a8ff-443c-a75c-2fe8c4bcb635
Contributor b24988ac-6180-42a0-ab88-20f7382dd24c
Reader acdd72a7-3385-48ef-bd42-f606fba81ae7
  1. Go to your search service in the Azure portal.

  2. From the left pane, select Access control (IAM).

  3. Select + Add > Add role assignment.

    Screenshot of the Access control (IAM) page for assigning service administration roles.

  4. Select a role: Owner, Contributor, or Reader.

  5. On the Members tab, select the Microsoft Entra user or group identity. If you're setting up permissions for another Azure service, select a system-assigned or user-assigned managed identity.

  6. On the Review + assign tab, select Review + assign to assign the role.

Assign roles for development

The following roles let you create search objects, load documents, query indexes, and retrieve from knowledge bases. Assign all three roles to cover the full range of development tasks.

Role ID
Search Service Contributor 7ca78c08-252a-4471-8644-bb5ff32d4ba0
Search Index Data Contributor 8ebe5a00-799e-43f5-93ac-243d3dce84a7
Search Index Data Reader 1407120a-92aa-4202-b7e9-c0e197c71c8f
  1. Go to your search service in the Azure portal.

  2. From the left pane, select Access control (IAM).

  3. Select + Add > Add role assignment.

    Screenshot of the Access control (IAM) page for assigning development roles.

  4. Select Search Service Contributor.

  5. On the Members tab, select the Microsoft Entra user or group identity. If you're setting up permissions for another Azure service, select a system-assigned or user-assigned managed identity.

  6. On the Review + assign tab, select Review + assign to assign the role.

  7. Repeat these steps to assign Search Index Data Contributor and Search Index Data Reader.

Assign roles for read-only access

Use the following role for apps and processes that only need read access to indexes and knowledge bases. Supported operations include search, lookup, autocomplete, and suggestions for indexes and retrieve for knowledge bases.

Role ID
Search Index Data Reader 1407120a-92aa-4202-b7e9-c0e197c71c8f
  1. Go to your search service in the Azure portal.

  2. From the left pane, select Access control (IAM).

  3. Select + Add > Add role assignment.

    Screenshot of the Access control (IAM) page for assigning read-only data access roles.

  4. Select the Search Index Data Reader role.

  5. On the Members tab, select the Microsoft Entra user or group identity. If you're setting up permissions for another Azure service, select a system-assigned or user-assigned managed identity.

  6. On the Review + assign tab, select Review + assign to assign the role.

Test role assignments

Use a client to test role assignments. Remember that roles are cumulative. You can't delete or deny inherited roles that are scoped to the subscription or resource group level at the resource (search service) level.

Before you proceed, configure your application for keyless connections and have role assignments in place.

  1. Go to your search service in the Azure portal.

  2. From the left pane, select Search management > Indexes to test index-related permissions:

    • Search Service Contributors can create, modify, and delete search objects but can't load documents or run queries. To verify permissions, create a search index.

    • Search Index Data Contributors can load documents. There's no load documents option in the Azure portal outside of the Import data wizard, but you can reset and run an indexer to confirm document load permissions.

    • Search Index Data Readers can query indexes. To verify permissions, use Search explorer. You should be able to send queries and view results, but you shouldn't be able to view index definitions or create indexes.

Grant access to a single index

In some scenarios, you might want to limit an application's access to a single resource, such as an index.

The Azure portal doesn't currently support role assignments at this level of granularity, but you can assign roles using PowerShell or the Azure CLI.

In PowerShell, use New-AzRoleAssignment, providing the Azure user or group name and the scope of the assignment.

  1. Load the Azure and AzureAD modules and connect to your Azure account:

    Import-Module -Name Az
    Import-Module -Name AzureAD
    Connect-AzAccount
    
  2. Add a role assignment scoped to an individual index:

    New-AzRoleAssignment -ObjectId <objectId> `
        -RoleDefinitionName "Search Index Data Contributor" `
        -Scope  "/subscriptions/<subscription>/resourceGroups/<resource-group>/providers/Microsoft.Search/searchServices/<search-service>/indexes/<index-name>"
    

    Reference: New-AzRoleAssignment

Per-index scope and indexer operations

Per-index role assignments apply to direct API operations only, such as queries or document uploads from users or applications. Indexers aren't restricted by per-index permissions because they operate with service-level credentials.

A user with the Search Service Contributor role can create indexers that write to any index on the search service, even indexes where that user has no per-index role assignment.

For strict data isolation between indexes, consider these approaches:

  • Use separate search services for teams or users who require index-level isolation.
  • Assign Search Service Contributor only to administrators who manage indexers.
  • Use document-level access control with security filters to restrict query results within a shared index.

Create a custom role

If built-in roles don't provide the right combination of permissions, you can create a custom role to support the operations you require.

The following examples clone Search Index Data Reader and then add the ability to list indexes by name. Normally, listing the indexes on a search service is considered an administrative right.

  1. Sign in to the Azure portal and navigate to your search service.

  2. From the left pane, select Access control (IAM).

  3. On the Roles tab, find Search Index Data Reader or another role, select the ellipsis (...), and then select Clone.

  4. On the Basics tab, enter a name for the custom role, such as "Search Index Data Explorer", and then select Next.

  5. On the Permissions tab, select Add permissions.

  6. In the Add permissions pane, select the Microsoft Search tile.

  7. With Actions selected at the top, set the following permissions:

    • Under Microsoft.Search/operations, select Read : List all available operations.
    • Under Microsoft.Search/searchServices/indexes, select Read : Read Index.
  8. Switch to Data Actions at the top, and under Microsoft.Search/searchServices/indexes/documents, select Read : Read Documents.

    The JSON definition looks like the following example:

    {
     "properties": {
         "roleName": "search index data explorer",
         "description": "",
         "assignableScopes": [
             "/subscriptions/0000000000000000000000000000000/resourceGroups/free-search-svc/providers/Microsoft.Search/searchServices/demo-search-svc"
         ],
         "permissions": [
             {
                 "actions": [
                     "Microsoft.Search/operations/read",
                     "Microsoft.Search/searchServices/indexes/read"
                 ],
                 "notActions": [],
                 "dataActions": [
                     "Microsoft.Search/searchServices/indexes/documents/read"
                 ],
                 "notDataActions": []
             }
         ]
       }
     }
    
  9. Select Add to close the pane.

  10. Select Review + create to create the role.

    You can now assign users and groups to the role. For more information about these steps, see Create or update Azure custom roles using the Azure portal.

Create a Conditional Access policy

If you need to enforce organizational policies, such as multifactor authentication, use Microsoft Entra Conditional Access.

To create a Conditional Access policy for Azure AI Search:

  1. Sign in to the Azure portal.

  2. Search for Microsoft Entra Conditional Access.

  3. On the Overview page, select Create new policy.

  4. Under Cloud apps or actions, add Azure AI Search as a cloud app, depending on how you want to set up your policy.

  5. Update the remaining parameters of your policy. For example, specify which users and groups to which the policy applies.

  6. Save the policy.

Important

If your search service has a managed identity assigned to it, the specific search service appears as a cloud app. However, selecting that specific search service doesn't enforce the policy. Instead, select the general Azure AI Search cloud app to apply Conditional Access policies to your search service.

Troubleshooting

When you develop applications that use role-based access control for authentication, you might encounter some common problems:

  • The default configuration for a search service is key-based authentication. If you don't change this setting to Both or Role-based access control, all requests that use role-based authentication are automatically denied, regardless of the underlying permissions.

  • If your request includes an API key alongside role-based credentials, the service authenticates using the key. Remove the API key from your request headers to use role-based authentication.

  • If the authorization token comes from a managed identity and you recently assigned the appropriate permissions, it might take several hours for the permissions assignments to take effect.

  • If queries with document-level permissions don't return expected results, use Search Index Data Contributor or create a custom role with elevated permissions to investigate.

Next step

This article explains how to assign roles for control and data plane operations on Azure AI Search. For comprehensive instructions on adding role-based access to your application code: