Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save darrenjrobinson/6c5b7886244bf2ad356bd8a8abea6c0a to your computer and use it in GitHub Desktop.
Save darrenjrobinson/6c5b7886244bf2ad356bd8a8abea6c0a to your computer and use it in GitHub Desktop.
Create SailPoint IdentityNow CentOS Virtual Appliance in Azure based off converted VA VMWare Image and a Seed CentOS VM
# Resource Group of the Seed VM
$ResourceGroup = 'SeedVMResourceGroup'
# The Seed VM Name
$seedVM ='IdentityNowSeedVA1'
# Subnet the Seed VM is located in
$seedVMSubnet = 'default'
# OS Disk Container from copied CentOS VHD
[uri]$OSDiskURI = "https://storageaccount.blob.core.windows.net"
# URI for copied VHD which we'll attached as the OSDrive for the newVM
$NewVMDiskURI = "https://storageaccount.blob.core.windows.net/vhd/sailpoint-va-diskos.vhd"
# Import AzureRM Module
Import-Module AzureRM
# see if we already have a session. If we don't authN
if (!$AzureRMAccount.Context.Tenant) {
$AzureRMAccount = Add-AzureRmAccount
}
# Get Sub Info
$SubscriptionName = Get-AzureRmSubscription | sort SubscriptionName | Select SubscriptionName
$TenantId = $AzureRMAccount.Context.Tenant.TenantId
Select-AzureRmSubscription -TenantId $TenantId
# Get details about the Seed VM
$seedVM = get-azurermvm -ResourceGroupName $ResourceGroup -Name $seedVM
# Storage Account Stuff
# Get Storage URI from Seed VM
$storageAccountName = $OSDiskURI.Host.Split('.').Item(0)
# Get the StorageAccount from the Storagename and Resource Group
$storageAccount = Get-AzureRMStorageAccount -ResourceGroupName $ResourceGroup -Name $storageAccountName
$storageContext = (Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroup -Name $storageAccountName).Context
# Get all the other inputs for the new VM to clone from the Seed one
# VM Size (keep the same as the Seed one)
$VMSize = $seedVM.HardwareProfile.VmSize
# Name with 2 on the end
$VMName = $seedVM.Name.Replace("1","2")
# Location we'll keep the same
$location = $seedVM.Location
# Start the creation of the details for the New VM
$NewVM = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize
# OS Disk
Set-AzureRmVMOSDisk -VhdUri $NewVMDiskURI -VM $NewVM -Name "$($VMName)_OSDisk_1" -CreateOption attach -Linux -Caching ReadWrite
# Seed VM VirtNet
$VirtNet = Get-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroup
# Seed VM Subnet
$SubnetID = (Get-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $VirtNet -Name $seedVMSubnet).Id
# Create new Public IP and create a new NIC
$pip = New-AzureRmPublicIpAddress -Name "$VMName-IP" -ResourceGroupName $ResourceGroup -Location $location -AllocationMethod Dynamic
$nic = New-AzureRmNetworkInterface -Name "$VMName-NIC" -ResourceGroupName $ResourceGroup -Location $location -PublicIpAddressId $pip.Id -SubnetId $SubnetID
# Add the new NIC to the new VM
$NewVM = Add-AzureRmVMNetworkInterface -VM $NewVM -Id $nic.Id
# Tell Azure to make it happen
New-AzureRmVM -ResourceGroupName $ResourceGroup -Location $location -vm $NewVM -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment