FLPSUG Last meeting May 15th on “PowerShell Azure SQL Database”

FLPSUG Lync meeting Thursday May 15 2014 – Session: “PowerShell Working w/Microsoft Azure SQL Database” Speaker Maximo Trinidad (MVP) and Co-hosting Adnan Cartwright (MVP).

In this presentation I will be covering how to subscribe to Azure, setup PowerShell to connect to your subscription, use scripting to create a SQL Database Server and then use SMO with PowerShell push data to your SQL Azure tables. All this using PowerShell scripting plus showing some editor, scripting techniques, and tips to avoid issues when working and setting Azure with PowerShell. (live demo with Windows Azure). Thanks to Adnan for assisting me in this meeting.

Here’s the Powerpoint presentation, demo scripts, and link to the recorded video. The video is the full and unedited meeting: https://onedrive.live.com/redir?resid=7FD7082276C66197!31206&authkey=!AIbxWUhyiUth7Dg&ithint=file%2c.zip

Video link: http://youtu.be/9-fMxXY7DcQ

Co-host Adnan Cartwright link: http://www.fisg.us/

 

Quick Rundown – Microsoft Azure SQL Database Server and PowerShell

Azure SQL Database 
1. Web and Business editions are no longer available. Now there’s Basic, Standard, and Enterprise editions. (New)
2. There is a limit of 6 SQL Database Servers and up to 150 databases per subscription.
3. Create database from 1 GB up to 500GB of storage.
4. Database Throughput Unit(DTU) Service performance levels available: (New)

  • DTU Service Level:
    1  – Basic
    5 – S1
    25 – S2
    100 – P1
    200 – P2
    800 – P3

AzureSQLdb_DTU

For more information about Azure SQL Database Throughout Units Service, check out Scott Kline and Tobias Ternstrom on this link: http://channel9.msdn.com/Series/Windows-Azure-Storage-SQL-Database-Tutorials/Scott-Klein-Video-02

Quick tips when testing Azure SQL Database Server:
1. There’s no need to specify a storageaccount.
2. Start with “Basic” or “Standard” Service level.
3. Start with  1GB in size for testing.
4. Current Azure Portal version will create random database server names.

Observations on the “Preview” Azure Portal on Azure SQL Datbases:
1. It show the ability to group databases.
2. You can provide a SQL Database Server name (not random).

Upcoming Azure Portal (Preview)

Assign a Group and Name your Database Server
Assign a Group and Name your Database Server

Windows Management Framework 5.0 May 2014

On PowerShell  v5.0 Preview just released on May 14th.  This version has no problem with the Azure PowerShell cmdlets installation.

Blog: http://blogs.msdn.com/b/powershell/archive/2014/05/14/windows-management-framework-5-0-preview-may-2014-is-now-available.aspx

Download at: http://www.microsoft.com/en-us/download/details.aspx?id=42936

Azure PowerShell cmdlets updated

Azure PowerShell cmdlet was updated to version 0.8.2 on 05/12/2014 with 390 commands.AzurePosh_082_05152014

 

 

Latest Azure PowerShell version 0.8.0 has a preview module included

In my previous blog I mention the latest version has two module.  Well, I was wrong!  It’s important that you take the time to read the documentation and pay attention to what’s trending in the social network (such as twitter).  I did notice someone tweet about the new Azure module included in this last released: the “AzureResourceManager“.  And here’s where the fun begin.

There are three modules:

  1. Azure
  2. AzureProfile
  3. AzureResourceManager (Preview)

When executing the “Get-Module -ListAvailable” command you will notice that only 2 will show up: Azure and AzureProfile.

Azure_GetModule_02

This new module is a “PREVIEW“, and the documentation states “The Azure and Azure Resource Management modules are not designed to be used in the same Windows PowerShell session. To make it easy to switch between them, we have added a new cmdlet, Switch-AzureMode.”  Here’s the link to the documentation: http://msdn.microsoft.com/en-us/library/jj554330.aspx

