Forum Discussion
HassaanFaruq
Jan 29, 2026Copper Contributor
Cannot connect Azure OpenAI Embeddings model to SQL Server 2025
On SQL Server 2025, I am trying to vectorize a table.
To set up the ability for SQL Server 2025 to communicate with Azure OpenAI embeddings model, I first created a master key for encryption.
CREATE MASTER KEY ENCRYPTION BY PASSWORD = 'Secret';
GO
Then I set up a database scoped credential.
CREATE DATABASE SCOPED CREDENTIAL [MyAzureOpenAICredential]
WITH IDENTITY = 'HTTPEndpointHeaders',
SECRET = '{"api-key":"secret"}';
Then I created an external model.
CREATE EXTERNAL MODEL AzureOpenAIEmbeddingsModelWITH (LOCATION = 'https://{secret}-eastus2.cognitiveservices.azure.com/openai/deployments/text-embedding-3-small/embeddings?api-version=2023-05-15',API_FORMAT = 'Azure OpenAI',MODEL_TYPE = EMBEDDINGS,MODEL = 'text-embedding-3-small',CREDENTIAL = [MyAzureOpenAICredential]);
However, when I run this simple script:
DECLARE @text NVARCHAR(MAX) = N'SQL Server 2025 enables AI-powered applications';
DECLARE @embedding VECTOR(1536) = AI_GENERATE_EMBEDDINGS(@text USE MODEL AzureOpenAIEmbeddingsModel);
I get this error.
The database scoped credential 'MyAzureOpenAICredential' cannot be used to invoke an external rest endpoint.
I have read through https://learn.microsoft.com/en-us/training/modules/build-ai-solutions-sql-server/4-integrate-ai-models pertaining to this task. As well as SQL Server 2025 docs for creating a model. I have also read SQL Server 2025 docs for creating https://learn.microsoft.com/en-us/sql/t-sql/statements/create-database-scoped-credential-transact-sql?view=sql-server-ver17. I have not found any answers.
No RepliesBe the first to reply