Connect SPSync to Azure AI Search
SPSync writes one Azure AI Search index per table: a list’s main table, each multi-value child table and the shared users table. Documents are merged by key, and a row deleted in SharePoint is removed from the index. With an embedding provider configured, each index also gets a vector field, so keyword, vector and hybrid queries all work against the same index.
Before you start
Section titled “Before you start”- An Azure AI Search service. The Basic tier or above suits a real list; the no-cost level has small index and document limits.
- Either Owner or Contributor on the service (to read its keys) or someone who can give you the admin key, or an Azure identity SPSync can sign in as and someone who can assign it roles on the service (see “Sign in with Microsoft Entra ID”).
- Nothing to install on the machine that runs SPSync. SPSync keeps a small local state file (a DuckDB file) that records what it last sent, so it sends only the rows that changed. Keep that file on a disk that survives restarts.
Create the database and a least-privilege user
Section titled “Create the database and a least-privilege user”There is no database to create: SPSync creates the indexes. You choose how it signs in.
Admin key. Index creation needs an admin key, and a query key is refused. In the Azure portal, open the service, then Settings, Keys, and copy the primary or secondary admin key. Use the secondary for SPSync so you can rotate the primary without a gap. The service must accept keys: under Settings, Keys, API access control, choose API keys or Both. An admin key can change or delete any index on the service. If the service also serves your own search application, create a second service for SPSync’s indexes, or keep the key out of anything else’s reach.
Microsoft Entra ID (preview, not verified live). Where the service has API-key access
turned off (the disableLocalAuth setting, or API access control set to Role-based
access control), an admin key is refused and SPSync signs in as an Entra identity instead.
Give that identity two roles on the search service, no more:
Search Index Data Contributor, to write and delete documents.Search Service Contributor, to create the indexes and add fields to them.
If embeddings use Azure OpenAI, also give it Cognitive Services OpenAI User on the Azure
OpenAI resource. spsync auth azure-search-roles prints the az role assignment create lines
for you to review and run; SPSync never runs them:
spsync auth azure-search-roles \ --principal <object id of the identity> \ --search-service-id /subscriptions/<id>/resourceGroups/<group>/providers/Microsoft.Search/searchServices/<name> \ --openai-account-id /subscriptions/<id>/resourceGroups/<group>/providers/Microsoft.CognitiveServices/accounts/<name>Leave out --openai-account-id when embeddings do not use Azure OpenAI. The principal is the
identity’s object id; the application id will not work.
Allow SPSync to reach it
Section titled “Allow SPSync to reach it”The service endpoint is https://<service>.search.windows.net on port 443. On the desktop
app and a self-hosted server the connection starts from that machine. For the Azure managed
application, it starts from the address the application connects out from.
- Public endpoint with a firewall: under Settings, Networking, choose Selected IP addresses and add the address. Add the portal’s own address range too if you want to keep browsing the indexes there.
- Private endpoint: choose Private under Networking, create the private endpoint and run SPSync inside the virtual network, or peered to it.
- No firewall: the default is open to the internet, protected by the key alone.
Encrypt the connection
Section titled “Encrypt the connection”The endpoint is https only and uses a certificate from a public authority, so there is
nothing to switch on. Enter the URL with https://.
Authentication SPSync supports today
Section titled “Authentication SPSync supports today”You can sign in with an admin key or, where the service turns keys off, as a Microsoft Entra identity.
Sign in with Microsoft Entra ID
Section titled “Sign in with Microsoft Entra ID”| Mode | What SPSync signs in as | Status |
|---|---|---|
| Admin API key | The key you enter | Supported |
| Azure managed identity | The identity assigned to the machine or app SPSync runs on (give a client id for a user-assigned one) | Preview |
| Entra default credential | Whatever the environment provides: a managed identity, a workload identity, or a developer’s az login |
Preview |
| Service principal with a certificate | An app registration, using a certificate whose path is in an environment variable | Preview |
| Service principal with a client secret | An app registration, using a secret held in an environment variable or a Key Vault reference | Preview |
| Signed-in Microsoft Entra user | The person using the SPSync desktop app. No secret is stored; the sign-in is kept in the operating system’s keychain | Preview, desktop app only |
Preview means the mode is built and tested against a stand-in for the service and the real Azure libraries, but has not been run against a real search service, so try it on a small list first.
Sign in as yourself (desktop app)
Section titled “Sign in as yourself (desktop app)”On the desktop app, Signed-in Microsoft Entra user signs in as the person using it, so
there is nothing to store and no service principal to create. Give that person the same
roles an identity needs (below). The first Test connection opens a browser window to
sign in; SPSync asks for the sign-in to this service (https://search.azure.com/.default)
and, when you use Azure OpenAI embeddings, to Azure OpenAI
(https://cognitiveservices.azure.com/.default). You are asked to sign in once for each of the two. Both fields on the form are optional: the
tenant defaults to common (any work or school account) and the application to the one SPSync
signs in with. If you use your own application, it needs the delegated permissions
user_impersonation on Azure Cognitive Search and on Azure Cognitive Services, and a public
client redirect of http://localhost. If you close the browser window or leave it open for more
than two minutes, the sign-in is abandoned and you can choose Test connection again.
A scheduled run never opens a browser. If the sign-in has expired it stops with a message
that says to choose Test connection again. The mode is not available on a hosted server
or in a container, because there is no person to sign in. spsync doctor shows the account
the token is for (for example ada@example.com). On the CLI, run
spsync auth login --client-id <application id> --tenant common --scope https://search.azure.com/.default (and the same with
https://cognitiveservices.azure.com/.default for Azure OpenAI embeddings) and set
auth.mode: entra_user. The client id and tenant must match the ones SPSync uses: the run’s
error message prints the exact command.
This mode is in preview: it is built and tested with the sign-in library and the service replaced by stand-ins, and has not been run against a real search service.
Choose the mode in Authentication on the Destination screen. An Entra mode hides the key
fields. For a service principal, enter the tenant id, the application id and the name of an
environment variable (or a keyvault:<vault>/<secret> reference) that holds the secret or
the certificate path; the secret itself is never typed into SPSync. The same identity calls
Azure OpenAI for embeddings, so the key fields for embeddings disappear too.
SPSync sends the token only over https to your search service’s own address (the address
Azure shows for the service), and refuses any other address, any http address and any
address with a user name, a different port or a path. The US Government and China clouds work
the same way: SPSync reads the cloud from the service address, and those clouds are also in
preview. With an admin key, the endpoint can be any address you enter.
An admin key still works everywhere a service allows keys. spsync doctor says so when it
connects with one, because a tenant that later turns key access off will stop SPSync.
Connect from SPSync
Section titled “Connect from SPSync”-
Desktop app: open the Destination screen, choose Azure AI Search, enter the endpoint, choose Authentication (Admin API key, or an Entra mode and its options), then choose Test connection. SPSync manages the local state file itself.
-
CLI: the config names environment variables, never the key itself.
SPSYNC_AAIS_STATE_PATHholds the path of the local state file, not a network address. For an Entra identity, setauthin the config file instead of the key variable:destination:kind: azure-ai-searchconnection_string_env: SPSYNC_AAIS_STATE_PATHdataset_name: mainazure_ai_search_endpoint: https://my-service.search.windows.netauth:mode: entra_managed_identity # or entra_default, entra_service_principal_secret, ...The key flags below are for the admin-key form.
Terminal window export SPSYNC_AAIS_STATE_PATH=/var/lib/spsync/aais-state.duckdbexport SPSYNC_AAIS_ADMIN_KEY='<admin key>'spsync export-config --output replication.yaml \--site-url https://contoso.sharepoint.com/sites/x --list Projects \--pipeline-name spsync_dev --prefix dev \--destination-kind azure-ai-search --connection-string-env SPSYNC_AAIS_STATE_PATH \--dataset-name main \--azure-ai-search-endpoint https://my-service.search.windows.net \--azure-ai-search-api-key-env SPSYNC_AAIS_ADMIN_KEY \--client-id <entra-app-client-id> -
AI assistant: with the admin MCP server connected, ask for the destination requirements, then let the assistant create the destination with the endpoint. You enter the admin key on the secure entry page, never in the chat.
Index names
Section titled “Index names”Azure AI Search allows only lowercase letters, digits and dashes in an index name, so every
underscore in a table name becomes a dash. With the prefix dev, a list called Tasks is the
index dev-tasks, and its multi-value column Tags is dev-tasks--tags. The users table is
sp-users. If a column changes type, SPSync adds a new index ending -v2 rather than
failing, because Azure AI Search cannot change a field’s type in place.
Every index also has an sp_key text field, which is the document key. The service requires
a text key, and SharePoint ids are numbers.
Embeddings and the vector field
Section titled “Embeddings and the vector field”Set an embedding provider to give each index a vector field, sp_embedding by default, with
a companion sp_embedding_hash. SPSync embeds the text of the columns you name, joined in
order, and re-embeds only the rows whose text changed. Changing the model re-embeds every
row.
| Setting | What it is |
|---|---|
| Provider | openai, azure-openai, or local (an offline model, no key needed). |
| Model | The model name. For azure-openai, the deployment name. |
| Dimensions | The vector width. It must match the model. Changing it later starts a new index ending -v2. |
| Columns | The destination column names to embed, for example title and description. |
| Embedding API key | The OpenAI or Azure OpenAI key. Not the search admin key. Not used with an Entra mode, where azure-openai is the only provider and the same identity is used. |
| Azure OpenAI endpoint | Needed for azure-openai only. With an Entra mode it must be your Azure OpenAI resource’s own https address. |
On the desktop app these are the Embedding fields on the same form. On the CLI they are
the --azure-ai-search-embedding-* flags, with the key and endpoint passed as environment
variable names. The local provider downloads its model on first use, so the machine needs
outbound internet access then. SPSync fills the index and leaves querying to the service: it
configures one default HNSW vector profile and no semantic ranking or scoring profiles.
What Test connection and doctor check
Section titled “What Test connection and doctor check”Both list the service’s index names. A pass means the endpoint is reachable and the key, or
the Entra identity, is accepted; with an identity, the result says which one SPSync connected
as (its application, user or object id, never the token). It does not check the embedding
provider’s key or the Azure OpenAI role, and it does not create anything. spsync doctor reports the probe as destination-connectivity.
Common errors
Section titled “Common errors”| What you see | What it means and the fix |
|---|---|
| Timeout or connection refused | The service firewall or a private endpoint is blocking SPSync, or the endpoint is wrong. |
HTTP 403 listing indexes |
The key is wrong or revoked, or it is a query key. Use an admin key. |
HTTP 403 with API keys disabled |
The service is set to role-based access only. Either set API access control to Both, or sign in with an Entra mode. |
HTTP 401 or 403 with an Entra mode |
The identity lacks the roles. Assign Search Index Data Contributor and Search Service Contributor on the search service (role assignments can take a few minutes to apply). |
could not acquire a credential ... [AADSTS...] |
Microsoft Entra refused to issue a token. The code names the cause; for example AADSTS700016 means the application id is wrong. |
Azure OpenAI embeddings call failed with a role named |
The identity lacks Cognitive Services OpenAI User on the Azure OpenAI resource. |
the endpoint must be an https:// URL or is not an Azure service host |
An Entra mode only sends its token to your search service’s own address. Copy the address from the portal. |
HTTP 400 naming an index or field |
A name breaks the service’s rules. Index names are lowercase with dashes; SPSync converts them, so check for a hand-made index with the same name. |
HTTP 400 about vector dimensions |
The model’s dimensions differ from the field. Set the dimensions to the model’s output size, or let SPSync create the -v2 index. |
HTTP 429 or 503 |
The service is throttling. Scale the replicas or partitions, or wait. SPSync resends on the next round. |