Latest posts by Michael Pietroforte (see all)
- Results of the 4sysops member and author competition in 2018 - Tue, Jan 8 2019
- Why Microsoft is using Windows customers as guinea pigs - Reply to Tim Warner - Tue, Dec 18 2018
- PowerShell remoting with SSH public key authentication - Thu, May 3 2018
Azure and PowerShell ^
Beta versions of Azure PowerShell have been available for awhile. However, I find it amazing that version 1.0 came out only now, considering scripting in the cloud is much more important than it is in conventional IT. The cloud is all about elasticity and scalability, and this is only possible if you have good automation tools.
Automation in conventional IT can often be achieved by using third-party GUI tools that have been adapted to our LANs for decades and therefore leave little need for IT to build its own management tools.
However, the cloud is still new and the management tool industry adapts slowly to this new environment. Therefore, scripting in the cloud is often a must, in particular if you work with many interdependent objects. Azure and PowerShell are perfect matches. I dare say that PowerShell gives Azure a significant advantage over other cloud providers.
Thus, if you are a PowerShell geek, it is time to make friends with Microsoft’s cloud; if you work in Azure, learning PowerShell is mandatory. The release of version 1.0 indicates that Azure PowerShell is now ready for prime time.
As mentioned in the intro, you have three options to download and install Azure PowerShell. You can install it directly from your PowerShell console, you can use the Microsoft Web Platform Installer (WebPI), or you can deploy an MSI file in your network.
Uninstalling a previous version ^
If you installed a pre version of Azure PowerShell, you should first uninstall before you install version 1.0. If you installed the MSI, you can uninstall via Programs and Features in the Control Panel.
Uninstall Azure PowerShell through the Control Panel
If you installed with the Install-Module cmdlet, you can execute the following command:
Uninstall-Module –Name Azure* -Force
Installing with Install-Module ^
You probably know that, since PowerShell 5, you can easily install modules from the PowerShell Gallery with the help of the Install-Module cmdlet. This also works with Azure PowerShell. On a PowerShell console with administrator privileges, you can run the following commands:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
You only need to set the PowerShell execution policy if you haven’t done so before. Of course, Unrestricted instead of RemoteSigned works as well.
Installing Azure PowerShell
The next two commands download and install the Azure Resource Manager, a set of cloud tools that enable you to group interdependent cloud objects in resource collections to manage them as a single entity. The fourth command installs the common Azure cmdlets that you can use for typical management tasks such as creating new VMs.
At the end, we import all the modules. You only have to do this once. When you launch the PowerShell console next time, the modules will be loaded automatically. You can work with Azure PowerShell on the console or in PowerShell ISE.
Installing via WebPi and MSI ^
WebPi is a free tool that allows you to download and install web and cloud tools. The download tool also offers third-party tools such as Acronis Backup Cloud. Simply download WebPi, add it, and then install Microsoft Azure PowerShell from the Products tab.
Installing Azure PowerShell via WebPi
Alternatively, you can download a customized WebPi from the Azure download page that automatically starts the download of Azure PowerShell. On the web page, scroll down to Command-line tools / Windows PowerShell and click Install.
WebPi essentially just downloads an MSI file that you can get through the Direct Download Link in the tool after you click Items to be installed. The MSI files of the latest and previous versions can also be found at GitHub (scroll down to 1.0.1). If you intend to install Azure PowerShell on multiple machines, the MSI file is what you need.
Azure PowerShell direct download link to MSI
Differences between the install methods ^
The end result of installing Azure PowerShell via WebPi/MSI or Install-Module differs in several ways. The first two methods install a special Azure PowerShell console, which you can find by typing Azure in the Start search. You can work with Azure here right after the installation. If you want to use the normal PowerShell console or PowerShell ISE, you have to restart Windows first. This is not necessary if you install and download with Install-Module.
In addition, the Windows Azure Pack is installed, which you probably don’t need if you don’t intend to build a private cloud.
The Azure PowerShell console
Another difference is that the WebPi/MSI method installs the PowerShell modules to C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\, whereas Install-Module downloads them to C:\Program Files\WindowsPowerShell\Modules.
In practice, this shouldn’t make a difference. However, in troubleshooting cases, you might want to take into account the installation method you used. If you only want the minimal Azure PowerShell, I would use the Install-Module method.
Getting started with Azure PowerShell ^
To verify whether everything was installed correctly, you can sign in to Azure with the Add-AzureAccount cmdlet. You had better read the yellow text because it tells you something about the data Microsoft is collecting when you work with Azure. If you want to, you can turn off data collection. Note that you have to sign in only once this way because the cmdlet adds your Azure account to PowerShell.
Signing in to Azure with Add-AzureAccount
After you sign in, you can retrieve information about your Azure subscription with Get-AzureSubscription, and Get-AzureVM should list your virtual machines.
To get an overview of the available Azure cmdlets, you can use the Commands add-on pane.
Azure cmdlets in PowerShell ISE
In the next post, you'll get a few more tips of how to get started with Azure PowerShell.