As probably many of you know PowerShell is a very powerful tool for any programmer or IT administrator. Here is my scenario and basically what this post is about. Currently at my job we are testing using BizTalk Services in Windows Azure. Our problem is that we have to create all the necessary services and databases, which takes time, and then bring them back down as to make sure we do not incur any charges for them. This takes precious time and just gets monotonous after awhile.
The solution to this is PowerShell. With PowerShell and the Azure module we can pretty much script all of the common tasks of standing up VMs, ACSs, databases, virtual networks and services. So all we have to do before sitting down to test is double click a script file and away we go. The first part of this is simply setting up PowerShell to use the Azure module and getting your Publish Settings file into PowerShell the correct way. Some blogs will go through this but skip a major step. Now I will assume you have some idea of what PowerShell is and how to at least open it. Let's begin!
1. First we need to download Microsoft's Web Platform Installer. This is a great tool for getting tools to develop Microsoft Products and other products. The download is at http://www.microsoft.com/web/downloads/platform.aspx
2. After the Web Platform is installed you should be shown a screen similar to the following
3. In the top right hand corner search for Windows Azure PowerShell and add it to your downloads. Then click Install at the bottom right.
4. The installer will walk you through installation.
5. The installation not only includes the cmdlets but also a Windows Azure PowerShell program. This is nice because all the Azure cmdlets are loaded for you.
6. Now issue the command get-azurepublishsettingsfile. This will open up your browser and take you to a site to download your Azure subscription Publish Settings file. Log in with your Live ID and you will be prompted to download the file. I recommend saving it somewhere you will be able to find it later.
7. Next issue the command import-azurepublishsettingsfile -publishsettingsfile <fileLocation>. The file location is a string and will need to be in quotes. This will import all the setting for you subscription.
8. To test your settings issue the command get-azuresubscription. The output is pictured below.
9. In the above picture, the most import thing to check is the IsDefault setting towards the bottom of the output. Here is the one thing most blogs forget to have you check. If this is not set to true your commands will fail. The importing of your publish settings file should take care of this but when I first started with Azure PowerShell for some unknown reason this did not happen. It caused me a lot of headache until a co-worker pointed it out.
10. To set a subscription to default issue the command set-azuresubscription -subscriptionname <subscriptionname>. The subscriptionname argument is a string and should be quotes.
11. Issue the get-azuresubscription command again to make sure the subscription you want is the default.
Ok well this covers the Azure subscription setup. As soon as I have the whole script working for my project I will be sure to write about it. I hope you are successful with this and this opens new doors to your developing. Thanks!