Using the Azure CLI
Start course

Microsoft Azure is a collection of online services that organisations can use to build, host, and deliver applications. You don’t need to have your own data center because Azure runs in Microsoft’s data centers around the world. Not only does this approach save you the trouble of having to build and maintain your own on-premises IT infrastructure, but it can also save you money, because you only have to pay for what you use, and you can scale your Azure resources up and down as needed.

In this course, you will not only get an overview of the Azure services available in various categories, such as compute, storage, and networking, but you will also follow hands-on examples showing you how to create virtual machines and web apps using the Azure Portal and Azure command-line interface.

Learning Objectives

  • Describe some of the Azure services available in various categories
  • Use the Azure Portal
  • Use the Azure command line

Intended Audience

  • Anyone who would like to learn more about Azure


  • General technical knowledge
  • A Microsoft Azure account is recommended (sign up for a free trial at if you don’t have an account)


The GitHub repository for this course is at 



As you saw in the last demo, it's pretty easy to use the portal to create Azure resources but it's definitely not the most efficient way to do it because it requires a lot of pointing and clicking. An alternative is to use the command line. Although it can be more difficult since you have to know the exact names of all the command line options. Once you've mastered it, you can often create and manage resources much more quickly.

In this demo, I'm going to show you how to create a website using Azure App Service. Do you remember when I said that it's possible to use the command line without having to install anything on your desktop? Well, now that you're familiar with the portal, I'll show you how.

You see this icon to the right of the search bar? That's how you start something called the Cloud Shell. It's a very small virtual machine that you can use to run Azure commands. Click on it.

The first time you run Cloud Shell, it'll ask you for permission to create a storage account that the Cloud Shell VM can use. This isn't the first time I've used Cloud Shell, so my storage account is already set up. If you do get a dialogue box asking for permission, then click the option to create a storage account.

Cloud Shell supports both PowerShell and the Bash shell. You can switch between them using this menu. We're going to use the Bash Shell because the commands are simpler. If you're familiar with Linux commands, then it will be especially easy.

First, we need to download the files for a sample website. The command to do that is pretty long, so it's easiest to copy and paste it. You can get it from the read me file in the GitHub repository for this course. You can find a link to the repository at the bottom of the overview tab below this video.

Okay, copy this git clone command and paste it into the Cloud Shell window. It created a directory (which is the Linux term for folder) called html-docs-hello-world. Change into that directory with the cd command. I'm just going to use keyboard shortcuts to do the copying and pasting now. Now we can create an Azure App Service Web App using one command. Here it is.

It starts with az which means it's an Azure command. Then we say webapp which is the command for Azure App Service. Then up which means to create the web app using the code in the current directory. Then we say --location and the name of the region where we want to deploy the web app. I've set it to westus. Then we say --name and what we want to call the app. I'm calling it ca-example, but you'll have to call it something else because the name has to be unique among all of the out service names across all Azure customers. Then we say --html to tell it that we're creating a static HTML website. Now hit Enter.

That's all you have to do to create a website running on Azure App Service. It'll take a little while to deploy so I'll fast forward.

Okay, it's done. Now we can make sure the website is working by going to this URL. Remember to change this name to the one you used. Great, there's the sample website.

All right, now let's delete the web app, so we don't incur any more charges. In the VM demo, we deleted everything associated with the VM by deleting its resource group. We can do the same thing here but since we didn't specify a resource group name in the command, how do we do that? App Service created a resource group for us. You'll see it in the output from the command. Type az group delete --name then copy and paste the resource group name from here. Type "y".

While that's getting deleted, I should mention that there are many ways to deploy a web app. For example, both Visual Studio and Visual Studio Code can publish an app directly to Azure App Service without you needing to use the Azure portal or the command line. Once the app is deployed, though, you'll need to use the portal or the CLI to manage it.

And that's it for using the CLI.

About the Author
Learning Paths

Guy launched his first training website in 1995 and he's been helping people learn IT technologies ever since. He has been a sysadmin, instructor, sales engineer, IT manager, and entrepreneur. In his most recent venture, he founded and led a cloud-based training infrastructure company that provided virtual labs for some of the largest software vendors in the world. Guy’s passion is making complex technology easy to understand. His activities outside of work have included riding an elephant and skydiving (although not at the same time).

Covered Topics