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 |
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.
An Azure subscription - Create one for free
You must have the following installed on your local computer:
- Azure Developer CLI
- Docker Desktop
- Visual Studio Code
- Dev Container Extension
- Visual Studio Code Bicep This extension helps you author Bicep syntax.
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.
-
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). -
In step 1 of the Quickstart article, you were instructed to create the azdtest folder. Open that folder in Visual Studio Code.
-
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
orazd 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.
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.
-
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
toS1
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.
-
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 duringazd init
. -
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 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.
- Learn more about the Python web
azd
templates - Learn more about the
azd
commands. - Learn what each of the folders and files in the project do and what you can edit or delete?
- Update the Bicep templates to add or remove Azure services. Don't know Bicep? Try this Learning Path: Fundamentals of Bicep
- Use
azd
to set up a GitHub Actions CI/CD pipeline to redeploy on merge to main branch - Set up monitoring so that you can Monitor your app using the Azure Developer CLI