Cloud Development with Azure Developer CLI (azd)
It has been a while since I blogged something tech on my website. I have been busy speaking, writing my book and organizing community events at Azure User Group Sweden that it took a while. But I am had some devoted time to write this blog post article to contribute to this year’s #AzureBackToSchool 2023
This is actually my second content of the September month for AzureBackToSchool event. If you missed my previous content, check out my recorded talk on YouTube, Jonah Andersson – Minimal APIs for .NET and Azure API Management which I contributed during my birthday this year.
I also wrote a short technical article about the topic of minimal APIs in .NET on my community contribution for Festive Tech Calendar organized by Cloud Family friends last year. If you have not read it, you can read it on Minimal Web APIs in .NET and Azure API Management Combined
Today, for 21st September, I am contributing this article about Azure Developer CLI (azd) not just for the Azure community around the globe, but also as a tribute and remembrance to my mother Joan, whose birthday is today. She died of breast cancer in 2004, and if she was still alive today, she could have been 58. Giving back to the community is also my gift to her today, even though she died not knowing I would turned out to be brave and courageous woman she wanted me to be.
I would like to give KUDOS and big thanks to fellow community leaders and friends in the community, Dwayne Natwick and Derek Smith, for organizing AzureBackToSchool every year. Also, thank you for letting me choose the dates for my contents. September month is special to me and AzureBackToSchool has been part of that special tradition with the community!
This event will also not be possible without the amazing contributions of other speakers and experts around the globe – sharing their content for the entire 2023!
Glad to be part of the speaker list and contributors this year!
NOTE: You may use the Table of Contents below to navigate into sections of this blog article.
Cloud Development with Azure Developer CLI (azd) - Table of Contents
Introduction to Developer-Centric Tools
Being a developer in the generation of artificial intelligence, machine learning, edge and cloud puttinging are fun because you have a vast variety of great things to learn. However, the opportunities of learning new things that adopts the evolving new technologies can be hard to catch up because of many factors. First of all, we have so little time, too much to do. If you are a developer today, you need to understand beyond what you wrote on your sourceode to create, build, debug and troubleshoot. This is when developer-centric culture and tools that helps create it comes into my mind.
If you are a beginner in software development, this term might be jargon for you. Developer-centric means creating a collaborative work culture that supports developers in delivering and shipping the result of their work faster and more efficiently. Creating a developer-centric culture in IT teams of course has its challenges but achievable depending on the organizational mindset and culture. The common challenges can be barriers to communication, resistance to change, lack of accountability, and other factors. Dev-centric practice in teams can be achieved in several ways, including creating a work culture and mindset involving developers in the application development lifecycle until the project is shipped to production.
If you are curious to learn more about improving the culture in development teams, I recommended one of my good reads that relates to developer-centric culture from MattersMost.com, Building a Developer-Centric Culture: How to transform your org into a place developers will love to work.
What is Azure Developer CLI (azd)?
As an open-source development tool, Azure Developer CLI (azd) is a developer-centric tool for those developers building applications with Azure. This tool enables developers to accelerate the time to get their apps from the local development environment to deployment to Azure. It is designed to help with developer productivity by saving time, enhancing the
The purpose of Azure Developer CLI (azd) as a tool is to help follow the recommended best practice yet provide accessible commands that are developer-friendly. These azd commands help map critical stages in a developer’s workflow when developing and working with the terminal, their preferred IDE, infrastructure as code, and CI/CD workflows.
An Azure Developer CLI template consists of the following:
- The infra folder is the infrastructure code that can be IaC files for Bicep and Terraform Infra-as-code application code files (Bicep or Terraform) required to provision Azure resources.
- A file named Azure.yaml that describes your application
- src folder can have your application-related source code files for your applications, both frontend and backend/APIs
- azd templates that are extensible and modifiable according to your particular use case
- Components with platform and programming languages Support of Azure Developer CLI (azd)
The azd is supported on multiple platforms such as Windows, Linux, Dev Containers, GitHub Codespaces, etc. There are different pros, cons, and support scopes for each; therefore, I recommended checking out the table found on Microsoft Learn: Supported Languages and Environments
The following shows how the structure of a trypical structure with different parts, based on the Awesome azd templates example:
Azure Developer CLI (azd) supports multiple infrastructures as code (IaC) providers, including:
• Bicep – a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. Learn the fundamentals of Bicep for deploying infrastructure on Azure.
• Hashicorp Terraform – is an open-source Iac tool for cloud infrastructure provisioning and management. Learn more about Terraform on Azure.
• By default, since azd is on Microsoft stack, it assumes Bicep as the default IaC provider. If your use case or project requires you to use Terraform, check out this Microsoft Learn guide about how you can use Terraform for Azure Developer CLI (azd)
Azure Developer CLI (azd) Templates
The azd has extensible blueprint templates containing everything you need to run an Azure application. Reusable infrastructure and proof-of-concept application code are included in these templates. You can design your project from a template closest to your infrastructure or use case. Perhaps, you can also create one.
Azure Developer CLI azd templates are sample repositories constructed using Azure Developer CLI conventions to utilize azd. The azd templates go beyond “Hello World!” to provision Azure resources and configure continuous integration and continuous delivery (CI/CD) pipelines, among other things. These templates are the basis for constructing and customizing your solutions.
Since I am a developer focused on .NET/C# with Microsoft Azure, I am currently using C# example templates as a learn by doing guide. You can use the filters on the website to choose your type of template, your can also use the azd command, azd template list, to list the available templates for you to get started with, as shown on my screenshot below, which was a list when you run the command using Powershell.
Getting Started with Azure Developer CLI (azd) and Initial Setup
There are several ways you can get started using the azd for cloud development with Azure. You can choose to work locally using your favorite IDE, you can also work directly on GitHub Codespaces, etc.
The following are a few examples how you can set using Powershall and GitHub Codespaces.
Locally - Using Windows Powershell
If you prefer to work locally on your computer, you can install the Azure Developer CLI (azd) using this Microsoft Learn guide or you can directly run the azd command winget install microsoft.azd.
It will ask you to agree to some agreement terms and just wait and follow the instructions until it is done.
Locally - Visual Studio Code Extension Azure Developer CLI (Preview)
Another easy way to get started is to install the VS Code Extension for this tool which you will find on Azure Developer CLI – Visual Studio Marketplace
Typical Use Case and Developing with Azure Developer CLI (azd)
The Azure Developer CLI is a good tool that creates collaboration between different teams. The tool creates a shared workspace for everyone to work together in one place. In a typical azd project, all source code for the application (frontend and backend), infrastructure as code (IaC), CI/CD workflows, and more.
You can start learning by doing local development using the azd templates available for the community, depending on your preferred programming language and technology stack you want to code with. Since I am a .NET developer, I started with the azd template, Azure-Samples/todo-csharp-sql-swa-func: A blueprint for getting a React web app with a C# API and a SQL database on Azure.
For this specific azd template, you would need some prerequisites such as installing Azure Developer CLI, at least .NET 6 SDK, latest Azure Function Core Tools, and with React frontend up, you need to have the Node.js with npm installed locally.
As for Azure resources for the cloud infrastructure, the architecture was designed as below.
Setting Up the Local Environment Environment for Azure Developer CLI (azd)
When you have done all of the prereqs, you may use the template and clone it into your own GitHub repository, which I did, and named it with a different repo project name to differentiate it as my dev project via the azd template.
During the initial steps, for example, you are asked to name your default environment locally when you do the azd init.
In my local hands-on, I decided to have “dev” as the name of my local environment setup on VSCode. It shows on the Environment list for your Workspace.
Once you have that setup and configured, you are ready to make changes or customize the blueprint template as you want, or you can directly deploy it to Azure if you want to understand the development workflow.
azd Workflow - The azd cli commands you need to know
Once you’ve installed Azure Developer CLI, you can run your app on Azure in just a few steps using the azd workflow commands. You can choose to use the Azure Developer CLI azd template or customize one.
The azd CLI commands for the workflow summarize the steps of coding, building, deploying, and monitoring what you built.
1. azd init – This azd command initializes the project with the template by running
2. azd up – After initializing, you would need to package and provision to deploy the app
3. azd deploy – You can use this azd command as you continuously iterate your code changes to the application code and deploy changes when needed
4. azd provision – Not required, but optional is to update your Azure resources by modifying the template’s Infrastructure as Code (IaC).
Monitoring Applications using azd
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 – Shows you the overview of App Insights dashboard integrated with your app/project
- –logs – It shows you the the dashboard for logs in your application
- –live – Gives you the live metrics dashboard which is useful if you want to troubleshoot issues real-time
Working with Azure Developer CLI (azd) on GitHub Codespaces
Aside from working locally with azd, you can also work with it using GitHub Codespaces or Dev Container. For example, in one of the azd templates, you can directly go to the repository for the Azure Developer CLI azd templates of your choice of programming language to get started or set up your azd project on GitHub Codespaces with the help of the examples.
You can open these example templates to understand how it is structured or use any of them as a starter template and then customize it with your own.
If you find any template interesting to share with the Azure community, you can suggest adding it. Check out the azd template contribution guide for more information.
If you want to see another example, there is a an example template available for C# with React as its web frontend. Link to that GitHub template repo example is on my GitHub link jonahandersson/azd-csharp-azure-template-example: Azure Developer CLI example for CSharp based on azd default templates (github.com)https://github.com/jonahandersson/azd-csharp-azure-template-example
Recommended Learning Resources
There are so much to learn and I hope by reading this blog article, the concepts have inspired you to try it out and learn by actually coding either with your own development projects or your real-life use cases in your IT projects at work.
The following are some of the getting started learning resources that I highly recommended checking out to learn more. What I wrote here is just a beginning of the interesting learning journey!
- Get started using Azure Developer CLI (preview) | Microsoft Learn
- Azure Developer CLI VS Code Extension – Visual Studio Marketplace
- Azure Developer CLI versioning and feature release strategy | Microsoft Learn
- Make your project compatible with Azure Developer CLI | Microsoft Learn
- Azure Developer CLI versioning and feature release strategy | Microsoft Learn
- Awesome AZD Templates | Awesome Azure Dev CLI
- Introducing the Azure Developer CLI (azd) | Azure Friday
- Microsoft Learn: Getting Started with Azure Developer CLI
About Author - Jonah Andersson