Navigating the complexities of cloud development often poses significant challenges, especially when creating and managing environments. The Azure Developer CLI azd emerges as a beacon of simplification, offering developers an intuitive pathway from code to cloud. This guide dives into the Azure Developer CLI, showcasing how it can simplify and accelerate your development workflow.
Azure Developer CLI (azd) Features
The Azure Developer CLI ( azd ) simplifies project setup, allowing you to easily scaffold projects and integrate essential cloud services. It ensures consistency between local and cloud environments, reducing deployment issues. Moreover, azd seamlessly integrates with popular development tools, enhancing productivity without disrupting your workflow.
Here's what azd brings to your development workflow:
Initialise: Create a new project based on a template using azd init
Up: Package the project, provision Azure resources, and deploy the app using azd up
Deploy: Continue developing and then deploy new features by running azd deploy
Provision: Create and update Azure resources using azd provision
Monitor: Monitor your application running in Azure using azd monitor
These developer-friendly commands map closely with your workflow and promote a focused and efficient coding experience, allowing you to dedicate more time to crafting unique code.
Templates
With a rich library of templates curated by Microsoft and the community, you will likely find a starting point that fits your project's needs. Embodying best practices, these templates ensure a rapid and reliable transition from code to cloud. For those with specific requirements or existing projects, azd offers excellent support and guidance on building your template, ensuring alignment with your team or organisation's needs.
Figure: Awesome Azure Developer CLI
View the full range of templates on awesome-azd and learn how to create a new template (or make your existing project compatible) on Microsoft Learn.
Development Containers
The templates include support for development containers that are fully featured development environments built on Docker containers. This makes it easy to set up consistent development environments across teams and can help avoid compatibility issues, offering a smoother development experience. Essentially, each template includes a tailed development environment with all the tools and runtimes you will need to work on that project.
Pipelines as Code
A default CI/CD pipeline as code supporting Azure DevOps or GitHub Actions is included in each template. Configure a CI/CD pipeline by running azd pipeline config. Once you have configured the pipeline, new changes to the project or infrastructure will be automatically deployed and provisioned anytime you push changes to your repository.
Infrastructure as Code
Infrastructure as code (IaC) using Bicep or Terraform is supported. The templates include core IaC modules representing an extensive range of Azure services, greatly reducing the effort required to create and maintain your infrastructure as code.
Benefits
Using azd saves time and effort in configuring cloud resources, ensuring consistency across environments, and increasing deployment reliability. It's flexible and supports various Azure services, making it adaptable to multiple project needs. The extensive range of templates effectively demonstrates a best practices approach to creating, provisioning, and deploying a comprehensive range of solutions to Azure.
Of course, you can do all of this without azd - but having a purpose-built CLI and a consistent set of conventions for developers to understand and follow is a much better approach. Doing it all myself, I can get from code to cloud in about 45 minutes with time left over for a coffee. With azd , I can do it in about 5 minutes while making a coffee.
Getting Started
The easiest way to start with azd would be to select an existing template. After that, it will only take a few commands to get a new app up and running on Azure. You can also build new templates or add support to an existing application.
This guide will use the Blazor on .NET 8 template I recently created and contributed to awesome-azd. This template provides a starter project for creating a Blazor web app using .NET 8, C# and a SQL database hosted on Azure.
Here's a high-level architecture diagram to illustrate the deployed Azure environment:
Figure: Blazor Azure Developer CLI template
You can see that this template utilises the following Azure resources:
Azure App Service to host the web app
Azure Monitor for monitoring and logging
Azure SQL Database for storage of app data
Azure Key Vault for securely storing app secrets
Let's deploy a new Blazor app to Azure! First, install azd using your preferred package manager. Then, create a new directory and run the following command:
The above command uses the azd template to create the project in your local
development environment. When you are ready to deploy the application to
Azure, run this command:
By running only two commands, you have successfully created, built, packaged, provisioned, and deployed a complete application that is now running on Azure. Review these next steps to see what else the Azure Developer CLI can do.
Conclusion
The Azure Developer CLI is a powerful ally in cloud development, designed to make your journey from code to cloud as straightforward as possible. Whether you're a seasoned expert or just getting started, azd will be a great addition to your stack, and since it's aligned closely to the typical developer workflow, it will help you stay productive and in the zone, focused on writing the code that only you can write. To learn more, check out the Build and deploy applications with the Azure Developer CLI course on Microsoft Learn. For more detailed information and guidance, refer to the official Microsoft documentation and
consider engaging with the azd community for support and to share insights.
Comments