Slide 1

Slide 1 text

Building intelligent Python apps and microservices with Azure Container Apps Pamela Fox Anthony Chu

Slide 2

Slide 2 text

Azure Developers | Python Day

Slide 3

Slide 3 text

Azure Developers | Python Day Demo: "Chat with your data" app https://youtu.be/zPrwcrK3_9g

Slide 4

Slide 4 text

Azure Developers | Python Day RAG (Retrieval Augmented Generation) Large Language Model Document Search User question Benefit_Options-2.pdf: The plans also cover preventive care services such as mammograms, colonoscopies, and other cancer screenings. Northwind Health Plus offers more comprehensive coverage than Northwind Standard. This plan offers coverage for emergency services, both in-network and out-of-network, as well as mental health and substance abuse coverage. …. The Northwind Health Plus plan includes coverage for emergency services, mental health and substance abuse, out-of-network services, and a wider range of prescription drug coverage compared to the Northwind Standard plan. [Benefit_Options-2.pdf] What is included in my Northwind Health Plus plan that is not in standard?

Slide 5

Slide 5 text

Azure Developers | Python Day Azure Cognitive Search Azure architecture Azure OpenAI Azure Container Apps Azure Storage Azure Storage Form Recognizer Web Container Local Script Azure OpenAI Azure Cognitive Search Uploads PDF pages Extracts data from PDFs Computes embeddings Stores in index prepdocs.py

Slide 6

Slide 6 text

Azure Developers | Python Day Deployment with the Azure Developer CLI name: azure-search-openai-demo services: web: project: ./app/backend language: py host: containerapp hooks: prepackage: posix: shell: sh run: cd ../frontend;npm install;npm run build interactive: true continueOnError: false hooks: postprovision: posix: shell: sh run: ./scripts/prepdocs.sh interactive: true continueOnError: false >>> azd up https://github.com/Azure-Samples/azure-search-openai-demo/tree/aca aka.ms/aca-rag

Slide 7

Slide 7 text

Azure Developers | Python Day Why containerize? Dockerfile Create an environment that's replicable and portable (across local machine and prod, across clouds, across Azure services). FROM python:3.11-bullseye RUN python -m pip install --upgrade pip WORKDIR /demo-code COPY requirements.txt . RUN python -m pip install -r requirements.txt RUN python -m pip install gunicorn==21.2.0 COPY entrypoint.sh . RUN chmod +x entrypoint.sh COPY . . CMD bash -c ". entrypoint.sh" App Container App Container Docker engine Operating system

Slide 8

Slide 8 text

Azure Developers | Python Day Containers on Azure Azure Kubernetes Service Azure Container Apps Azure App Service BYOC Azure Functions (Preview) Flexibility PaaS features https://learn.microsoft.com/en-us/azure/container-apps/compare-options aka.ms/azure-containers

Slide 9

Slide 9 text

Azure Developers | Python Day Azure Container Apps ACA allows you to run multiple containers within a shared network. Features: • Pull images from any container registry (ACR, DockerHub, private, etc) • Consumption-based pricing • Auto-scaling, including scale-to-zero Container app 1 Revision 1 Revision 2 Replica Replica Container(s) Container(s) Container app 2 Revision 1 Revision 2 Replica Replica Container(s) Container(s) Azure Container Apps Environment

Slide 10

Slide 10 text

Azure Developers | Python Day Azure Container Apps: Auto-scaling Default scaling rule: When ACA detects ~10 concurrent requests per second, it creates a new instance. Or configure custom scale rules: Demo: https://youtu.be/N0QjLLQ8YWw

Slide 11

Slide 11 text

AUTO-SCALE CRITERIA Scaling is determined by the number of concurrent HTTP requests Jobs can be triggered on demand or on schedule Individual microservices can scale independently using any KEDA scale triggers Scaling is determined by the number of concurrent HTTP requests Scaling is determined by the number of messages in the queue Public API endpoints Background processing Microservices Web Apps Event-driven processing E.g., API app with HTTP requests split between two revisions of the app E.g., on-demand job running background processing to transform data in a database Microservices architecture with the option to integrate with Dapr E.g., Web app with custom domain, TLS certificates, and integrated authentication HTTP TRAFFIC REVISION 2 REVISION 1 80% 20% MICROSERVICE B MICROSERVICE C MICROSERVICE A E.g., Queue reader apps or jobs that process messages as they arrive in a queue

Slide 12

Slide 12 text

Azure Developers | Python Day Azure Cognitive Search Azure architecture for Uploader + Job Azure OpenAI Azure Container Apps Azure Storage Azure Storage Form Recognizer Web Container Local Script Azure OpenAI Azure Cognitive Search Uploads PDFs Extracts data from PDFs Computes embeddings Stores in index

Slide 13

Slide 13 text

Azure Developers | Python Day Azure Cognitive Search Azure architecture for Uploader + Job Azure OpenAI Azure Container Apps Azure Storage Azure Storage Form Recognizer Web Container Job Azure OpenAI Azure Cognitive Search Uploads PDFs Extracts data from PDFs Computes embeddings Stores in index Uploader UI

Slide 14

Slide 14 text

Azure Developers | Python Day Azure Container Apps — apps and jobs Apps Services that are continuously running, such as a web or API app, or app that constantly polls a queue for messages. Can receive HTTP or TCP connections Configure KEDA scale rules to add or remove replicas based on events. Jobs Tasks that run to completion, such as a data processing job or a job that processes a single message from a queue and exits. Trigger job executions manually/programmatically or on a schedule. Configure KEDA scale rules that are evaluated on regular intervals that trigger job executions. (event-driven jobs) Apps Jobs

Slide 15

Slide 15 text

Azure Developers | Python Day

Slide 16

Slide 16 text

Azure Developers | Python Day

Slide 17

Slide 17 text

Azure Developers | Python Day

Slide 18

Slide 18 text

Azure Developers | Python Day Learn more • Deploy a Flask/FastAPI to Azure Container Apps https://learn.microsoft.com/azure/developer/python/ tutorial-containerize-simple-web-app • Azd templates for Python + ACA https://azure.github.io/awesome- azd/?operator=AND&tags=python&tags=aca • Deploy "Chat on your data" app to azd: https://github.com/Azure-Samples/azure-search- openai-demo/tree/aca aka.ms/container-apps/github Got feedback for ACA team? Any questions (that ChatGPT can't answer)? aka.ms/aca-python-tutorial aka.ms/aca-python-azd aka.ms/aca-rag