Hello Readers!

Here we are again, this time, with another example Runbook ready to use with Azure Automation!

This is my 3rd Azure Automation Runbook Contribution to Script Center under the Windows Azure – Automation Sub-Category (you can find my first two, here and here).

In fact, the Windows Azure – Automation Script Center example listing (from both MSFT and Community) continues to grow, so be sure to check back on a regular basis…Oh, and if you have ideas, please do let us know!

So, once again, no long post, no big explanation…just a link to the script, and the hope that you will find it interesting!


Script Center Contribution and Download

The download is the example: New-AzureVMEndpoint.ps1

Here is a brief description:

This Runbook creates a simple new Stand-Alone Azure Endpoint for a specified Virtual Machine based on the following input parameters:
       “Service Name", "VM Name", "Azure Endpoint Name",
        "Azure Endpoint Protocol", "Azure Endpoint Public Port", "Azure Endpoint Local Port"

A detained Description, full set of Requirements, and the actual Runbook Contents are available within the Script Center Contribution (not to mention, the actual download).

Download the Create New Azure VM Endpoint Example Runbook from Script Center here:

BC-DLButtonDark


A bit more about the Requirements…

This runbook sample leverages organization id credential based authentication (Azure AD; instead of the Connect-Azure Runbook). Before using this runbook, you must create an Azure Active Directory user and allow that user to manage the Azure subscription you want to work against. You must also place this user's username / password in an Azure Automation credential asset.

You can find more information on configuring Azure so that Azure Automation can manage your Azure subscription(s) here: http://aka.ms/Sspv1l 

It does leverage an Automation Asset for the required Azure AD Credential. This example uses the following call to get this credential from the Asset store:

Get-AutomationPSCredential -Name 'Azure AD Automation Account'

IMPORTANT      Usage of the Select-AzureSubscription command (not included in this example) will be needed as well right after connection if multiple Azure Subscriptions are associated with the provided organization id credential.

In addition, there may be some benefit to creating and leveraging Variable Assets to store some of the more static Azure Endpoint data.

This example runbook DOES NOT include example script to enable the following options for the Azure Endpoint: "Create a Load-Balanced Set", "Enable Direct Server Return".

Note     This Runbook example leverages InlineScript for the actual command invocation, as the necessary commands for Azure Endpoint creation leverages fairly complex pipeline execution, which is even more complex within the PowerShell Workflow context.


Example Runbook Usage

.EXAMPLE
    New-AzureVMEndpoint -ServiceName "MyService001" -VMName "MyVM001" `
        -AEName "Remote Desktop" -AEProtocol "TCP" `
       
-AEPublicPort 50025 -AELocalPort 3389       
       
.EXAMPLE
    New-AzureVMEndpoint -ServiceName "MyService001" -VMName "MyVM001" `
        -AEName "HTTPIn" -AEProtocol "TCP" -AEPublicPort 80 -AELocalPort 8080

.EXAMPLE
    $VMData = (
        @{
            ServiceName = "MyService001";
            VMName = "MyVM001";
            AEName = "My Endpoint";
            AEProtocol = "TCP"
            AEPublicPort = "50025";
            AELocalPort = "3389";
        },
    
        @{
            ServiceName = "MyService001";
            VMName = "MyVM002";
            AEName = "My Endpoint";
            AEProtocol = "TCP"
            AEPublicPort = "52153";
            AELocalPort = "5986";
        }
    )
   
    foreach ($VM in $VMData)
    {
        New-AzureVMEndpoint -ServiceName $VM.ServiceName -VMName $VM.VMName `
            -AEName $VM.AEName -AEProtocol $VM.AEProtocol `
            -AEPublicPort $VM.AEPublicPort -AELocalPort $VM.AELocalPort
    }

Note     These examples, as well as detailed Runbook Parameter descriptions are available within the comment header in the actual script as well.


Thanks for checking out my blog post! For more information, tips/tricks, and example solutions for Automation within System Center, Windows Azure Pack, Microsoft Azure, etc., be sure to check out the other blog posts from Building Clouds in the Automation Track!

enJOY!