---
title: "Walkthrough: Configure Azure Cognitive Search"
slug: "walkthrough--configure-azure-cognitive-search"
abstract: "Configure your Azure Search instance with this developer guide."
---
# Walkthrough: Configure Azure Cognitive Search

### Caution

Azure Cognitive Search will be discontinued in the future and Sitecore will no longer provide support for this service in future releases.

To use Azure Search with Sitecore you must first configure your Azure Search service with your Sitecore instance. 

<details>
<summary><h2>Create a Search service</h2></summary>

To create a Search service with Azure, work through the following instructions.

1. Log in to [the Azure portal](https://azure.microsoft.com/), click **More services**, and create a Search service.
2. In the **Filter** field, enter Search service and click **Search services**.

    ![Search for Search services](https://doc.sitecore.com/api/markdown-image/xp/en/developers/91/platform-administration-and-architecture/images/6A3A9E8F2CB442E6AC6CCD8FE3149616.png)

3. In the **Search services** window, click **Add**.

    ![Click Add](https://doc.sitecore.com/api/markdown-image/xp/en/developers/91/platform-administration-and-architecture/images/BDB3EA34893D4467B05236A811CA5DC0.png)

4. In the **New Search Service** window:
    - Specify the name of your Search Service instance.
    - Choose the type of subscription that suits you.
    - Choose the appropriate resource group, location, and pricing tier that suits you.

    > [!note]
    > Sitecore uses 15 search indexes, and therefore requires the Standard pricing tier as a minimum.

    ![New Search Service window](https://doc.sitecore.com/api/markdown-image/xp/en/developers/91/platform-administration-and-architecture/images/5F3DBC6035294D57B6E4618E44688A54.png)

5. When the Search Service instance is configured, click **Create**.
6. Open your newly created search service and click **Settings**, **Keys**.
7. Copy the **Primary admin key** or the **Secondary admin key** to the `apiKey` parameter. It doesn't matter which key you choose to use, but the key will be used in the connection string.

</details>

<details>
<summary><h2>Format the connection string</h2></summary>

The default connection string name for Cloud Search is `cloud.search` and it contains the following information:

- `serviceUrl` – the HTTPS URL of the search service API (for example, https://dk-test.search.windows.net).
- `apiVersion` – follows a date format, for example, 2017-11-11 (see [more information on API versions](https://msdn.microsoft.com/library/azure/dn798935.aspx)).
- `apiKey` – the admin key to the service that you obtain from the Azure management portal.

> [!note]
> For Sitecore version 9.1 and later, set the API version to 2017-11-11. For information about other supported versions, refer to the [Azure Search compatibility table](https://kb.sitecore.net/articles/549969).

The connection string format is:

```text
<add name="cloud.search" connectionString="serviceUrl=<url>;apiVersion=<apiVersion>;apiKey=<apiKey>" />

```

> [!note]
> Azure Cognitive Search for xConnect does not support this feature.

### Geo-replicated scenarios

Sitecore supports a Search service with geo-replicated scenarios. To use this type of scenario:

1. Create two or more Search service instances.
2. Add connection strings with a pipe separator (`|`). If you have two search services, for example, searchservice1 and searchservice2, and you want to use them in a geo-replicated scenario, you must use the following connection string:

    ```xml
    <add name="cloud.search"
    connectionString="serviceUrl=https://searchservice1.search.windows.net;apiVersion=2015-02-28;apiKey=AdminKey1|serviceUrl=https://searchservice2.search.windows.net;apiVersion=2015-02-28;apiKey=AdminKey2" />
    ```

### Advanced scaling scenarios

For advanced scaling scenarios, it is best practice to use a dedicated search service for your index. To set this up:

1. Add a new connection string (for example, `cloud.search.analytics`).
2. Configure the corresponding index with this connection string name:

![Connection string name](https://doc.sitecore.com/api/markdown-image/xp/en/developers/91/platform-administration-and-architecture/images/3CED22D63B624CB2BFFE6CEDE59049B4.png)

</details>

<details>
<summary><h2>Specify Azure as your search provider</h2></summary>

By default Sitecore is distributed with the Solr search provider enabled. 

In order to use Azure instead, you must [specify Azure](https://doc.sitecore.com/xp/en/developers/91/platform-administration-and-architecture/configure-a-search-and-indexing-provider.html "Configure a search and indexing provider") as your search provider in the `web.config` file.

</details>

<details>
<summary><h2>Rebuild the indexes</h2></summary>

You must rebuild the indexes to ensure Sitecore is fully operational.

To rebuild the indexes:

1. Go to the Sitecore login page (http:// {your_instance}/sitecore/login) and log in with your admin credentials.
2. On the Sitecore **Launchpad**, click **Control Panel**, and select **Indexing manager**.
3. To select and rebuild all of the indexes, on the **Indexing Manager** page, click **Select all**, **Rebuild**.

    > [!note]
    > Rebuilding the index is a time consuming operation and can take 15 minutes or more.

    When the indexes are rebuilt, the Sitecore search indexes appear in the **Search service** window of the Azure Portal.

    ![Indexing Manager page](https://doc.sitecore.com/api/markdown-image/xp/en/developers/91/platform-administration-and-architecture/images/4B949D4B00C94DD1A55C849238DA8196.png)

</details>

<details>
<summary><h2>Map the Azure field types</h2></summary>

Azure Search uses the following [Entity Data Model (EDM) field types](https://msdn.microsoft.com/en-us/library/azure/dn798938.aspx). Refer to the table to ensure you map the field types correctly.

| **Field type** | **Description** |
| --- | --- |
| `Edm.String` | Optional: Text that can be tokenized for full-text search, for example, word-breaking, stemming, and so on. |
| `Collection(Edm.String)` | A list of strings that can be tokenized for full-text search. There is no upper limit on the number of items in a collection, but remember that the 16 MB upper limit on payload size applies to collections. |
| `Edm.Boolean` | Contains `true` or `false` values. |
| `Edm.Int32` | Contains 32-bit integer values. |
| `Edm.Int64` | Contains 64-bit integer values. |
| `Edm.Double` | Uses double-precision numeric data. |
| `Edm.DateTimeOffset` | The date and time values are represented in the OData V4 format, for example:<br><br>yyyy-MM-ddTHH:mm:ss.fffZ<br><br>yyyy-MM-ddTHH:mm:ss.fff[+\|-]HH:mm.<br><br>> [!note]<br>> The precision of `DateTime` fields is limited to milliseconds. If you upload `DateTime` values that have submillisecond precision, the returned value will be rounded up to milliseconds, for example:<br>> `2015-04-15T10:`30:09`.7552052Z` will be returned as:<br>> `2015-04-15T10:`30:09`.7550000Z`. |

To see how to define the different types of mapping between .Net and Sitecore, go to the `sitecore\contentsearch\indexConfigurations\defaultCloudIndexConfiguration\CloudTypeMapper` node in the *App_Config\\Sitecore\\ContentSearch.Azure\\Sitecore.ContentSearch.Azure.DefaultIndexConfiguration.config* file.

> [!note]
> You must define the map element for all custom fields like this:
>
> <map type="<Field type>" cloudType="<Edm type from list of supported types>" />

</details>

<details>
<summary><h2>Map fields</h2></summary>

When listing all of the fields that the components use under the index configuration section, it is best practice that you list them as follows:

- `sitecore`\\`contentSearch`\\`configuration`\\`indexes`\\`index`\\`configuration`\\`fieldMap`

The supported attributes are:

| **Attribute** | **Description** |
| --- | --- |
| `fieldName` | The name of the field, as defined for Lucene and Solr. |
| `cloudFieldName` | The field name as defined for Cloud. It can only contain letters, numbers, and underscores.<br><br>> [!note]<br>> The first character must be a letter. |
| `boost` | Use the boost attribute to give one field more importance than another. |
| `format` | You must configure this attribute for `DateTime` type fields. The supported value is `yyyy-MM-ddTHH:mm:ss.fffZ.` |
| `settingType` | The `settingType` property must be: `Sitecore.ContentSearch.Azure.CloudSearchFieldConfiguration, Sitecore.ContentSearch.Azure` |

</details>

<details>
<summary><h2>Support for Azure Search</h2></summary>

Use the [support reference for Azure Search](https://doc.sitecore.com/xp/en/developers/91/platform-administration-and-architecture/support-reference-for-azure-cognitive-search.html "Support reference for Azure Cognitive Search") to ensure that you configure query support and facet support correctly.

</details>

<details>
<summary><h2>Configure a number of open HTTP connections</h2></summary>

You can [manage the number of connections](https://docs.microsoft.com/en-us/dotnet/framework/network-programming/managing-connections) that the Azure Search provider uses with the following setting:

```text
<setting name="ContentSearch.Azure.ServicePoint.ConnectionLimit" value="100" />

```

In the following scenarios you must adjust the setting value:

- *Decrease the value* - If there are other applications that are using HTTP intensively.
- *Increase the value* - If an application is under a high load, it takes too long to create new connections or creation fails. This is due to the exceed limit being set too low.

</details>