Skip to content

Azure Developer CLI – Command Line Tool for DevOps Experts

Photo: Max DeRoin:

Microsoft has published new CLI tool aimed for Azure developers called Azure Developer CLI. It is completely different tool than Azure CLI and its main focus is on DevOps. The CLI provides developer-friendly commands to handle key steps in your DevOps workflow. For example to setup new project, to deploy azure resources, to setup pipelines etc. It can be used through the Windows Terminal, Visual Studio Code, Visual Studio or Azure DevOps.

Installation

CLI is super simple to install. Just open Windows Terminal (or Powershell) and run

powershell -ex AllSigned -c "Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression"

After that restart terminal (to update PATH) and type in azd version to see that it response with current installed version. You can use the tool to work with existing project, but then you need to setup your project by using this guide.

What we can do with it?

The Azure Developer CLI can be used to create projects, configure pipelines, etc. I think the best way to describe it’s capabilities is to run it. For example, if you want to create new C# & Azure SQL project + Azure DevOps pipeline for it, you can do it by using following commands.

azd init
azd pipeline config --provider "azdo"

If you run azd init in empty folder, the CLI will ask you to select desired project template and after that it creates a good punch of files for you. For example the C# & Azure SQL project creates React frontend, C# TODO API backend, infra folder full of Bicep scripts etc. It is huge set of code files that you get with a simple command.

New C# & Azure SQL project creates following files.

The azd pipeline config command connects our newly created project into Azure DevOps or GitHub. I used provider azdo, which means that it connects into Azure DevOps. You can use the command to create new repository (or even completely new ADO project) and the build pipeline for it. The build pipeline will run automatically all those Bicep scripts and it will create Azure resources for the project.

Azure resources that are automatically created when you create pipeline

For example the Azure SQL that is created automatically is a General Purpose: Gen5, 2 vCores, which means that it costs somewhere around 350€/month to run. App Service plan is B1 which is quite cheap. The resources are created with weird looking generated names like sql-in4bkzxbecgq2…

The lucky thing is that you can delete all these resources by simply running azd down command in your own terminal. The command will ask that if you really want to delete 11 resources and after that they are all gone. It will even delete the resource group.

Summary

Azure Developer CLI is a powerful tool. Maybe a bit too powerful for newbie users, but for more proficient DevOps expert it can be a good tool. I think the true power of it, is to create init template for your existing project (or completely new simple template) and when the new developer arrives into your team, you can just tell him/her to run azd init, select your custom template and that’s it. Cool isn’t it?