Skip to content

Latest commit

 

History

History
108 lines (72 loc) · 6.65 KB

quickstart-python-scale-bicep.md

File metadata and controls

108 lines (72 loc) · 6.65 KB
title description ms.date ms.topic ms.custom
Scale your azd Python web app with Bicep
Quickstart article featuring the modification of Bicep files and using azd provision to scale your azd Python web app.
3/20/2025
conceptual
devx-track-python, devx-track-bicep, devx-track-extended-azdevcli

Quickstart: Scaling services deployed with the azd Python web templates using Bicep

The Python web azd templates allow you to quickly create a new web application and deploy it to Azure. The azd templates were designed to use low-cost Azure service options. Undoubtedly, you'll want to adjust the service levels (or skus) for each of the services defined in the template for your scenario.

In this Quickstart, you'll update the appropriate bicep template files to scale up existing services and add new services to your deployment. Then, you'll run the azd provision command and view the change you made to the Azure deployment.

Prerequisites

An Azure subscription - Create one for free

You must have the following installed on your local computer:

Deploy a template

To begin, you need a working azd deployment. Once you have that in place, you're able to modify the Bicep files generated by the azd template.

  1. Follow steps 1 through 7 in the Quickstart article. In step 2, use the azure-django-postgres-flexible-appservice template. For your convenience, here's the entire sequence of commands to issue from the command line:

    mkdir azdtest
    cd azdtest
    azd init --template azure-django-postgres-flexible-appservice
    azd auth login
    azd up

    Once azd up finishes, open the Azure portal, navigate to the Azure App Service that was deployed in your new Resource Group and take note of the App Service pricing plan (see the App Service plan's Overview page, Essentials section, "Pricing plan" value).

  2. In step 1 of the Quickstart article, you were instructed to create the azdtest folder. Open that folder in Visual Studio Code.

  3. In the Explorer pane, navigate to the infra folder. Observe the subfolders and files in the infra folder.

    The main.bicep file orchestrates the creation of all the services deployed when performing an azd up or azd provision. It calls into other files, like db.bicep and web.bicep, which in turn call into files contained in the \core subfolder.

    The \core subfolder is a deeply nested folder structure containing bicep templates for many Azure services. Some of the files in the \core subfolder are referenced by the three top level bicep files (main.bicep, db.bicep and web.bicep) and some aren't used at all in this project.

Scale a service by modifying its Bicep properties

You can scale an existing resource in your deployment by changing its SKU. To demonstrate this, you'll change the App Service plan from the "Basic Service plan" (which is designed for apps with lower traffic requirements and don't need advanced auto scale and traffic management features) to the "Standard Service plan", which is designed for running production workloads.

Note

Not all SKU changes can be made after the fact. Some research may be necessary to better understand your scaling options.

  1. Open the web.bicep file and locate the appService module definition. In particular, look for the property setting:

       sku: {
          name: 'B1'
       }

    Change the value from B1 to S1 as follows:

       sku: {
          name: 'S1'
       }

    [!IMPORTANT] As a result of this change, the price per hour will increase slightly. Details about the different service plans and their associated costs can be found on the App Service pricing page.

  2. Assuming you already have the application deployed in Azure, use the following command to deploy changes to the infrastructure while not redeploying the application code itself.

    azd provision

    You shouldn't be prompted for a location and subscription. Those values are saved in the .azure<environment-name>.env file where <environment-name> is the environment name you provided during azd init.

  3. When azd provision is complete, confirm your web application still works. Also find the App Service Plan for your Resource Group and confirm that the Pricing Plan is set to the Standard Service Plan (S1).

This concludes the Quickstart, however there are many Azure services that can help you build more scalable and production-ready applications. A great place to start would be to learn about Azure API Management, Azure Front Door, Azure CDN, and Azure Virtual Network, to name a few.

Clean up resources

Clean up the resources created by the template by running the azd down command.

azd down

The azd down command deletes the Azure resources and the GitHub Actions workflow. When prompted, agree to deleting all resources associated with the resource group.

You can also delete the azdtest folder, or use it as the basis for your own application by modifying the files of the project.

Related Content