Quantcast
Channel: sandrino.dev
Viewing all articles
Browse latest Browse all 77

Using the Windows Azure CLI on Windows and from within Visual Studio

$
0
0

Last month Glenn Block announced the new release of azure-cli (version 0.6.9). This release adds lots of new features to the CLI like managing Mobile Services, custom Web Site deployments … Next to the new features we also get an improved setup experience which makes it really easy to get started with the azure-cli. Let’s take a look…

Installing the CLI

Download for Windows: azure-cli 0.6.9


Just click Install, wait a few minutes and you’re done. Node.js, the required node modules and the CLI libraries have been installed on your machine and you can find everything in this directory: C:\Program Files (x86)\Microsoft SDKs\Windows Azure\CLI.

What I really like about this installer is that it takes care of everything. Even though Node.js is available on chocolatey, it’s so much better to have everything included in the installer.

Using the CLI

Now that everything has been installed you can start using the CLI. Before we proceed it’s also nice to know that the installer will add the C:\Program Files (x86)\Microsoft SDKs\Windows Azure\CLI\0.6.9\wbin directory to the PATH, which makes it really easy to start the CLI:

  • Open command prompt (Windows+R, cmd.exe)
  • Type azure and press Enter

Simply typing azure will show you the help page:

Before you can really start using the CLI you’ll need to do one last thing. In order for all of this to work you will need to import your Windows Azure subscriptions. And as it turns out this is also very easy to do with the CLI. First you simply call azure account download which will redirect you to the portal and allow you to download your publish settings. Then you can import these settings by calling azure account import <filename>.publishsettings

That’s it, the CLI has been setup. This means you can do most of the things you would do in the portal straight from the command line.

But now you’re probably thinking: “Why don’t you use PowerShell?”. Well I use both PowerShell and the CLI. When I need to automate things I create a PowerShell script once and I run it over and over again. PowerShell is great for automating things. But I find it to be less intuitive when you need to do things on the fly.

With the CLI it’s different. I can simply type azure to see which options are available. Then if I want to create a site I just type azure site to see my other options. Then I type azure site create and I simply fill in the required parameters to create the website and I’m done.

To summarize:

  • Windows Azure Powershell: I use it to automate stuff. Create a script once, run it many times (like a deployment).
  • azure-cli: I use it when I need to do things on the fly. No need to use the portal, I can do (almost) everything from the command line. And the help is so good that you don’t even need to know the syntax.

Cleaning things up

When you use the azure-cli on your machine you probably see this:

Because of the font and the font size it’s pretty ugly compared to how it looks like on Mac for example. But you can easily fix this by right clicking on the title bar and choosing Properties. By changing the font to Consolas (size = 14) and changing the Screen Buffer Size and Window Size things will look much better right away.

Running in Visual Studio

Yesterday my ex-colleague Maarten Balliauw also blogged about the azure-cli: Working with Windows Azure from within PhpStorm. In this post he explained how easy it is to use the azure-cli from within PhpStorm. That’s great if you’re using PhpStorm, but what if you’re using Visual Studio?

We’ll there’s a neat trick you can use. So the azure-cli is available in the PATH which means you can directly call it from the command line. But this also means you can directly call it from PowerShell. And do you know how you can run PowerShell in Visual Studio? … This is possible with the NuGet Package Manager Console (Tools > Library Package Manager > Package Manager Console):

And there you go! You can now manage your Windows Azure subscriptions without ever leaving Visual Studio.

Update: Maarten Balliauw shows how you can do the same with Windows Azure PowerShell

Enjoy!


Viewing all articles
Browse latest Browse all 77

Trending Articles