Deploy your first template
The Azure Developer CLI (azd
) is built around developer-friendly commands and foundational application templates. The commands map to common development workflow tasks, such as provisioning or deploying resources. The templates include all of the necessary source code and configuration assets to complete these tasks. You can start using azd
by either working off of one of the existing and extensible sample templates or by building your own.
When getting started with azd
, it's often easiest to find an existing template that closely matches your desired environment architecture and use that as a starting point. You can explore a large set of available templates on the Awesome AZD site. You can also see a list of the available templates using the following command:
azd template list
For this example, you'll use the existing todo-nodejs-mongo template built around the Node.js and MongoDB stack. Even if you've never worked with these technologies, you can still complete the steps ahead, because azd
handles most of the work for you. This template creates a set of resources in Azure that are similar to those outlined in the sample scenario at the beginning of the module.
Note
The same azd
steps described in this module also apply to templates built around other languages or technologies, such as C# or Python.
Deploy the template
The most common starter workflow for azd
only requires a few commands. You'll explore other commands and options later in the module to complete additional tasks. To initialize and deploy an azd
template, complete the following steps:
Open a command prompt to an empty file directory.
Run the
azd init
command and specify the template you want to use as a parameter.azd
will clone the template in your local environment.azd init --template todo-nodejs-mongo
When the command prompts you for an environment name, enter
azdlearn
. The environment name influences the naming of certain resources in Azure.Run the
azd auth login
command to launch a browser window you can use to sign in to your Azure account.azd auth login
Run the
azd up
command to provision and deploy the template resources to Azure. When prompted, select the subscription and location you would like to deploy to.azd up
The azd up
command might take several minutes to run. Each template provisions different Azure resources and configurations, which means different templates require varying amounts of time to complete. You should see updates printed out in the console as the process runs. When it completes, a link to the deployed site will be displayed. You should also see a link to the deployment process in Azure, which you can visit to view additional deployment information.
The deployed application should look similar to the following screenshot:
You can also view the resources that were created in Azure by navigating to your resource group in the Azure portal:
In the main Azure portal search bar, search for the resource group
azd
created for you by typingrg-azdlearn
. By convention, the resource group will be the environment name you specified prefixed withrg-
.Select the resource group from the results to navigate to the overview page. You should see a list of the different resources that were created for you by
azd
.
Monitor the application
Many azd
templates also provision monitoring resources in Azure, such as Application Insights dashboards. These dashboards provide application health monitoring capabilities such as live metrics and logging. You can launch these dashboards using the azd monitor
command and one of the following flags:
--overview
- Launches the main dashboard.--live
- Launches the live metrics dashboard.--logs
- Launches the logging dashboard.
For example, run the following command in your terminal to open the live metrics dashboard:
azd monitor --live
The browser should launch and display a page similar to the following screenshot:
Congratulations! You provisioned, deployed and monitored your first app environment using azd
. Next, you'll learn how to update the template and deploy your changes.