Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Azure Developer CLI (azd) templates are regular code repositories that include sample application code, as well as azd configuration and infrastructure files. azd templates enable you to provision Azure resources, deploy your application, configure CI/CD pipelines, and more. You can either create your own templates, or get started using an existing template from a template repository such as Awesome AZD. In this article, you'll learn about the following concepts:
- How
azdtemplates enable you to provision and deploy app resources - How
azdtemplates are structured - How to decide whether to use an existing template or create one
- Explore existing
azdstarter templates
Why use Azure Developer CLI templates?
Developers often face many time consuming and challenging tasks when building properly architected and configured environment aware apps for the cloud. Teams must account for many different concerns in these environments, such as creating resources, applying configurations, setting up monitoring and logging, building CI/CD pipelines, and other tasks. azd templates reduce and streamline these responsibilities to help the developer on their journey from local development to a successfully deployed app on Azure.
For example, suppose you work at a company that operates a ticket management and customer communication platform, which requires the following Azure resources:
- Two App Service instances and an App Service Plan to host a front-end web app and back-end API
- A Key Vault instance to store secure app secrets
- A Cosmos DB database to permanently store app data
- Azure Monitor resources such as Application Insights dashboards
- A Service Bus to manage scalable messaging
- CI/CD pipelines to ensure changes can be reliably deployed through an automated, repeatable process.
Rather than starting from the ground up, with azd you can leverage existing architecture templates to provision and deploy most of the resources for you. The development team can then focus on building the app and making smaller adjustments to the template architecture.
How Azure Developer CLI templates work
Azure Developer CLI templates are designed to work with azd commands such as azd init and azd up. The templates include configuration and infrastructure-as-code (IaC) files that are used by the commands to perform tasks such as provisioning Azure resources and deploy the app code to them.
For example, a typical azd workflow using an existing template includes the following steps:
Run the
azd initcommand with the--templateparameter to clone an existing template down from GitHub.azd init --template todo-nodejs-mongoRun the
azd auth logincommand to authenticate to your Azure subscription.azd auth loginRun the
azd upcommand to provision and deploy the template resources to Azure. Theazd upcommand leverages the configuration and infrastructure-as-code (IaC) files in your template to provision Azure resources and deploy your application to those resources.azd upOnce your environment is set up in Azure, you can locally modify the application features or Azure resource templates and then run
azd upagain to provision your changes.
Explore Azure Developer CLI template structure
azd templates are standard code repositories with some additional assets included. All azd templates share a similar file structure based on azd conventions:
infrafolder - Contains all of the Bicep or Terraform infrastructure as code files for theazdtemplate.azdexecutes these files to create the Azure resources required to host your app.azure.yamlfile - A configuration file that maps source code folders in your project to Azure resources defined in theinfrafolder for deployment. For example, you might define an API service and a web front-end service in separate folders and map them to different Azure resources for deployment..azurefolder - Contains essential Azure configurations and environment variables, such as the location to deploy resources or other subscription information.srcfolder - Contains all of the deployable app source code. Someazdtemplates exclude thesrcfolder and only provide infrastructure assets so you can add your own application code.
For example, a common azd template might match the following folder structure:
azd templates also optionally include one or more of the following folders:
.githubfolder - Holds the CI/CD workflow files for GitHub Actions, the default CI/CD provider for azd..azdofolder - If you decide to use Azure Pipelines for CI/CD, define the workflow configuration files in this folder..devcontainerfolder - Allows you to set up a Dev Container environment for your application.
Start with an existing template or create your own
There are two main approaches to working with azd templates:
- Start with an existing
azdtemplate.- This is a good choice if you're just getting started with
azdor if you're looking for a template to build off of for a new app with a similar architecture and frameworks.
- This is a good choice if you're just getting started with
- Convert an existing project to an
azdtemplate.- This is a good choice when you already have an existing app but you want to make it compatible with
azdcapabilities.
- This is a good choice when you already have an existing app but you want to make it compatible with
The following sections provide more information on these two options.
Start with an existing template
A broad selection of azd templates is available on the awesome-azd template gallery. These templates provide infrastructure and application code for various development scenarios, language frameworks, and Azure services. If you find a template that aligns with your local application stack or desired architecture, you can extend and replace the template code with your own
For example, the following azd templates provide starting points for common app architectures and frameworks:
Create a new azd template for your app
You can also convert an existing app into an azd template to enhance the repository with provisioning and deployment capabilities. This approach allows for the most control and produces a reusable solution for future development work on the app. The high level steps to create your own template are as follows:
- Initialize the project template with
azd init. - Create the Bicep or Terraform infrastructure as code files in the
infrafolder. - Update the
azure.yamlfile to tie the app services together with the Azure resources. - Provision & deploy with
azd up.
The following resources provide more information about creating your own templates:
Guidelines for using azd templates
Please note that each template that you use with Azure Developer CLI is licensed by its respective owner (which may or may not be Microsoft) under the agreement which accompanies the template. It is your responsibility to determine what license applies to any template you choose to use.
Microsoft is not responsible for any non-Microsoft templates and does not screen these templates for security, privacy, compatibility, or performance issues. The templates you use with Azure Developer CLI, including those provided from Microsoft, are not supported by any Microsoft support program or service. Any Microsoft-provided templates are provided AS IS without warranty of any kind.