Muokkaa

Jaa


Quickstart: Deploy an Azure Developer CLI template

In this quickstart, you'll learn how to provision and deploy app resources to Azure using an Azure Developer CLI (azd) template and only a few azd commands. azd templates are standard code repositories that include your application source code, as well as azd configuration and infrastructure files to provision Azure resources. To learn more about azd templates and how they can accelerate your Azure provisioning and deployment process see What are Azure Developer CLI templates?.

Select and deploy the template

For the steps ahead, you'll use the following template to provision and deploy an app on Azure:

You can also select a template that matches your preferences from the Awesome AZD template gallery site. Regardless of which template you use, you'll end up with the template code in your development environment and be able to run commands to build, redeploy, and monitor the app in Azure.

Select your preferred environment to continue:

A local development environment is a great choice for traditional development workflows. You'll clone the template repository down onto your device and run commands against a local installation of azd.

Prerequisites

Initialize the project

  1. In File Explorer or a terminal, create a new empty directory, and change into it.

  2. Run the azd init command and specify the template you want to use as a parameter:

    azd init --template todo-nodejs-mongo
    
    azd init --template todo-python-mongo
    
    azd init --template todo-csharp-cosmos-sql
    
    azd init --template todo-java-mongo-aca
    

    Enter an environment name when prompted, such as azdquickstart, which sets a naming prefix for the resource group that will be created to hold the Azure resources. What is an Environment Name in azd?

    After you specify the environment, azd clones the template project to your machine and initializes the project.

Provision and deploy the app resources

  1. Run the azd auth login command and azd launches a browser for you to complete the sign-in process.

    azd auth login
    
  2. Run the azd up command:

    azd up
    
  3. Once you are signed-in to Azure, you will be prompted for the following information:

    Parameter Description
    Azure Location The Azure location where your resources will be deployed.
    Azure Subscription The Azure Subscription where your resources will be deployed.

    Select your desired values and press enter. The azd up command handles the following tasks for you using the template configuration and infrastructure files:

    • Creates and configures all necessary Azure resources (azd provision), including:
    • Access policies and roles for your account
    • Service-to-service communication with Managed Identities
    • Packages and deploys the code (azd deploy)

    When the azd up command completes successfully, the CLI displays two links to view resources created:

    • ToDo API app
    • ToDo web app frontend

    Screenshot of command output listing endpoint URLs.

    Note

    You can call azd up as many times as you like to both provision and deploy updates to your application. The deployment may fail due to a resource being undeployable in the selected region. Because this is a quick start, it is safe to delete the .azure directory and try azd up again. When asked, select a different region. In a more advanced scenario you could selectively edit files within the .azure directory to change the region.

Clean up resources

When you no longer need the resources created in this article, run the following command to power down the app:

azd down

If you want to redeploy to a different region, delete the .azure directory before running azd up again. In a more advanced scenario you could selectively edit files within the .azure directory to change the region.

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.

Next steps