Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Important
The Azure OpenAI extension for Azure Functions is currently in preview.
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.
Note
References and examples are only provided for the Node.js v4 model.
Note
References and examples are only provided for the Python v2 model.
Note
While both C# process models are supported, only isolated worker model examples are provided.
Example
Go support isn't currently available for this binding.
This example writes an HTTP input stream to a semantic document store at the provided URL.
This example writes an HTTP input stream to a semantic document store at the provided URL.
This example writes an HTTP input stream to a semantic document store at the provided URL.
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:
For more information about function.json file properties, see the Configuration section.
This example writes an HTTP input stream to a semantic document store at the provided URL.
Attributes
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. |
Annotations
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. |
Decorators
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. |
Configuration
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. |
Configuration
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. |
Usage
See the Example section for complete examples.