Learn Python with Talk Python's 270 hours of courses

Reinventing Azure's Python CLI

Episode #373, published Tue, Jul 12, 2022, recorded Thu, May 12, 2022

Deploying and managing your application after you create it can be a big challenge. Cloud platforms such as Azure have literally hundreds of services. Which ones should you choose? How do you link them together? In this episode, Anthony Shaw and Shayne Boyer share a new CLI tool and template they've created for jump starting you use of modern Python apps and deploying them to Azure. We're talking FastAPI, Beanie and MongoDB, async and await, Bicep DevOps, automated CI/CD pipelines and more. Plus we catch up on other Python work happening that Anthony is involved with. If you're interested in deploying or structuring modern Python apps, you'll find some interesting take aways from our conversation.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guests Background

Anthony Shaw is a longtime Python core contributor and advocate. He works at Microsoft, focusing on performance, security, and strengthening Python’s presence and capabilities in Azure. Anthony is known for his work on projects like the Performance Linter (perf-lint), Pidgin (a JIT exploration for Python), and many community efforts around modern Python.

Shayne Boyer leads an end-to-end developer experiences team for Azure inside Microsoft’s Developer Division. He concentrates on streamlining the process of taking applications from code to the cloud and making sure services like Azure Container Apps, Azure Functions, and more, are developer-friendly—especially for Python users.


What to Know If You're New to Python

If you’re just getting into Python and curious about deploying Python applications to the cloud, it might help to understand a few basics before digging into this episode’s references:

  • Environment Management: Knowing how Python virtual environments (e.g., venv, virtualenv, or tools like Poetry) organize dependencies will help you follow discussions around Docker and containerization.
  • FastAPI Basics: A modern, async-friendly web framework for Python. Familiarity with how APIs or web routes are structured in FastAPI helps.
  • Async and Await: Understanding Python’s asynchronous features is valuable, as these play a major role in frameworks like FastAPI and ORMs such as Beanie.

Key Points and Takeaways

  1. Reinventing the Developer Experience with a New Azure Dev CLI
    Microsoft has introduced a new CLI (often called AZD or “Azure Developer CLI”) that focuses on a streamlined developer experience specifically for coding and deploying apps, rather than only managing cloud resources. This command-line tool offers opinionated yet flexible scaffolding for modern Python web applications, hooking into services like Azure Container Apps, Key Vault, and Cosmos DB. It bridges the gap between “just code” and “production-ready infrastructure.” By emphasizing developer workflows, it allows teams to skip lengthy manual setup steps and jump right into coding and continuous delivery.

  2. Differentiating from the Existing Azure CLI
    While the original Azure CLI (written in Python) is well-known for managing Azure services (creation, scaling, monitoring), the new AZD CLI aims directly at the day-to-day flow of developers shipping code. Instead of focusing on the “ops” or infrastructure perspective, AZD helps you stand up Docker containers, connect them to a database, create CI/CD pipelines, and handle environment secrets. This separation allows dev teams to concentrate on shipping features rather than navigating 100+ Azure services individually.

  3. A Production-Level To-Do App Example
    Anthony, Shayne, and the team built a sample “To-Do” web application to demonstrate best practices and realistic configurations. It pairs a React front end with a FastAPI-based Python back end and uses MongoDB (via Cosmos DB’s Mongo API) plus Key Vault for secrets. This approach ensures that new developers see more than just “hello world”: they get a deeper look into a multi-container deployment with async data operations, CI/CD, testing, and environment management.

  4. FastAPI + Beanie + Cosmos DB for Modern Python
    The demo app shows how to leverage FastAPI’s async capabilities alongside Beanie, an async-friendly document mapper for MongoDB. By deploying to Azure’s Cosmos DB with the Mongo API, it keeps the local development experience with a “pure” MongoDB library (motor/Beanie) while letting production data live in a fully managed, scalable service. This synergy provides great performance, schema flexibility, and a modern Pythonic developer workflow.

  5. Bicep for Infrastructure as Code
    Instead of writing massive JSON-based ARM templates, Bicep offers a more concise and readable way to define Azure resources. This entire example uses Bicep to provision container apps, databases, and Key Vault. For devs who prefer Terraform or Pulumi, support is also planned. But Bicep excels at describing Azure resources without the overhead of raw JSON.

  6. Docker and Azure Container Apps
    By containerizing each layer of the app (front end, back end), Azure Container Apps handle scaling, SSL, and internal networking without requiring knowledge of Kubernetes configuration. The approach in the sample project packs React and FastAPI each in their own Docker image, which are then orchestrated by the AZD workflow. This stands in contrast to manually dealing with “bare” Kubernetes clusters, making dev onboarding simpler.

  7. Automated CI/CD with GitHub Actions
    Once the template is deployed, it sets up GitHub Actions pipelines that run tests, rebuild Docker images, and push them to the Azure Container Registry before rolling out the update. Developers can easily expand or tweak these workflows to suit multi-branch strategies, environment approvals, or advanced QA gates. Crucially, no separate “pipeline glue” is required to get started.

  8. OpenTelemetry and Monitoring
    The sample FastAPI app integrates OpenTelemetry for detailed, vendor-neutral traces of requests and performance metrics. These traces flow into Azure Monitor, which provides a single pane of glass for logs, alerts, and metrics across your containers and services. This ensures that, from day one, each container’s performance, error traces, and logs are captured for quick troubleshooting.

  9. Secrets Management with Azure Key Vault
    Rather than storing sensitive secrets in code or environment variables in plain text, Key Vault provides a centralized and secure store. The template automatically retrieves database connection strings, so you don’t have to reconfigure or redeploy your containers each time you rotate credentials. This also helps teams comply with security best practices by default.

  10. Planning for Growth and Swapping Components
    One major goal of these templates is flexibility: want to replace MongoDB with PostgreSQL or switch to a different authentication mechanism? You can edit the Bicep files and Python code rather than retool your entire deployment approach. This modular design acknowledges real-world apps often evolve in data backends, authentication, or front-end frameworks—so you can adapt as your needs change.