This means that in order to use the new commands from the “AzureResourceManager” you need to run the “Switch-AzureMode” which will prevent you from using the Azure commands such as Get-AzureVM on the same PowerShell session.  Now, keep in mind that you can always open another session to keep working with the Azure module commands.

PowerShell with module Autoload On
PowerShell with module Autoload On

At the same time, If you need to use the command “Import-Module Azure“, you’ll notice that it will give an error telling that it can’t find the module. The trick here is, if you haven’t turned off the PowerShell Module Autoload option, the commands will be available.  Here’s a TechNet link on how to Turn-Off the PowerShell Autoload module (not recommended): http://blogs.technet.com/b/heyscriptingguy/archive/2013/02/20/powertip-turn-off-powershell-module-autoload.aspx

Import-Module Azure Error
Import-Module Azure Error

This is a bug that have been recently reported to the Microsoft Azure PowerShell team.  By default, PowerShell have the Module Autoload “ON” and you will be able to list all the Azure module commands.

PowerShell Autoload Azure commands
PowerShell Autoload Azure commands

So, you can still work with your Azure PowerShell commands and use the “Switch-AzureMode” on another session.

Use the "Switch-AzureMode" to preview the new AzureResourceManager cmdlets

Now you can continue to work with PowerShell Azure command and check out is new (Preview) module AzureResourceManager.

List of the Preview Module AzureResourceManager Cmdlets:Azure_ListPreview_06

Get-AzureLocation
Get-AzureResource
Get-AzureResourceGroup
Get-AzureResourceGroupDeployment
Get-AzureResourceGroupGalleryTemplate
Get-AzureResourceGroupLog
New-AzureResource
New-AzureResourceGroup
New-AzureResourceGroupDeployment
Remove-AzureResource
Remove-AzureResourceGroup
Save-AzureResourceGroupGalleryTemplate
Set-AzureResource
Stop-AzureResourceGroupDeployment
Test-AzureResourceGroupTemplate

Happy PowerShelling!

Find your Windows Azure PowerShell cmdlets version.

I don’t know if you notice when you go to download the latest version of Windows Azure PowerShell cmdlets, the version number is no longer displayed  on the Download page.  As you already know, Azure PowerShell commands gets updated sporadically, so you need to periodically check if there are new updates.  The download page was previously giving you the hint that there was an updated set of commands.

Last year Windows Azure Download page used to display the Azure PowerShell version which made it easy to check for the updated product:

Last year Windows Azure PowerShell version displayed
Last year Windows Azure PowerShell version displayed

Currently, as of February 2014, the version number is Gone!

Windows Azure PowerShell version is Gone!
Windows Azure PowerShell version is Gone!

Well,  here’s where PowerShell comes to the rescue.

The following quick code can query both you current version and check for the latest version available on the Internet. And, Yes! This code can be improved and taken a little further.  But, this will give you a head start.

Get-WindowsAzurePowerShellVersion function:WindowsAzurePowerShell_00

Copy/Paste code in PowerShell Console.

WindowsAzurePowerShell_01

View Results.

WindowsAzurePowerShell_02

Notice the first portion of the code uses WMIWin32_Product” Class which will take a few minutes to query your system for what’s installed.  By a strong recommendation from my MVP college Aleksandar Nikolic I change the code from using the WMI Win32_Product class and instead use the Get-Module Version property. This way it will effectively provide the needed information.

Then, for the “Microsoft.Web.PlatformInstaller” piece, if you previously installed Windows Azure PowerShell (or any of the other options), this assembly will be already in your system.

Note: My college Aleksandar Nikolic suggested not to use Win32_Product. BAD IDEA!!  Check the following links why not to use “Win32_Product“:

So, I corrected the code below following Alek suggestion.

If you want to further learn to further automate your Azure PowerShell download and installation, I recommend you to read the following article at the “PowerShell Magazine“: http://www.powershellmagazine.com/2014/02/27/using-powershell-and-web-platform-installer-to-install-azure-powershell-cmdlets/

