|
| 1 | +--- |
| 2 | +title: Integrate Azure OpenAI with Service Connector |
| 3 | +description: In this document, learn how to integrate Azure OpenAI into your application with Service Connector |
| 4 | +author: wchigit |
| 5 | +ms.author: wchi |
| 6 | +ms.service: service-connector |
| 7 | +ms.topic: how-to |
| 8 | +ms.date: 06/14/2024 |
| 9 | +--- |
| 10 | + |
| 11 | +# Integrate Azure OpenAI with Service Connector |
| 12 | + |
| 13 | +This page shows supported authentication methods and clients, and shows sample code you can use to connect Azure OpenAI to other cloud services using Service Connector. You might still be able to connect to Azure OpenAI using other methods. This page also shows default environment variable names and values you get when you create the service connection. |
| 14 | + |
| 15 | +## Supported compute services |
| 16 | + |
| 17 | +Service Connector can be used to connect the following compute services to Azure OpenAI: |
| 18 | + |
| 19 | +- Azure App Service |
| 20 | +- Azure Functions |
| 21 | +- Azure Container Apps |
| 22 | +- Azure Spring Apps |
| 23 | + |
| 24 | +## Supported authentication types and client types |
| 25 | + |
| 26 | +The table below shows which combinations of authentication methods and clients are supported for connecting your compute service to Azure OpenAI using Service Connector. A “Yes” indicates that the combination is supported, while a “No” indicates that it is not supported. |
| 27 | + |
| 28 | + |
| 29 | +| Client type | System-assigned managed identity | User-assigned managed identity | Secret/connection string | Service principal | |
| 30 | +|-------------|:--------------------------------:|:------------------------------:|:------------------------:|:-----------------:| |
| 31 | +| .NET | Yes | Yes | Yes | Yes | |
| 32 | +| Java | Yes | Yes | Yes | Yes | |
| 33 | +| Node.js | Yes | Yes | Yes | Yes | |
| 34 | +| Python | Yes | Yes | Yes | Yes | |
| 35 | +| None | Yes | Yes | Yes | Yes | |
| 36 | + |
| 37 | +This table indicates that all combinations of client types and authentication methods in the table are supported. All client types can use any of the authentication methods to connect to Azure OpenAI using Service Connector. |
| 38 | + |
| 39 | +## Default environment variable names or application properties and sample code |
| 40 | + |
| 41 | +Use the connection details below to connect compute services to Azure OpenAI. For more information about naming conventions, check the [Service Connector internals](concept-service-connector-internals.md#configuration-naming-convention) article. |
| 42 | + |
| 43 | +### System-assigned managed identity |
| 44 | + |
| 45 | +| Default environment variable name | Description | Sample value | |
| 46 | +| --------------------------------- | ---------------------------- | ------------------------------------------------ | |
| 47 | +| AZURE_OPENAI_BASE | Azure OpenAI endpoint | `https://<Azure-OpenAI-name>.openai.azure.com/` | |
| 48 | + |
| 49 | +#### Sample code |
| 50 | +Refer to the steps and code below to connect to Azure OpenAI using a system-assigned managed identity. |
| 51 | +[!INCLUDE [code sample for app config](./includes/code-openai-me-id.md)] |
| 52 | + |
| 53 | +### User-assigned managed identity |
| 54 | + |
| 55 | +| Default environment variable name | Description | Sample value | |
| 56 | +| --------------------------------- | -------------------------- | ----------------------------------------------- | |
| 57 | +| AZURE_OPENAI_BASE | Azure OpenAI Endpoint | `https://<Azure-OpenAI-name>.openai.azure.com/` | |
| 58 | +| AZURE_OPENAI_CLIENTID | Your client ID | `<client-ID>` | |
| 59 | + |
| 60 | +#### Sample code |
| 61 | +Refer to the steps and code below to connect to Azure OpenAI using a user-assigned managed identity. |
| 62 | +[!INCLUDE [code sample for azure openai](./includes/code-openai-me-id.md)] |
| 63 | + |
| 64 | +### Connection string |
| 65 | + |
| 66 | +> [!div class="mx-tdBreakAll"] |
| 67 | +> | Default environment variable name | Description | Sample value | |
| 68 | +> | --------------------------------- | ------------| ------------ | |
| 69 | +> | AZURE_OPENAI_BASE | Azure OpenAI Endpoint | `https://<Azure-OpenAI-name>.openai.azure.com/` | |
| 70 | +> | AZURE_OPENAI_KEY | Azure OpenAI API key | `<api-key>` | |
| 71 | +
|
| 72 | +#### Sample Code |
| 73 | +Refer to the steps and code below to connect to Azure OpenAI using a connection string. |
| 74 | +[!INCLUDE [code sample for azure openai](./includes/code-openai-secret.md)] |
| 75 | + |
| 76 | + |
| 77 | +### Service principal |
| 78 | + |
| 79 | +| Default environment variable name | Description | Sample value | |
| 80 | +| ----------------------------------- | -------------------------- | ---------------------------------------------- | |
| 81 | +| AZURE_OPENAI_BASE | Azure OpenAI Endpoint | `https://<Azure-OpenAI-name>.openai.azure.com/` | |
| 82 | +| AZURE_OPENAI_CLIENTID | Your client ID | `<client-ID>` | |
| 83 | +| AZURE_OPENAI_CLIENTSECRET | Your client secret | `<client-secret>` | |
| 84 | +| AZURE_OPENAI_TENANTID | Your tenant ID | `<tenant-ID>` | |
| 85 | + |
| 86 | +#### Sample code |
| 87 | +Refer to the steps and code below to connect to Azure OpenAI using a service principaL. |
| 88 | +[!INCLUDE [code sample for azure openai](./includes/code-openai-me-id.md)] |
| 89 | + |
| 90 | +## Next steps |
| 91 | + |
| 92 | +Follow the tutorial listed below to learn more about Service Connector. |
| 93 | + |
| 94 | +> [!div class="nextstepaction"] |
| 95 | +> [Learn about Service Connector concepts](./concept-service-connector-internals.md) |
0 commit comments