title | description | ms.topic | ms.custom | ms.collection | ms.date | zone_pivot_groups | ||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Azure OpenAI embeddings store output binding for Azure Functions | 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. | reference |
|
| 01/07/2025 | 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="29-70":::
::: 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="24-68":::
::: 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-25":::
::: 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. |
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. |
MaxOverlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
InputType | Optional. Gets the type of the input. |
ConnectionName | 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. |
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. |
maxOverlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
inputType | Optional. Gets the type of the input. |
connectionName | 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. |
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. |
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. |
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. |
maxOverlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
inputType | Optional. Gets the type of the input. |
connectionName | 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. |
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. |
maxOverlap | Optional. Gets or sets the maximum number of characters to overlap between chunks. |
inputType | Optional. Gets the type of the input. |
connectionName | 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.