Keep learning PowerShell!

Script Code:

[sourcecode language=”powershell”]
function Get-WindowsAzurePowerShellVersion
{
[CmdletBinding()]
Param ()

## – Section to query local system for Windows Azure PowerShell version already installed:
Write-Host “`r`nWindows Azure PowerShell Installed version: ” -ForegroundColor ‘Yellow’;
(Get-Module -ListAvailable | Where-Object{ $_.Name -eq ‘Azure’ }) `
| Select Version, Name, Author | Format-List;

## – Section to query web Platform installer for the latest available Windows Azure PowerShell version:
Write-Host “Windows Azure PowerShell available download version: ” -ForegroundColor ‘Green’;
[reflection.assembly]::LoadWithPartialName(“Microsoft.Web.PlatformInstaller”) | Out-Null;
$ProductManager = New-Object Microsoft.Web.PlatformInstaller.ProductManager;
$ProductManager.Load(); $ProductManager.Products `
| Where-object{
($_.Title -match “Windows Azure PowerShell”) `
-and ($_.Author -eq ‘Microsoft Corporation’)
} `
| Select-Object Version, Title, Published, Author | Format-List;
};

[/sourcecode]

PowerShell Working with Windows Azure VMs

This blog describe the essentials to get you started with building Windows Azure Virtual Machines.  This is slightly different from the previous blogs on Windows Azure SQL Database Servers.  As a refresher, in order to use PowerShell with Windows Azure, you need to create and install a Certificate key.  Then, it will enable PowerShell to work with Windows Azure commands.

Check the links provided for creating and uploading the Certificate Key on my previous blog: http://www.maxtblog.com/2013/08/getting-ready-with-windows-azure-sql-database-server-powershell-and-smo-part-12/

For most part, PowerShell can be use without going back the Azure web Portal.  Of course, the portal will be the first way to get you subscribe and start using Windows Azure.

WindowsAzurePortal01

Then, you can try using PowerShell to automate some of it tasks.  Don’t forget to download the PowerShell Azure Command from the following link:
http://www.windowsazure.com/en-us/downloads/

WindowsAzureDownloadPosh

So, after the Azure subscription has been activated and the certificate key uploaded to azure then PowerShell is all set.  Then, remember to check periodically for PowerShell Azure module updates.

When working with Powershell, loading the “Azure” module is not required. As you typed and execute the command, PowerShell by default will autoload the module.  This way there’s no need to use the “Import-Module xxxxx” command.

But, what’s the sequence for building an Azure VM using PowerShell?  I’m presenting the way I’ve done it.  This is just a suggestion.  Please feel free to use this as a possible guideline.

Here’s the order of the samples scripts I’m providing for building an Azure VM:

1. Create a new Storage Account.
2. Reconnect to Azure with the “Current Storage Account”.
3. Search and Select the Windows Azure pre-built VM.
4. Create the Azure VM.
5. Stopping the Azure VM.

The following scripts will get you started.  I recommend to read the help documentation for any of the PowerShell Azure commands shown in this blog.  It’s possible to find something that may be needed.

Create a new Storage Account

Before building a new Azure VM, an Storage Account need to be created first. One of the requirement for the account name is that it has to be in lowercase or the following message will be displayed:

[sourcecode language=”powershell”]
## – Create a Storage Container:
New-AzureStorageAccount `
-StorageAccountName "Testpitstorage01" `
-Label "TestPIT01" `
-Location "East US";
## – Error Message:
"New-AzureStorageAccount : "An exception occurred when calling the ServiceManagement API. HTTP Status Code: 400.
Service Management Error Code: BadRequest. Message: The name is not a valid storage account name. Storage account
names must be between 3 and 24 characters in length and use numbers and lower-case letters only.. Operation Tracking
ID: 983e38b290134b24a15b0ec46d89fc5a."
At line:1 char:1
+ New-AzureStorageAccount `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [New-AzureStorageAccount], ServiceManagementClientException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.StorageServices.NewAzureStorageAccou
ntCommand"
[/sourcecode]

When this command runs successfully, it will also create the both Primary and Secondary “Azure Storage Account” keys automatically.

WindowsAzureStorageAcct

At the same time, don’t forget to pick the Windows Azure location where the Storage Account is going to be create.  To list all locations available use the “Get-AzureLocation” command.

[sourcecode language=”powershell”]
## list of all Azure locations:
Get-AzureLocation
[/sourcecode]

WindowsAzureLocations

If there’s a need to list all Storage Account then use the “Get-AzureStorageAccount” command using the

[sourcecode language=”powershell”]
## list of all Azure Storage Account(s):
Get-AzureStorageAccount
[/sourcecode]

WindowsAzureStorageAcctlist

Reconnect to Azure with the “Current Storage Account”

After you got everything set for PowerShell to connect to Windows Azure then you need to create the “Storage Account “. There’s one noticeable difference between the Azure SQL and the Virtual machine.  Azure Virtual Machines need a  Storage Account.  This is done using the “Set-AzureSubscription” with the “-ContainerStorageAccount” parameter.

[sourcecode language=”powershell”]
Set-AzureSubscription `
-SubscriptionName "PutItTogetherAzure01" `
-SubscriptionId $subID -Certificate $myCert -CurrentStorageAccount ‘pitstorage01’;
[/sourcecode]

This section help set the Azure Subscription to the “Current Storage Account” which maybe optional.  I included this section because I started using my subscription to create only Azure SQL Database Server and I didn’t need any Storage Account.

Then, use the “Get-AzureSubscription” command to view all Azure Subscription values.

WindowsAzureSubscription

Search and Select the Windows Azure pre-built VM

For search the list of available Azure pre-built VM’s we use the “Get-AzureVMimage” command.  Here’s one creative approach for searching and select the VM imagename using the PowerShell V3 enhanced “Out-GridView” command with the ‘-PassThru’ parameter.  By creating a PowerShell variable “$x” we can store the value select from the “Out-GridView” and pass it to the “New-AzureQuickVM” command to build the VM.  Check the following example:

[sourcecode language=”powershell”]
## – Get and Select from the list of Azure VM Images:
$x = get-azurevmimage `
| Where-Object{$_.OS -match ‘WINDOWS’} `
| select label, imagename `
| Out-GridView -PassThru;
[/sourcecode]

This way we can pick and choose the image. Then, we use the variable with the member property that holds the name: $x.ImageName.   Remember to use the oneliner “$x | Get-Member” to view all variable member objects.

WindowsAzureGetMember

Create the Azure VM (Caution w/Service Name)

At the same time it will need to be provide a “Service Name”.  The “New-AzureQuickVM” help documentation mention that this is either a new one or existing one.  The following is an example of a new VM with a new ServiceName “MyPITcloudSvc2“:

[sourcecode language=”powershell”]
New-AzureQuickVM -Windows `
-AdminUsername ‘maxt’ -Password ‘$Mypwd01’ `
-ServiceName "MyPITcloudSvc2" -Name ‘Zeus01’ `
-ImageName $x.ImageName -Location "East US" `
-InstanceSize "Small";
[/sourcecode]

But, trying to use an existing ‘-ServiceName “MyPITcloudSvc1’ it gave the following error:

[sourcecode language=”powershell”]
## – Create a new ServiceName:
New-AzureService `
-ServiceName "MyPITcloudSvc1" `
-Label "MyPITcloudService" `
-Location "East US";

## – Create VM – It will create a new VM using an existing ServiceName:
## – (but it won’t work)
New-AzureQuickVM -Windows `
-AdminUsername ‘maxt’ -Password ‘$Mypwd01’ `
-ServiceName "MyPITcloudSvc1" -Name ‘Thor01’ `
-ImageName $x.ImageName
-Location "East US" `
-InstanceSize "Small";
## – Error Message:
">>New-AzureQuickVM : Service already exists, Location cannot be specified.
At line:1 char:1
+ New-AzureQuickVM -Windows `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : CloseError: (:) [New-AzureQuickVM], ApplicationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.IaaS.PersistentVMs.NewQuickVM"
[/sourcecode]

It’s possible this is a bug!  In the help documentation shows that either a new of existing ServiceName can be use:

-ServiceName <string>
Specifies the new or existing service name.

Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Accept wildcard characters?  false

So, for now just provide a non-existing Service Name for the new Azure VM.

WindowsAzureVms

Stopping the Azure VM

Now during your Azure Trial version, if you want to slow down the charges, then you can stop the active VM(s) by executing the following two ways:

1. Just using the “Stop-AzureVM” command.

[sourcecode language=”powershell”]
## – Stop VM Service(s):
Stop-AzureVM -ServiceName "MyPITcloudSvc2" -Name "Zeus01";
[/sourcecode]

2. Or, by piping the result of “Get-AzureVM” to “Stop-AzureVM” command.

[sourcecode language=”powershell”]
## – Get-AzureVM to pipe to Stop VM Service(s):
Get-AzureVM -ServiceName "MyPITcloudSvc2" -Name "Zeus01" `
| Stop-AzureVM;
[/sourcecode]

WindowsAzureStopVMs

Please keep in mind, that I haven’t discuss anything about the creating network items and/or affinity group to established connectivity between the Azure VMs.  At least this information will help in getting started.

I hope you all find this information useful!  There will be more coming soon.

Maximo Trinidad (MVP Windows PowerShell)
AKA Mr. PowerShell

QuickBlog: PowerShell Working with Windows Azure

As I venture into the realm of learning some PowerShell Automation in Windows Azure, its interesting the things you learn by just trying things out.  On my previuos blogs I mention, in order to use PowerShell, you need to create and install the certificate in the portal.  After that, you can use following commands to connect to Azure:

1. Import-Module Azure (*Optional – Autoload module is already set to “On”)
2. Set-AzureSubscription
3. Select-AzureSubscription

*Note: The ‘Import-Module Azure’ is more of a habit to do it.  Powershell 3.0/4.0 will search and automatically load a module the first time the cmdlet is been executed.

I just realized, after the Certificates Keys are installed in Azure, then you don’t need to execute the above commands Set-AzureSubscription and Select-AzureSubscription everytime I open the PowerShell Console.  Yes! I can start typing away and work with Azure commands.

Just try it!  If you already loaded the certificate keys, then Open a PowerShell console session and type “Get-AzureVMimage” to display the list of available Azure VM images:

WindowsAzrureValidAccess

If there’s no certificates installed, the you’ll get the following message: (on another PC)

WindowsAzureInvalidAccess

So that you know, when working with Windows Azure SQL Database Server(s), you don’t need to set up a Storage (Container) Account nor a Azure Cloud Service. Definitely you will need them when working with Windows Azure VM’s.

Next, I will be blogging on “PowerShell working with Windows Azure VM’s”.

That’s it for now,

Maximo Trinidad (MVP Windows PowerShell)
AKA Mr. PowerShell

Trap missing IP Address for SQL Database Server Firewall Rule

As I work on my second blog piece for the “Getting Ready with Windows Azure SQL Database Server PowerShell and SMO Part – 2/2“, I came up with a way to trap the current IP Address with PowerShell scripting.  When using the Portal for creating your SQL Database Server, it will ask you if you want to create the Firewall rule for you.  But you may want to automate this step using PowerShell and there’s no cmdlet to identify  the “current” IP Address of your Windows Azure connection.

Here’s an example of how the Portal message when is asking for the current IP Address to be added to the Firewall rules:

WindowsAzure2SQLdb

WindowsAzureMissingIPrule

I’m going right to the point with this small blog piece.  Basically,  I’m trapping the error message from the “New-AzureSqlDatabaseServerContext” which will fail to connect to your Azure SQL Database. Then, I’m dissecting the string to get the IP Address in error.  This is my way of trapping the IP address.  I know there might be a better way but for now it works.

I’m assuming the connection to Windows Azure has already been established and you are trying to use the “New-AzureSqlDatabaseServerContext” for connecting to the database.  If you haven’t created the rule then it won’t connect.

Note: Again, stay tuned for the next “Windows Azure SQL Database Server with PowerShell and SMO” blog part 2/2.

In the “New-AzureSqlDatabaseServerContext” I’m including the following two parameters: -ErrorAction ‘SilentlyContinue’ and -ErrorVariable errConn.  The “ErrorAction” results in not displaying the message.  The “ErrorVariable” define the PowerShell variable you will be storing the error message.  Notice the “ErrorVariable” name doesn’t include a “$” but its needed to view it (ie. $errConn).

[sourcecode language=”powershell”]
## – Storing error value:
$azConn = New-AzureSqlDatabaseServerContext  `
-ServerName $azServerName -Credential $azCredential `
-ErrorAction ‘SilentlyContinue’ -ErrorVariable errConn;
[/sourcecode]

The additional script code shown next will dissect the error message string from $errConn variable. It will take the string to create an array which will help identify the element position where the IP Address is stored.  In this case I’m assuming the error message will not change so the IP Address will always be located in the same place (Right!).  So the first time this code execute, it will find the IP Address in element #18.

Note: Please run first the code to identify the element position in case the “Culture” settings might change the location of the IP Address.

[sourcecode language=”powershell”]
## – Extract information from the ErrorVariable:
$getIPforFW = ([string] $ErrConn[0]).split(" ‘");

## – Display all variable stored in the array and identify where the IP address is stored:
$global:x = 0;
$getIPforFW | Select-Object @{label=’element’;Expression={"[$($Global:x)]"; $Global:x++}}, `
@{label = ‘Array’;Expression={[string] $($_);}};

## – Run once to confirm IP value is stored in element #18:
$getIPforFW[18].Trim();
[/sourcecode]

TrappingIPfromError

The rest is easy.  After extracting the IP value then you can use the “New-AzureSqlDatabaseServerFirewallRule” to create the firewall rule to include the current IP Address.

[sourcecode language=”powershell”]
## – Get current IP and added it to the SQL Database Firewall Rule:
New-AzureSqlDatabaseServerFirewallRule `
-ServerName "YourServerName" -RuleName "YourClientIPAddressRule" `
-StartIPAddress $getIPforFW[18].Trim() -EndIPAddress $getIPforFW[18].Trim();
[/sourcecode]

CreateFilewallfromIPfound

You can refine this script code to suit your need.  Just make sure to test a few times and verify you are getting the results you need.

Here’s a few more commands you could use to work with these rules.  The “Remove-AzureSqlDatabaseServerFirewallRule” to remove any existing rule(s) and the “Get-AzureSqlDatabaseServerFirewallRule” to list them all.

[sourcecode language=”powershell”]
## – List all your SQL Database Firewall Rules:
Get-AzureSqlDatabaseServerFirewallRule -ServerName "YourServerName";

## – Removing existing SQL Database Firewall Rule:
Remove-AzureSqlDatabaseServerFirewallRule `
-ServerName "YourServerName" -RuleName "YourClientIPAddressRule"";
[/sourcecode]

So, at the end, you will have the ability to automate the process without the need of using the Portal.  Most can be done using PowerShell scripting.

Stay tuned for more Windows Azure SQL Database Server.

That’s it for now!

Maximo Trinidad
Mr. PowerShell
🙂

Getting Ready with “Windows Azure SQL Database Server” PowerShell and SMO Part – 1/2

But before we start using PowerShell with “Windows Azure SQL Database Server” there a few more steps we need to be completed after you have started your subscription:

  1. Installing the most recent Windows PowerShell Azure module
  2. Rename Subscription name (Optional)
  3. Create the Certificate Key

These three items are important before connecting Windows Azure.  Then, will be using 3 PowerShell Azure cmdlets to connect to your subscription.

WindowsAzurePortal

Installing the recent PowerShell Azure module

I recently finish updating my new Windows 8.1 (booth-VHD) and loaded all my tools. So when I started to install Windows Azure PowerShell, I was expecting it won’t work with PowerShell 4.0.  Well, Good Job Microsoft!  It did installed and I got my Windows Azure PowerShell working with PowerShell 4.0.

The latest revision, dated July 31st 2013, will let you install Windows Azure PowerShell on you Windows 8.1 preview. This is exciting Good News.  A couple of months ago I try it on my Windows 8 but the installation failed because of PowerShell 3.0.

Before you start working with your Windows Azure subscription(s) with PowerShell, you need to download the most recent “Windows Azure PowerShell – July 31, 2013 edition”.  At the same time you may want to pick the “Windows Azure SDK for .NET”.  Go to the following link: http://www.windowsazure.com/EN-US/downloads/?sdk=net

Rename Subscription name

For renaming your subscription is better to use the Portal.  It make sense to change your subscription name from “Windows Azure MSDN – Visual Studio xxxxx” to something meaningful like, for example: “MyWindowsAzureSubscription30DaysLimit“.

Note: It is not required to change the subscription name.

If you want to change the name then there’s two ways to do it. Go to the Windows Azure main page and Click on “Account”: https://www.windowsazure.com/en-us/

WindowsAzureGoAcct

Or, at the Portal you can change it by clicking on the UserID, then “View my bill”.  This  will require to login again.

WindowsAzurePortalAcct

Finally, click on the “Edit subscription details” to change the name.

WindowsAzureAccessSubst

WindowsAzureEditSubst

WindowsAzureRenameSubst

For more information on the following link:

Creating the Certificate Key

Next, to create the Certificate key or you won’t be able to use PowerShell to connect to your Windows Azure. This is mandatory as is part of your Azure credentials.  You can find documentation on this topic at following links:

Tip: You need to have installed You could use Visual Studio in order to run the “Makecert.exe” command from the Visual Studio command shell. Or, download the “Windows Software Development Kit (SDK) for Windows 8” to get the “Makecert.exe”.

After creating the certificate key use PowerShell (non-Azure) commands to check its properties.  Here’s an example script lines to look at your existing Certificate keys:

Get-ChildItem cert:\\CurrentUser\My;

Or, to display more information:

Get-ChildItem cert:\\CurrentUser\My | Format-List;

PowerShellCertKey2

Finally, we need to upload the certificate key to Windows Azure.  On the Portal, go to the “Setting” option and add the Certificate key. Follow the screenshots:

WindowsAzureAddCertKey

WindowsAzureUpCert2

Now everything is set to use PowerShell with Windows Azure. There’s no need (for now) to use the Portal web GUI.

PowerShell connecting to Windows Azure

In the following script need to include the Certificate key information as this is part of the Windows Azure credential to connect to your subscription. This is why using the previously shown “Get-ChildItem cert:\\CurrentUser\My | Format-List;” one-liner help you understand about the Certificate(s) in your system.

First, need to prepare the Certificate key use in Windows Azure:

PSCercode

Here’s the list of the 3 Azure commands to connect to your Windows Azure:

PSAzureConnect

Note: Import-Module Azure is optional if working with PowerShell 3.0 or 4.0.

After verifying connectivity to Windows Azure was successful then we can process to build VM’s, SQL Databases, and more using PowerShell.

In my next blog I will be showing how to use PowerShell Azure commands to build a Windows Azure SQL Database, and use SMO with it.

Going Crazy with Windows Azure PowerShell tonight

You’re all invited to attend FLPSUG online meeting on “Windows Azure PowerShell cmdlet” with MS Windows Azure Evangelist – Scott Klein?.

To register go here: http://flpsugmay2013online.eventbrite.com/

Don’t miss it! It will be both fun and informative.

Here’s an example of what has been trending in twitter recently.  Please notice that’s all been on Windows Azure.

Some of yesrterday (05/20/2013) “Window Azure PowerShell” links:

Automating Windows Azure Infrastructure Services (IaaS) Deployment with PowerShell – See more at:
http://blogs.technet.com/b/yungchou/archive/2013/05/20/automating-windows-azure-infrastructure-services-iaas-deployment-with-powershell.aspx?utm_source=feedburner&utm_medium=twitter&utm_campaign=Feed%3A+YungChouOnHybridCloud+%28Yung+Chou+on+Hybrid+Cloud%29#sthash.ibQad0aX.dpuf

Overview of Microsoft #WindowsAzure #Powershell for automated #Cloud Services:
http://mountainss.wordpress.com/2013/05/20/overview-of-microsoft-windowsazure-powershell-for-automated-cloud-services/

PowerShell script to migrate SharePoint to Azure IaaS
http://spiffy.sg/it-pros/powshell-script-to-migrate-sharepoint-to-azure-iaas/

PowerShell script to get username and password for FTP from Microsoft Azure publish settings
http://karl-henrik.se/powershell-script-to-get-username/?utm_source=buffer&utm_medium=twitter&utm_campaign=Buffer&utm_content=buffer08a3d

Application Management-Example-Deploying a Service to Your Private Cloud (Part 1)
http://blogs.technet.com/b/privatecloud/archive/2013/04/03/application-management-example-deploying-a-service-to-your-private-cloud-part-1.aspx

Application Management-Example-Deploying a Service to Your Private Cloud (Part 2)
http://blogs.technet.com/b/privatecloud/archive/2013/04/05/application-management-example-deploying-a-service-to-your-private-cloud-part-2.aspx

Azure does Powershell too
http://www.scarydba.com/2013/05/20/azure-does-powershell-too/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+HomeOfTheScaryDba+%28Home+of+the+Scary+DBA%29

Additional MSDN videos at Channel 9: MSDN Channel 9
http://channel9.msdn.com/WindowsAzure

If you missed last week Microsoft Virtual Academy on “Windows Azure for IT Professionals Jump Start”  check the recorded videos:
https://www.microsoftvirtualacademy.com/liveevents/Windows-Azure-for-IT-Professionals?CR_CC=200206715

Sample VHD migration image PowerShell script by David Aiken:

Here’s some of my personal notes from the “Windows Azure for the IT Pro – Jump Start”

Great Sessions today under the Microsoft Virtual Academy O “Windows Azure for IT Professionals Jump Start” with David Tesar and David Aiken today.

Azure AD
1. Azure AD thru a Windows Azure VM spin off.
2. Run on Windows Azure IaaS.
3. Network Gateway need to be defined before building the VM.
4. DC VM need an addition drive to store all the NTDS databases files.
5. DC Wizard NTDS section the folders need to point to the additional VM drive (don’t pick C:\).
6. Under the directory service panel, need to add a new site to point to the Windows Azure AD site.

AD to Windows Azure AD – Synch
1. Cloud Only / No integration
2. Directory Synch – using member server (no on DC) and only one way (can’t go back). Use “DirSynch”
3. Directory and Single Sign-On

Migrating VM (VHD) to Window Azure
1. you can use a Disk2VHD. Hint: Have one network card and set to use DHCP.
2. It will copy VHD size type from Dynamic to Fixed Disk format.
3. Cloud act as a Networking boundaries.
4. Only VHD format allowed (no VHDX).
5. Don’t use Static IP Address and remove PowerShell remoting.
6. Changes to system configuration: memory, network adapters, etc.

And, there’s more I wasn’t able to attend.

Don’t be left out!  Learn PowerShell now.