I am a big time supporter of PowerShell and automation when it comes to working with Azure. In the recent past, I have seen SQL Developer ask me – how I can start playing with PowerShell for Azure. Though the concepts of powershell are awesome and I use them inside SQL Server, it is always difficult to get them ready on their machines. Often, the question is – where do I start? This blog will get you started with installing and configuring your machine with PS and Azure.
We can install Azure PowerShell modules by running the Microsoft Web Platform Installer. I have initiated the same and go through the initial wizard.
We can see the installation progress and once done, we will be presented with information to various components that get installed as part of this.
Now to use PowerShell with out Azure subscription, we need to link our account. If you are using an organizational account, then use the Add-AzureAccount command from the Windows Azure PowerShell command. This is useful ONLY when we are using Azure AD for our account. If you are not using Azure AD, then move to the next step.
In most cases, we are going to have standard Live Account associated with our Subscription. In this case, we need to download the certificate. To do this, invoke the command Get-AzurePublishSettingsFile command from the PowerShell command prompt.
We will be prompted with a save dialog and save this certificate file in a secure location. The next step is to Import the same so that we can start using PowerShell from our local machine to work with our subscription remotely.
For this we will invoke the – Import-AzurePublishSettingsFile “Path of certificate file”
Once this is done, we are connected and we will get an confirmation of our current subscription. being used.
We can quickly get details about our current subscription using the command Get-AzureSubscription as it outlines some of the information.
Now we are all set with are getting started with PowerShell and Azure. In future posts we will use this configuration as starting point to play around creating new VMs, Stopping VMs, Deleting VMs, Creating other services and much more. Stay tuned !!!