Get started with the Azure AI Inference integrations
이 콘텐츠는 아직 번역되지 않았습니다.
Azure AI Inference provides a unified REST API for calling AI models deployed in Azure AI Foundry and Azure AI Services. The Aspire Azure AI Inference integration lets you register an existing Azure AI Inference endpoint as a named connection in your AppHost, then inject the connection information into any consuming app — regardless of language.
Why use Azure AI Inference with Aspire
Section titled “Why use Azure AI Inference with Aspire”Adding an Azure AI Inference connection through Aspire — rather than hard-coding endpoints and API keys in each service — gives you:
- Centralized credential management. The API key and endpoint are stored once in the AppHost configuration and injected into each consuming app automatically.
- Consistent connection info across languages. Once you reference the connection from a consuming app, Aspire injects the connection string as an environment variable in a predictable format that works from C#, TypeScript, Python, Go, or any other language.
- A first-class C# client integration. C# apps can use the
Aspire.Azure.AI.Inferencepackage for dependency injection, health checks, and OpenTelemetry, all wired up from the same connection name.
How the pieces fit together
Section titled “How the pieces fit together”Azure AI Inference doesn’t have a dedicated Aspire hosting integration. Instead, you register an existing endpoint as a named connection string in your AppHost and reference it from consuming apps.
architecture-beta group apphost(server)[AppHost] group consumer(server)[Consuming app] service endpoint(internet)[Azure AI Inference endpoint] in apphost service client(iconoir:server-connection)[Client integration] in consumer service app(server)[App] in consumer endpoint:R --> L:client client:R --> L:app
Getting there is a two-step process: register the connection string in your AppHost, then connect to the endpoint from each app that needs it.
-
Register the Azure AI Inference connection in your AppHost
Section titled “Register the Azure AI Inference connection in your AppHost”Add a named connection string to your AppHost that points to your existing Azure AI Inference endpoint. Aspire injects the connection information into each consuming app that references it.
C# — AppHost.cs var builder = DistributedApplication.CreateBuilder(args);var aiInference = builder.AddConnectionString("ai-foundry");builder.AddProject<Projects.ExampleProject>("myapp").WithReference(aiInference);// After adding all resources, run the app...builder.Build().Run();Store the connection string in your AppHost’s configuration — typically in User Secrets during local development — under the
ConnectionStringskey:JSON — User Secrets {"ConnectionStrings": {"ai-foundry": "Endpoint=https://{endpoint}/;Key={apikey};DeploymentId={deploymentName}"}} -
Connect from your consuming app
Section titled “Connect from your consuming app”When you reference the connection from a consuming app, Aspire injects the connection string as an environment variable. See Connect to Azure AI Inference for the connection string format, per-language examples for C#, Go, Python, and TypeScript, and the full C# client integration reference.
Connect to Azure AI Inference