Edit

Quickstart: Deploy an Azure Developer CLI template

The Azure Developer CLI (azd) is an open-source command-line tool that replaces manual setup and configuration with consistent commands for building and deploying apps on Azure.

In this quickstart, you initialize a sample template and deploy it to Azure. You get a running app on Azure and a reusable local project that you can redeploy, customize, or remove when you're done.

Prerequisites

Before you begin, ensure you have the following prerequisites:

Note

Both samples build container images remotely in Azure. The Python sample doesn't require a local Python installation for deployment. The .NET sample still requires a local .NET SDK because its postprovision hook runs dotnet user-secrets set.

Understand azd templates

An azd template is a source repository that contains everything azd needs to work with an app. You can build your own template for a new or existing app, or start from an existing template and customize it. In this quickstart, you use a sample template so you can focus on the core azd workflow.

The following structure shows a simplified, top-level view of a typical template:

|-- src/         # Application source code
|-- infra/       # Azure resources defined as infrastructure as code
|-- azure.yaml   # azd project configuration
`-- .azure/      # Local environment settings

For the full breakdown of these files, see Explore and edit template files.

Initialize the template

From the parent directory where you want to store the project, select a sample repository and run azd init:

This option uses the hello-azd-python sample repository.

azd init --template hello-azd-python

azd supports many languages, frameworks, and containers. For more information, see Supported languages and environments.

When prompted, enter a short environment name, such as dev. After initialization completes, open the new project directory in your terminal before you continue.

The azd init command:

  • Downloads the selected template into the new project directory.
  • Initializes the new directory as an azd project.
  • Creates an environment that stores deployment settings, such as your Azure subscription and location, under the .azure directory.

The command doesn't create or deploy any Azure resources.

Sign in to Azure

Run the following command, and then sign in through the browser:

azd auth login

Provision and deploy the app resources

Run the following command:

azd up

When prompted, select the Azure subscription and location to use. The first deployment can take several minutes because azd up runs the complete deployment workflow:

  1. Provision: Creates the Azure resources that the template's infrastructure-as-code files define.
  2. Package: Builds and packages the app for deployment. The sample uses a remote container build, so the build runs in Azure.
  3. Deploy: Deploys the packaged app to the provisioned hosting resource.

The template defines supporting resources, such as managed identities, role assignments, and application settings, in the Bicep files under the infra directory and the azure.yaml project configuration, and azd deploys them together with the app. To learn more about these files, see Explore and edit template files.

You can run azd up again after changing the app or infrastructure. azd updates the existing environment instead of creating a separate deployment.

Explore the deployed app

When azd up finishes, it prints links to the provisioned resources and the running app in the command output.

  1. Select the Azure portal resource-group link in the output to view the resources that azd provisioned.

    Screenshot of an Azure resource group in the Azure portal that contains the resources azd provisioned for the sample app.

  2. Select the app endpoint link in the output to open the running app in a browser.

    Screenshot of the deployed sample app's home page running in a browser.

Make a change and redeploy

Optionally, make a small change to the sample app, and then redeploy just the app code with azd deploy.

  1. Open src/app/templates/home.html.
  2. Find the <h1>Hello, customized template!</h1> heading.
  3. Replace the heading text with <h1>Hello from your azd template!</h1>, and then save the file.

This change affects only the app source, so you don't need to reprovision the infrastructure. Redeploy the updated code:

azd deploy

The azd deploy command packages and deploys only the app code, while azd up runs the full provision, package, and deploy workflow. When the command finishes, open the app endpoint from the command output. The home page shows the updated heading.

Screenshot of the deployed hello-azd app with a customized heading.

Clean up resources

When you're finished, run the following command to delete the Azure resources and avoid ongoing charges:

azd down

Confirm the deletion when prompted. This command removes the resources that azd provisioned for the current environment but keeps the local project files.

Next step

Request help

For information on how to file a bug, request help, or propose a new feature for the Azure Developer CLI, please visit the troubleshooting and support page.