Monday, October 21, 2013

Getting started with Microsoft Windows Azure PowerShell

The http://manage.windowsazure.com/ site is the web based interface that allows a user to manage an Azure environment.  There is also a PowerShell interface that you can use to manage your Azure environment and that is what this article will discuss.  This page, Windows Azure PowerShell, is a great starting resource.  There are a few steps that we need to go through in order to get everything ready for you to start working with Azure Virtual Machines. 


The How to install and configure Windows Azure PowerShell page provides the link that you will need to download Windows Azure PowerShell and connect to your subscription.  I have pulled those 2 sections into this post.

Install Windows Azure PowerShell on your computer

You can download and install the Windows Azure PowerShell module by running the Microsoft Web Platform Installer. When prompted, click Run. The Microsoft Web Platform Installer loads, with the Windows Azure PowerShell module available for installation. The Web Platform Installer installs all dependencies for the Windows Azure PowerShell cmdlets. Follow the prompts to complete the installation. 

On a Windows 8, you should see a Windows Azure PowerShell icon on your start screen.  If you are using the start button, you should have a Windows Azure group and within that group you should see Windows Azure PowerShell.  You should run as administrator when you start the Windows Azure PowerShell console through either one of those methods.

Connect to your subscription

Use of Windows Azure requires a subscription. If you don't have a subscription, see Get Started with Windows Azure.

The cmdlets require your subscription information so that it can be used to manage your services. This information is provided by downloading and then importing it for use by the cmdlets. The Windows Azure PowerShell module includes two cmdlets that help you perform these tasks:

  • The Get-AzurePublishSettingsFile cmdlet opens a web page on the [Windows Azure Management Portal]( from which you can download the subscription information. The information is contained in a .publishsettings file.
  • The Import-AzurePublishSettingsFile imports the .publishsettings file for use by the module. This file includes a management certificate that has security credentials.

Important
We recommend that you delete the publishing profile that you downloaded using Get-AzurePublishSettingsFileafter you import those settings. Because the management certificate includes security credentials, it should not be accessed by unauthorized users. If you need information about your subscriptions, you can get it from the Windows Azure Management Portal or the Microsoft Online Services Customer Portal.

  1. Sign in to the Windows Azure Management Portal using the credentials for your Windows Azure account.
  2. Open the Windows Azure PowerShell console, as instructed in How to: Install Windows Azure PowerShell.
  3. Type the following command:
    Get-AzurePublishSettingsFile
  4. When prompted, download and save the publishing profile and note the path and name of the .publishsettings file. This information is required when you run the Import-AzurePublishSettingsFile cmdlet to import the settings. The default location and file name format is:
    C:\Users\<UserProfile>\Desktop\[MySubscription-…]-downloadDate-credentials.publishsettings
  5. Type a command similar to the following, substituting your Windows account name and the path and file name for the placholders:
    Import-AzurePublishSettingsFile C:\Users\<UserProfile>\Downloads\<SubscriptionName>-credentials.publishsettings
  6. To view the subscription information, type:
    Get-AzureSubscription

Next: Create an Azure Affinity Group

According to Create an Affinity Group in the Management Portal, an Azure Affinity Group allows you to group your Windows Azure services to optimize performance. All services within an affinity group will be located in the same data center. An affinity group is required in order to create a virtual network.

  1. Open the Windows Azure PowerShell console as Administrator.
  2. Import your subscription information using this command:
    Import-AzurePublishSettingsFile "C:\Users\<UserProfile>\Downloads\<SubscriptionName>-credentials.publishsettings"

  3. Type the following command:
    New-AzureAffinityGroup -Name <affinitygroup> -Location "East US" -Label "East US" -Description "Affinity group for production applications in East US."

Finally: Create a Storage Account

According to How To Create a Storage Account, an Azure Storage Account is how you store files and data in the Blob, Table, and Queue services in Windows Azure.  You assign your storage account to a geographic region where you want to store the data.  A storage account can contain up to 100 TB of blob, table, and queue data. You can create up to five storage accounts for each Windows Azure subscription.

You can setup a storage account using the New-AzureStorageAccount cmdlet.  The following steps provide an example of how to do this.  The steps assume you are opening a new Windows Azure PowerShell console.  You can skip to step 3 if you already have a console window open.
Open the Windows Azure PowerShell console as Administrator.
  1. Import your subscription information using this command:
    Import-AzurePublishSettingsFile "C:\Users\<UserProfile>\Downloads\<SubscriptionName>-credentials.publishsettings"

  2. Type the following command:
    New-AzureStorageAccount -StorageAccountName <StorageAccountName> -AffinityGroup <affinitygroup> -Location "East US"
  3. Type the following command:
    New-AzureStorageAccount -StorageAccountName <StorageAccountName> -AffinityGroup <affinitygroup> -Location "East US"

No comments:

Post a Comment