Skip to content

Commit 1f0c1f0

Browse files
Merge pull request #194514 from gmndrg/master
Created new SQL MI managed identity indexer doc
2 parents 4607688 + 3735ab8 commit 1f0c1f0

16 files changed

+192
-6
lines changed

articles/search/TOC.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,8 @@
336336
href: search-howto-managed-identities-cosmos-db.md
337337
- name: SQL Database
338338
href: search-howto-managed-identities-sql.md
339+
- name: SQL Managed Instance
340+
href: search-index-azure-sql-managed-instance-with-managed-identity.md
339341
- name: Troubleshooting guidance
340342
href: search-indexer-troubleshooting.md
341343
- name: Troubleshoot indexer errors and warnings
Loading
22.4 KB
Loading
84.7 KB
Loading
68.8 KB
Loading
54.5 KB
Loading

articles/search/search-howto-connecting-azure-sql-database-to-azure-search-using-indexers.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ author: HeidiSteen
88
ms.author: heidist
99
ms.service: cognitive-search
1010
ms.topic: how-to
11-
ms.date: 02/28/2022
11+
ms.date: 05/03/2022
1212
---
1313

1414
# Index data from Azure SQL
@@ -25,6 +25,8 @@ This article supplements [**Create an indexer**](search-howto-create-indexers.md
2525

2626
+ A REST client, such as [Postman](search-get-started-rest.md) or [Visual Studio Code with the extension for Azure Cognitive Search](search-get-started-vs-code.md) to send REST calls that create the data source, index, and indexer.
2727

28+
+ If you're using the [Azure portal](https://portal.azure.com/) to create the data source, make sure that access to all public networks is enabled in the Azure SQL firewall while going through the instructions below. Otherwise, you need to enable access to all public networks during this setup and then disable it again, or instead, you must use REST API from a device with an authorized IP in the firewall rules, to perform these operations. If the Azure SQL firewall has public networks access disabled, there will be errors when connecting from the portal to it.
29+
2830
<!-- Real-time data synchronization must not be an application requirement. An indexer can reindex your table at most every five minutes. If your data changes frequently, and those changes need to be reflected in the index within seconds or single minutes, we recommend using the [REST API](/rest/api/searchservice/AddUpdate-or-Delete-Documents) or [.NET SDK](search-get-started-dotnet.md) to push updated rows directly.
2931
3032
Incremental indexing is possible. If you have a large data set and plan to run the indexer on a schedule, Azure Cognitive Search must be able to efficiently identify new, changed, or deleted rows. Non-incremental indexing is only allowed if you're indexing on demand (not on schedule), or indexing fewer than 100,000 rows. For more information, see [Capturing Changed and Deleted Rows](#CaptureChangedRows) below. -->
@@ -381,4 +383,4 @@ It's not recommended. Only **rowversion** allows for reliable data synchronizati
381383

382384
+ You can ensure that when the indexer runs, there are no outstanding transactions on the table that’s being indexed (for example, all table updates happen as a batch on a schedule, and the Azure Cognitive Search indexer schedule is set to avoid overlapping with the table update schedule).
383385

384-
+ You periodically do a full reindex to pick up any missed rows.
386+
+ You periodically do a full reindex to pick up any missed rows.

articles/search/search-howto-index-cosmosdb-mongodb.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,15 @@ api-key: [Search service admin key]
282282
}
283283
```
284284

285+
## Limitations
286+
287+
These are the limitations of this feature:
288+
289+
+ Custom queries are not supported.
290+
291+
+ In this feature, the column name `_ts` is a reserved word. If there is a column called `_ts` in the Mongo database, the indexer will fail. If this is the case, it is recommended an alternate method to index is used, such as [Push API](search-what-is-data-import.md) or through [Azure Data Factory](../data-factory/connector-azure-cosmos-db.md) by selecting an Azure Cognitive Search index sink.
292+
293+
285294
## Next steps
286295

287296
You can now control how you [run the indexer](search-howto-run-reset-indexers.md), [monitor status](search-howto-monitor-indexers.md), or [schedule indexer execution](search-howto-schedule-indexers.md). The following articles apply to indexers that pull content from Azure Cosmos DB:

articles/search/search-import-data-portal.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ manager: nitinme
88
ms.author: heidist
99
ms.service: cognitive-search
1010
ms.topic: conceptual
11-
ms.date: 10/06/2021
11+
ms.date: 05/03/2022
1212
---
1313
# Import data wizard in Azure Cognitive Search
1414

@@ -60,7 +60,9 @@ The wizard is not without limitations. Constraints are summarized as follows:
6060

6161
+ AI enrichment, as exposed in the portal, is limited to a subset of built-in skills.
6262

63-
+ A [knowledge store](knowledge-store-concept-intro.md), which can be created by the wizard, is limited to a few default projections and uses a default naming convention. If you want to customize names or projections, you will need to create the knowledge store through REST or the SDKs.
63+
+ A [knowledge store](knowledge-store-concept-intro.md), which can be created by the wizard, is limited to a few default projections and uses a default naming convention. If you want to customize names or projections, you will need to create the knowledge store through REST API or the SDKs.
64+
65+
+ Public access to all networks must be enabled on the supported data source while the wizard is used, since the portal won't be able to access the data source during setup if public access is disabled. This means that if your data source has a firewall enabled, you must disable it, run the Import Data wizard and then enable it after wizard setup is completed. If this is not an option, you can create Azure Cognitive Search data source, indexer, skillset and index through REST API or the SDKs.
6466

6567
## Workflow
6668

@@ -140,4 +142,4 @@ Internally, the wizard also sets up the following, which is not visible in the i
140142
The best way to understand the benefits and limitations of the wizard is to step through it. The following quickstart will guide you through each step.
141143

142144
> [!div class="nextstepaction"]
143-
> [Quickstart: Create a search index using the Azure portal](search-get-started-portal.md)
145+
> [Quickstart: Create a search index using the Azure portal](search-get-started-portal.md)
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
---
2+
title: Connect to Azure SQL Managed Instance using managed identity
3+
titleSuffix: Azure Cognitive Search
4+
description: Learn how to set up an Azure Cognitive Search indexer connection to an Azure SQL Managed Instance using a managed identity
5+
6+
author: gmndrg
7+
ms.author: gimondra
8+
manager: liamca
9+
10+
ms.service: cognitive-search
11+
ms.topic: conceptual
12+
ms.date: 05/03/2022
13+
---
14+
15+
# Set up an indexer connection to Azure SQL Managed Instance using a managed identity
16+
17+
This article describes how to set up an Azure Cognitive Search indexer connection to [SQL Managed Instance](/azure/azure-sql/managed-instance/sql-managed-instance-paas-overview) using a managed identity instead of providing credentials in the connection string.
18+
19+
You can use a system-assigned managed identity or a user-assigned managed identity (preview). Managed identities are Azure AD logins and require Azure role assignments to access data in SQL Managed Instance.
20+
21+
Before learning more about this feature, it is recommended that you have an understanding of what an indexer is and how to set up an indexer for your data source. More information can be found at the following links:
22+
23+
* [Indexer overview](search-indexer-overview.md)
24+
* [SQL Managed Instance indexer](search-howto-connecting-azure-sql-database-to-azure-search-using-indexers.md)
25+
26+
## Prerequisites
27+
28+
* [Create a managed identity](search-howto-managed-identities-data-sources.md) for your search service.
29+
30+
* Azure AD admin role on SQL Managed Instance:
31+
32+
To assign read permissions on SQL Managed Instance, you must be an Azure Global Admin with a SQL Managed Instance. See [Configure and manage Azure AD authentication with SQL Managed Instance](/azure/azure-sql/managed-instance/authentication-aad-configure) and follow the steps to provision an Azure AD admin (SQL Managed Instance).
33+
34+
* [Configure public endpoint and NSG in SQL Managed Instance](search-howto-connecting-azure-sql-mi-to-azure-search-using-indexers.md) to allow connections from Azure Cognitive Search.
35+
36+
## 1 - Assign permissions to read the database
37+
38+
Follow these steps to assign the search service system managed identity permission to read the SQL Managed database.
39+
40+
1. Connect to your SQL Managed Instance through SQL Server Management Studio (SSMS) by using one of the following methods:
41+
42+
- [Configure a point-to-site connection from on-premises](/azure/azure-sql/managed-instance/point-to-site-p2s-configure)
43+
- [Configure an Azure VM](/azure/azure-sql/managed-instance/connect-vm-instance-configure)
44+
45+
1. Authenticate with your Azure AD account.
46+
47+
:::image type="content" source="./media/search-index-azure-sql-managed-instance-with-managed-identity/sql-login.png" alt-text="Showing screenshot of the Connect to Server dialog.":::
48+
49+
3. From the left pane, locate the SQL database you will be using as data source for indexing and right-click it. Select **New Query**.
50+
51+
:::image type="content" source="./media/search-index-azure-sql-managed-instance-with-managed-identity/new-sql-query.png" alt-text="Showing screenshot of new SQL query.":::
52+
53+
54+
4. In the T-SQL window, copy the following commands and include the brackets around your search service name. Click on **Execute**.
55+
56+
57+
```tsql
58+
CREATE USER [insert your search service name here or user-assigned managed identity name] FROM EXTERNAL PROVIDER;
59+
EXEC sp_addrolemember 'db_datareader', [insert your search service name here or user-assigned managed identity name];
60+
```
61+
62+
:::image type="content" source="./media/search-index-azure-sql-managed-instance-with-managed-identity/execute-sql-query.png" alt-text="Showing screenshot of how to execute SQL query.":::
63+
64+
If you later change the search service system identity after assigning permissions, you must remove the role membership and remove the user in the SQL database, then repeat the permission assignment. Removing the role membership and user can be accomplished by running the following commands:
65+
66+
```tsql
67+
sp_droprolemember 'db_datareader', [insert your search service name or user-assigned managed identity name];
68+
69+
DROP USER IF EXISTS [insert your search service name or user-assigned managed identity name];
70+
```
71+
72+
## 2 - Add a role assignment
73+
74+
In this step you will give your Azure Cognitive Search service permission to read data from your SQL Managed Instance.
75+
76+
1. In the Azure portal navigate to your SQL Managed Instance page.
77+
1. Select **Access control (IAM)**.
78+
1. Select **Add** then **Add role assignment**.
79+
80+
:::image type="content" source="./media/search-index-azure-sql-managed-instance-with-managed-identity/access-control-add-role-assignment.png" alt-text="Showing screenshot of the Access Control page." lightbox="media/search-index-azure-sql-managed-instance-with-managed-identity/access-control-add-role-assignment.png":::
81+
82+
83+
4. Select **Reader** role.
84+
1. Leave **Assign access to** as **Azure AD user, group or service principal**.
85+
1. If you're using a system-assigned managed identity, search for your search service, then select it. If you're using a user-assigned managed identity, search for the name of the user-assigned managed identity, then select it. Select **Save**.
86+
87+
Example for SQL Managed Instance using a system-assigned managed identity:
88+
89+
:::image type="content" source="./media/search-index-azure-sql-managed-instance-with-managed-identity/add-role-assignment.png" alt-text="Showing screenshot of the member role assignment.":::
90+
91+
## 3 - Create the data source
92+
93+
Create the data source and provide a system-assigned managed identity.
94+
95+
### System-assigned managed identity
96+
97+
The [REST API](/rest/api/searchservice/create-data-source), Azure portal, and the [.NET SDK](/dotnet/api/azure.search.documents.indexes.models.searchindexerdatasourceconnection) support system-assigned managed identity.
98+
99+
When you're connecting with a system-assigned managed identity, the only change to the data source definition is the format of the "credentials" property. You'll provide an Initial Catalog or Database name and a ResourceId that has no account key or password. The ResourceId must include the subscription ID of SQL Managed Instance, the resource group of SQL Managed instance, and the name of the SQL database.
100+
101+
Here is an example of how to create a data source to index data from a storage account using the [Create Data Source](/rest/api/searchservice/create-data-source) REST API and a managed identity connection string. The managed identity connection string format is the same for the REST API, .NET SDK, and the Azure portal.
102+
103+
```http
104+
POST https://[service name].search.windows.net/datasources?api-version=2020-06-30
105+
Content-Type: application/json
106+
api-key: [admin key]
107+
108+
{
109+
"name" : "sql-mi-datasource",
110+
"type" : "azuresql",
111+
"credentials" : {
112+
"connectionString" : "Database=[SQL database name];ResourceId=/subscriptions/[subscription ID]/resourcegroups/[resource group name]/providers/Microsoft.Sql/managedInstances/[SQL Managed Instance name];Connection Timeout=100;"
113+
},
114+
"container" : {
115+
"name" : "my-table"
116+
}
117+
}
118+
```
119+
120+
## 4 - Create the index
121+
122+
The index specifies the fields in a document, attributes, and other constructs that shape the search experience.
123+
124+
Here's a [Create Index](/rest/api/searchservice/create-index) REST API call with a searchable `booktitle` field:
125+
126+
```http
127+
POST https://[service name].search.windows.net/indexes?api-version=2020-06-30
128+
Content-Type: application/json
129+
api-key: [admin key]
130+
131+
{
132+
"name" : "my-target-index",
133+
"fields": [
134+
{ "name": "id", "type": "Edm.String", "key": true, "searchable": false },
135+
{ "name": "booktitle", "type": "Edm.String", "searchable": true, "filterable": false, "sortable": false, "facetable": false }
136+
]
137+
}
138+
```
139+
140+
## 5 - Create the indexer
141+
142+
An indexer connects a data source with a target search index, and provides a schedule to automate the data refresh. Once the index and data source have been created, you're ready to create the indexer.
143+
144+
Here's a [Create Indexer](/rest/api/searchservice/create-indexer) REST API call with an Azure SQL indexer definition. The indexer will run when you submit the request.
145+
146+
```http
147+
POST https://[service name].search.windows.net/indexers?api-version=2020-06-30
148+
Content-Type: application/json
149+
api-key: [admin key]
150+
151+
{
152+
"name" : "sql-mi-indexer",
153+
"dataSourceName" : "sql-mi-datasource",
154+
"targetIndexName" : "my-target-index"
155+
}
156+
```
157+
158+
## Troubleshooting
159+
160+
If you get an error when the indexer tries to connect to the data source that says that the client is not allowed to access the server, take a look at [common indexer errors](./search-indexer-troubleshooting.md).
161+
162+
You can also rule out any firewall issues by trying the connection with and without restrictions in place.
163+
164+
## See also
165+
166+
* [SQL Managed Instance and Azure SQL Database indexer](search-howto-connecting-azure-sql-database-to-azure-search-using-indexers.md)

0 commit comments

Comments
 (0)