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