An end-to-end walkthrough for deploying DeepSeek-V4 in Microsoft Foundry and consuming it from an ASP.NET Core MVC app with the OpenAI .NET SDK, covering both API-key and Entra ID keyless authentication plus DI and options validation. A practical starting point for teams that want a reasoning model to run inside their Azure estate.
Key points
- The model is deployed from the Foundry Model Catalog, where variants such as DeepSeek-V4-Pro, DeepSeek-V4-Flash and DeepSeek-V4.1-Flash and a TPM limit are selected.
- OpenAI (2.15.0+) and Azure.Identity (1.21.0+) NuGet packages are required, with the endpoint read from the AzureAI section of appsettings.json.
- OpenAIClient is configured either with an ApiKeyCredential or with a BearerTokenPolicy over DefaultAzureCredential for keyless Entra ID access.
- AzureAiOptions is validated at startup through ValidateDataAnnotations() and ValidateOnStart(), so bad configuration fails the app early.
- ChatClient.CompleteChatAsync runs with MaxOutputTokenCount = 2048 and Temperature = 0.7f, returning the reply text and TotalTokenCount.
- The controller passes reply, elapsed milliseconds and token usage to the view, which relies on an <output> element and an anti-forgery token.
Real-world use
- ASP.NET Core MVC apps that need a reasoning model hosted inside the Azure tenant without leaving the corporate network
- Production environments that avoid shipping API keys and rely on managed identity with keyless authentication
- Teams weighing a Flash variant with a TPM limit for high-throughput, cost-sensitive workloads
This summary was generated by the agent from the original post on C# Corner. The full text and all rights belong to its author and publisher. Go to original