This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
This quickstart guides you through the easiest and fastest way to create and deploy a Python web and database solution to Azure. By following the instructions in this quickstart, you will:
azd
template based on the Python web framework, Azure database platform, and Azure web hosting platform you want to build on.azd
template to create a sample web app and database, and create and configure the necessary Azure resources, then deploy the sample web app to Azure.azd
command to redeploy.azd
command to clean up Azure resources.It should take less than 15 minutes to complete this tutorial. Upon completion, you can start modifying the new project with your custom code.
To learn more about theseazd
templates for Python web app development:
An Azure subscription -Create one for free
You must have the following installed on your local computer:
Choose anazd
template based on the Python web framework, Azure web hosting platform, and Azure database platform you want to build on.
Select a template name (first column) from the following list of templates in the following tables. You'll use the template name during theazd init
step in the next section.
Template | Web Framework | Database | Hosting Platform | GitHub Repo |
---|---|---|---|---|
azure-django-postgres-flexible-aca | Django | PostgreSQL Flexible Server | Azure Container Apps | repo |
azure-django-postgres-flexible-appservice | Django | PostgreSQL Flexible Server | Azure App Service | repo |
azure-django-cosmos-postgres-aca | Django | Cosmos DB (PostgreSQL Adapter) | Azure Container Apps | repo |
azure-django-cosmos-postgres-appservice | Django | Cosmos DB (PostgreSQL Adapter) | Azure App Service | repo |
azure-django-postgres-addon-aca | Django | Azure Container Apps PostgreSQL Add-on | Azure Container Apps | repo |
The GitHub repository (last column) is only provided for reference purposes. You should only clone the repository directly if you want to contribute changes to the template. Otherwise, follow the instructions in this quickstart to use theazd
CLI to interact with the template in a normal workflow.
Running anazd
template is the same across languages and frameworks. And, the same basic steps apply to all templates. The steps are:
At a terminal, navigate to a folder on your local computer where you typically store your local git repositories, then create a new folder namedazdtest. Then, change into that directory using thecd
command.
mkdir azdtestcd azdtest
Don't use Visual Studio Code's Terminal for this quickstart.
To set up the local development environment, enter the following commands in your terminal and answer any prompts:
azd init --template <template name>
Substitute<template name>
with one of the templates from thetables you selected in a previous step, such asazure-django-postgres-aca for example.
When prompted for an environment name, useazdtest or any othername. The environment name is used when naming Azure resource groups and resources. Forbest results, use a short name, lower case latters, no special characters.
To authenticateazd
to your Azure account, enter the following commands in your terminal and follow the prompt:
azd auth login
Follow the instructions when prompted to "Pick an account" or log into your Azure account. Onceyou have successfully authenticated, the following message is displayed in a web page:"Authentication complete. You can return to the application. Feel free to closethis browser tab."
When you close the tab, the shell displays the message:
Logged in to Azure.
Ensure that Docker Desktop is open and running in the background before attempting the next step.
To create the necessary Azure resources, enter the following commands in yourterminal and answer any prompts:
azd up
Important
Onceazd up
completes successfully, the sample web app will be available on the public internet and your Azure Subscription will begin accruing charges for all resources that are created. The creators of theazd
templates intentionally chose inexpensive tiers but not necessarilyfree tiers since free tiers often have restricted availability.
Follow the instructions when prompted to choose Azure Subscription to use for payment, thenselect an Azure location to use. Choose a region that is close to you geographically.
Executingazd up
could take several minutes since it's provisioning anddeploying multiple Azure services. As progress is displayed, watch for errors. If you see errors, try the following to fix the problem:
If you still have problems, see theTroubleshooting section at the bottom of this document.
Important
Once you have finished working with the sample web app, useazd down
to remove all of the services that were created byazd up
.
Whenazd up
completes successfully, the following output is displayed:
Copy the first URL after the word- Endpoint:
and paste it into the locationbar of a web browser to see the sample web app project running live in Azure.
Open a new tab in your web browser, copy the second URL from the previous step and paste it intothe location bar. The Azure portal displays all of the services in your newresource group that have been deployed to host the sample web app project.
The next step is to make a small change to the web app and then redeploy.
Open Visual Studio Code and open theazdtest folder created earlier.
This template is configured to optionally use Dev Containers. When you see the Dev Container notification appear in Visual Studio Code, select the "Reopen in Container" button.
Use Visual Studio Code's Explorer view to navigate tosrc/templates folder, and open theindex.html file. Locate the following line of code:
<h1>Welcome to ReleCloud</h1>
Change the text inside of the H1:
<h1>Welcome to ReleCloud - UPDATED</h1>
Save your changes.
To redeploy the app with your change, in your terminal run the following command:
azd deploy
Since you're using Dev Containers and are connected remotely into the container's shell, don't use Visual Studio Code's Terminal pane to runazd
commands.
Once the command completes, refresh your web browser to see the update. Depending on the web hosting platform being used, it could take several minutes before your changes are visible.
You're now ready to edit and delete files in the template. For more information, seeWhat can I edit or delete in the template?
Clean up the resources created by the template by running theazd down
command.
azd down
Theazd down
command deletes the Azure resources and the GitHub Actions workflow.When prompted, agree to deleting all resources associated with the resource group.
You may also delete theazdtest folder, or use it as the basis for your own application by modifying the files of the project.
If you see errors duringazd up
, try the following steps:
azd down
to remove any resources that may have been created. Alternatively, you can delete the resource group that was created in the Azure portal.See theFAQ for a more comprehensive list of possible issues and solutions.
azd
templatesazd
commands.azd
to set up a GitHub Actions CI/CD pipeline to redeploy on merge to main branchWas this page helpful?
Was this page helpful?