# Building a streaming DeepSeek-R1 app on Azure

DevFeed: [Building a streaming DeepSeek-R1 app on Azure](<https://devfeed.tech/articles/building-a-streaming-deepseek-r1-app-on-azure-21729.md>)

Original publisher: [Read original article](<http://blog.pamelafox.org/2025/04/building-streaming-deepseek-r1-app-on.html>)

Author: Pamela Fox (noreply@blogger.com)

Published: 2025-04-02T18:15:00Z

Content type: tutorial

Language: en

Sources: [Pamela Fox](<https://devfeed.tech/sources/pamela-fox.md>)

Topics: [Artificial Intelligence](<https://devfeed.tech/topics/ai.md>), [deepseek](<https://devfeed.tech/topics/deepseek.md>), [Azure](<https://devfeed.tech/topics/azure.md>), [Deployment](<https://devfeed.tech/topics/deployment.md>), [Infrastructure as code](<https://devfeed.tech/topics/infrastructure-as-code.md>), [Python](<https://devfeed.tech/topics/python.md>), [Serverless](<https://devfeed.tech/topics/serverless.md>), [Inference](<https://devfeed.tech/topics/inference.md>)

Tags: [ai](<https://devfeed.tech/tags/ai.md>), [azure](<https://devfeed.tech/tags/azure.md>), [code](<https://devfeed.tech/tags/code.md>), [deepseek](<https://devfeed.tech/tags/deepseek.md>), [deployment](<https://devfeed.tech/tags/deployment.md>), [inference](<https://devfeed.tech/tags/inference.md>), [infrastructure-as-code](<https://devfeed.tech/tags/infrastructure-as-code.md>), [openai](<https://devfeed.tech/tags/openai.md>), [python](<https://devfeed.tech/tags/python.md>), [serverless](<https://devfeed.tech/tags/serverless.md>), [streaming](<https://devfeed.tech/tags/streaming.md>)

## AI overview

A tutorial on building a streaming DeepSeek-R1 application on Azure. It explains how to deploy the model as a serverless Azure AI Services resource, use keyless authentication, connect from Python, and present reasoning thoughts separately from the final answer.

## Source excerpt

Update: The approach has slightly changed (in a good way!). Read this Microsoft Learn article for an updated guide. This year, we're seeing the rise in "reasoning models", models that include an additional thinking process in order to generate their answer. Reasoning models can produce more accurate answers and can answer more complex questions. Some of those models, like o1 and o3, do the reasoning behind the scenes and only report how many tokens it took them (quite a few!). The DeepSeek-R1 model is interesting because it reveals its reasoning process along the way. When we can see the "thoughts" of a model, we can see how we might approach the question ourself in the future, and we can also get a better idea for how to get better answers from that model. We learn both how to think with the model, and how to think without it. So, if we want to build an app using a transparent reasoning model like DeepSeek-R1, we ideally want our app to have special handling for the thoughts, to make it clear to the user the difference between the reasoning and the answer itself. It's also very important for a user-facing app to stream the response, since otherwise a user will have to wait a very long time for both the reasoning and answer to come down the wire. Here's an app with streamed, collapsible thoughts: You can deploy that app yourself from github.com/Azure-Samples/deepseek-python today, or you can keep reading to see how it's built. Deploying DeepSeek-R1 on Azure We first deploy a DeepSeek-R1 model on Azure, using Bicep files (infrastructure-as-code) that provision a new Azure AI Services resource with the DeepSeek-R1 deployment. This deployment is what's called a "serverless model", so we only pay for what we use (as opposed to dedicated endpoints, where the pay is by hour). var aiServicesNameAndSubdomain = '${resourceToken}-aiservices' module aiServices 'br/public:avm/res/cognitive-services/account:0.7.2' = { name: 'deepseek' scope: resourceGroup params: { name: aiServi