Interesting Quotes and Stories

  • On Azure's complexity for developers: “If you ask any web developer, ‘You’ve got code, how do you run this on the cloud?’, the answer is, ‘It depends, truly.’ That’s what we’re trying to fix with this new developer CLI.” — Shayne Boyer
  • Recalling Azure’s early days: “Back in 2008-ish, you’d just see three products and a slider bar for scaling. Now we have over 100 services with endless knobs, from CPU-based autoscaling to ephemeral container orchestration.” — Shayne Boyer
  • On bridging performance and features: “A simple code change can make a 60% difference. That’s why performance is important, even at scale on Azure.” — Anthony Shaw

Key Definitions and Terms

  • FastAPI: A modern, asynchronous Python web framework known for its speed and developer-friendly features like automatic docs generation.
  • Beanie: An async ODM (object-document mapper) built around Pydantic that provides a clean interface for MongoDB access in Python.
  • Bicep: A Domain Specific Language (DSL) simplifying Azure Resource Manager (ARM) template creation.
  • Azure Container Apps: A serverless container hosting environment where you can run multiple containers without directly managing Kubernetes.
  • OpenTelemetry: An open standard for collecting telemetry data (metrics, logs, traces) from distributed applications.

Learning Resources

Here are a few courses from Talk Python Training if you’d like structured, in-depth learning:


Overall Takeaway

Microsoft’s new Azure Developer CLI is a major step toward making Python cloud deployments simpler, more consistent, and production-ready out of the box. By providing a strong example project (FastAPI + Beanie + React + Bicep + Key Vault + Azure Container Apps) and automating the creation of CI/CD pipelines, secrets management, and monitoring, this CLI helps teams move fast without missing essential best practices. The result is a well-structured application template you can trust, adapt, and grow with minimal friction—letting you focus on what matters most: writing great Python code.

Links from the show

Anthony on Twitter: @anthonypjshaw
Shayne Boyer: @spboyer

Azure azd CLI tools: aka.ms
Beanie ODM: github.io
Pydantic: helpmanual.io
Give me back my monolith article: craigkerstiens.com
Python creator Guido van Rossum joins Microsoft: techcrunch.com
Making Python Faster with Guido and Mark episode: talkpython.fm
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon