| title | Azure OpenAI embeddings store output binding for Azure Functions | ||||||
|---|---|---|---|---|---|---|---|
| description | Learn how to use the Azure OpenAI embeddings store output binding to write searchable content to a semantic document store during function execution in Azure Functions. | ||||||
| ms.topic | reference | ||||||
| ms.custom |
|
||||||
| ms.collection |
|
||||||
| ms.date | 05/15/2025 | ||||||
| ms.update-cycle | 180-days | ||||||
| zone_pivot_groups | programming-languages-set-functions |
[!INCLUDE preview-support]
The Azure OpenAI embeddings store output binding allows you to write files to a semantic document store that can be referenced later in a semantic search.
For information on setup and configuration details of the Azure OpenAI extension, see Azure OpenAI extensions for Azure Functions. To learn more about semantic ranking in Azure AI Search, see Semantic ranking in Azure AI Search.
[!INCLUDE functions-support-notes-samples-openai]
::: zone pivot="programming-language-csharp"
This example writes an HTTP input stream to a semantic document store at the provided URL.
:::code language="csharp" source="~/functions-openai-extension/samples/rag-aisearch/csharp-ooproc/FilePrompt.cs" range="17-21,29-66":::
::: zone-end
::: zone pivot="programming-language-java"
This example writes an HTTP input stream to a semantic document store at the provided URL.
:::code language="java" source="~/functions-openai-extension/samples/rag-aisearch/java/src/main/java/com/azfs/FilePrompt.java" range="29-73":::
::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript"
This example writes an HTTP input stream to a semantic document store at the provided URL.
::: zone-end
::: zone pivot="programming-language-javascript"
:::code language="javascript" source="~/functions-openai-extension/samples/rag-aisearch/javascript/src/app.js" range="5-37":::
::: zone-end
::: zone pivot="programming-language-typescript"
:::code language="typescript" source="~/functions-openai-extension/samples/rag-aisearch/typescript/src/app.ts" range="4-40":::
::: zone-end
::: zone pivot="programming-language-powershell"
This example writes an HTTP input stream to a semantic document store at the provided URL.
Here's the function.json file for ingesting files:
:::code language="json" source="~/functions-openai-extension/samples/rag-aisearch/powershell/IngestFile/function.json" :::
For more information about function.json file properties, see the Configuration section.
:::code language="powershell" source="~/functions-openai-extension/samples/rag-aisearch/powershell/IngestFile/run.ps1" :::
::: zone-end
::: zone pivot="programming-language-python"
This example writes an HTTP input stream to a semantic document store at the provided URL.
:::code language="python" source="~/functions-openai-extension/samples/rag-aisearch/python/function_app.py" range="8-35":::
::: zone-end
::: zone pivot="programming-language-csharp"
Apply the EmbeddingsStoreOutput attribute to define an embeddings store output binding, which supports these parameters:
| Parameter | Description |
|---|---|
| Input | The input string for which to generate embeddings. |
| AIConnectionName | Optional. Gets or sets the name of the configuration section for AI service connectivity settings. For Azure OpenAI: If specified, looks for "Endpoint" and "Key" values in this configuration section. If not specified or the section doesn't exist, falls back to environment variables: AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_KEY. For user-assigned managed identity authentication, this property is required. For OpenAI service (non-Azure), set the OPENAI_API_KEY environment variable. |
| EmbeddingsModel | Optional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage. |
| MaxChunkLength | Optional. The maximum number of characters used for chunking the input. For more information, see Usage. |
| MaxOverlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
| InputType | Optional. Gets the type of the input. |
| StoreConnectionName | The name of an app setting or environment variable that contains the connection string value. This property supports binding expressions. |
| Collection | The name of the collection or table or index to search. This property supports binding expressions. |
::: zone-end ::: zone pivot="programming-language-java"
The EmbeddingsStoreOutput annotation enables you to define an embeddings store output binding, which supports these parameters:
| Element | Description |
|---|---|
| name | Gets or sets the name of the output binding. |
| input | The input string for which to generate embeddings. |
| aiConnectionName | Optional. Gets or sets the name of the configuration section for AI service connectivity settings. For Azure OpenAI: If specified, looks for "Endpoint" and "Key" values in this configuration section. If not specified or the section doesn't exist, falls back to environment variables: AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_KEY. For user-assigned managed identity authentication, this property is required. For OpenAI service (non-Azure), set the OPENAI_API_KEY environment variable. |
| embeddingsModel | Optional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage. |
| maxChunkLength | Optional. The maximum number of characters used for chunking the input. For more information, see Usage. |
| maxOverlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
| inputType | Optional. Gets the type of the input. |
| storeConnectionName | The name of an app setting or environment variable that contains the connection string value. This property supports binding expressions. |
| collection | The name of the collection or table or index to search. This property supports binding expressions. |
::: zone-end
::: zone pivot="programming-language-python"
During the preview, define the output binding as a generic_output_binding binding of type semanticSearch, which supports these parameters:
| Parameter | Description |
|---|---|
| arg_name | The name of the variable that represents the binding parameter. |
| input | The input string for which to generate embeddings. |
| ai_connection_name | Optional. Gets or sets the name of the configuration section for AI service connectivity settings. For Azure OpenAI: If specified, looks for "Endpoint" and "Key" values in this configuration section. If not specified or the section doesn't exist, falls back to environment variables: AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_KEY. For user-assigned managed identity authentication, this property is required. For OpenAI service (non-Azure), set the OPENAI_API_KEY environment variable. |
| embeddings_model | Optional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage. |
| maxChunkLength | Optional. The maximum number of characters used for chunking the input. For more information, see Usage. |
| max_overlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
| input_type | Gets the type of the input. |
| store_connection_name | The name of an app setting or environment variable that contains the connection string value. This property supports binding expressions. |
| collection | The name of the collection or table or index to search. This property supports binding expressions. |
::: zone-end ::: zone pivot="programming-language-powershell"
The binding supports these configuration properties that you set in the function.json file.
| Property | Description |
|---|---|
| type | Must be embeddingsStore. |
| direction | Must be out. |
| name | The name of the output binding. |
| input | The input string for which to generate embeddings. |
| aiConnectionName | Optional. Gets or sets the name of the configuration section for AI service connectivity settings. For Azure OpenAI: If specified, looks for "Endpoint" and "Key" values in this configuration section. If not specified or the section doesn't exist, falls back to environment variables: AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_KEY. For user-assigned managed identity authentication, this property is required. For OpenAI service (non-Azure), set the OPENAI_API_KEY environment variable. |
| embeddingsModel | Optional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage. |
| maxChunkLength | Optional. The maximum number of characters used for chunking the input. For more information, see Usage. |
| maxOverlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
| inputType | Optional. Gets the type of the input. |
| storeConnectionName | The name of an app setting or environment variable that contains the connection string value. This property supports binding expressions. |
| collection | The name of the collection or table or index to search. This property supports binding expressions. |
::: zone-end
::: zone pivot="programming-language-javascript,programming-language-typescript"
The binding supports these properties, which are defined in your code:
| Property | Description |
|---|---|
| input | The input string for which to generate embeddings. |
| aiConnectionName | Optional. Gets or sets the name of the configuration section for AI service connectivity settings. For Azure OpenAI: If specified, looks for "Endpoint" and "Key" values in this configuration section. If not specified or the section doesn't exist, falls back to environment variables: AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_KEY. For user-assigned managed identity authentication, this property is required. For OpenAI service (non-Azure), set the OPENAI_API_KEY environment variable. |
| embeddingsModel | Optional. The ID of the model to use, which defaults to text-embedding-ada-002. You shouldn't change the model for an existing database. For more information, see Usage. |
| maxChunkLength | Optional. The maximum number of characters used for chunking the input. For more information, see Usage. |
| maxOverlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
| inputType | Optional. Gets the type of the input. |
| storeConnectionName | The name of an app setting or environment variable that contains the connection string value. This property supports binding expressions. |
| collection | The name of the collection or table or index to search. This property supports binding expressions. |
::: zone-end
See the Example section for complete examples.