PowerShell deployment of Riverbed SteelHead for Azure Resource Manager deployment model

I have been working on various cloud transformation projects using Riverbed SteelHead appliances for WAN optimisation.

Below is an example of using PowerShell to deploy a Riverbed SteelHead appliance into ARM:

# Tenant and Subscription details
$TenantId = ”
$SubscriptionId = ”
# Authenticate
Login-AzureRmAccount -TenantId $TenantId -SubscriptionId $SubscriptionId
Select-AzureRmSubscription -TenantId $TenantId -SubscriptionId $SubscriptionId

# Deployment time tracking
$StartTime = Get-Date

# Location
$Location = ‘North Europe’

# Resource Group for deployment
$ResourceGroupName = “RG-Contoso-Riverbed”

# Storage Account Name
$storageAccountResourceGroupName = “RG-Contoso-Storage”
$storageAccountName = “sacontoso”
$storageAccountContainerName = ‘vhds’

# VNET
$vnetName = “VN-Contoso”
$vnetResourceGroupName = “RG-Contoso-Networking”

# Riverbed Appliance Details
$Publisher = ‘riverbed’
$Offer = ‘riverbed-steelhead-9-2’
$Sku = ‘riverbed-steelhead-9-2’
$Version = ‘latest’
$DataStoreDiskSize = ‘460’

# Compute Variables
$vmName = ‘RiverbedSH01’
$vmSize = ‘Standard_D3_v2’
$vmIPAddress = ‘192.168.3.5’
$vmSubnet = ‘Riverbed’
$diskName = ‘_disk_0’
$Username = ‘placeholderusername’ # Username is not used; to log in to for the first time, use the default username of admin
$Password = ‘Password01’ # Password is not used; to log in to for the first time, use the default password of password

$storageAccount = Get-AzureRmStorageAccount -Name $storageAccountName -ResourceGroupName $storageAccountResourceGroupName

## Compute
$osDiskName = $vmName.ToLower() + “_disk_0”
$osDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + $storageAccountContainerName + “/” + $osDiskName.ToLower() + “.vhd”
$DataDiskName = $vmName.ToLower() + “_disk_1”
$DataDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + $storageAccountContainerName + “/” + $DataDiskName.ToLower() + “.vhd”

# NIC details
$Vnet = Get-AzureRmVirtualNetwork -Name $VnetName -ResourceGroupName $vnetResourceGroupName
$SubnetConfig = Get-AzureRmVirtualNetworkSubnetConfig -Name $vmSubnet -VirtualNetwork $Vnet
$nicname = “$($vmName)_nic1”
$nic1 = New-AzureRmNetworkInterface -Name $nicname -ResourceGroupName $ResourceGroupName -Location $Location `
-SubnetId $SubnetConfig.Id -PrivateIpAddress $vmIPAddress

# Create the VM Configuration
Write-Verbose ‘Creating VM Configuration’
$vm = New-AzureRmVMConfig -VMName $vmName -VMSize $vmSize
# Set root password
$cred = New-Object PSCredential $Username, ($Password | ConvertTo-SecureString -AsPlainText -Force)
$vm = Set-AzureRmVMOperatingSystem -VM $vm -Linux -ComputerName $vmName -Credential $cred -ErrorAction Stop
# Add primary network interface
$vm = Add-AzureRmVMNetworkInterface -VM $vm -Id $nic1.Id -ErrorAction Stop

# Use image from the Azure Marketplace
Write-Verbose ‘Using latest image from the Azure Marketplace’
$vm.Plan = @{‘Name’= $Sku; ‘Publisher’= $Publisher; ‘Product’ = $Offer}
$vm = Set-AzureRmVMSourceImage -VM $vm -PublisherName $Publisher -Skus $Sku -Offer $Offer -Version $Version -ErrorAction Stop
$vm = Set-AzureRmVMOSDisk -VM $vm -Name $osDiskName -VhdUri $osDiskUri -CreateOption fromImage
$vm = Add-AzureRmVMDataDisk -VM $vm -Name $DataDiskName -DiskSizeInGB $DataStoreDiskSize -VhdUri $DataDiskUri -Lun 0 -CreateOption FromImage

# Create the Appliance
Write-Verbose ‘Creating Appliance…’
$result = New-AzureRmVM -ResourceGroupName $ResourceGroupName -Location $Location -VM $vm

if($result.IsSuccessStatusCode -eq ‘True’) {
$result
Write-Output “Riverbed VM ‘$($vmName)’ was successfully deployed. Connect to the appliance at $($vmIPAddress) with the username: admin and password: password”
} else {
Write-Output “Deployment Failed. $($result.ReasonPhrase)”
}

# Display deployment time tracking
$EndTime = Get-Date
Write-Output “Deployment duration: $([math]::Round(($EndTime – $StartTime).TotalMinutes,1)) mins”

 

Enterprise Mobility Workshops - 24th November 2015 - London | 9:00am – 3:00pm

Leave a Reply

Your email address will not be published. Required fields are marked *