Manage Azure with System Center 2012 R2 Virtual Machine Manager #SCVMM 2012 R2 #UR6

With Update Rollup 6 for System Center 2012 R2 Virtual Machine Manager (VMM 2012 R2 UR6) you have the option to manage Azure Virtual machines.

What you can do with this feature
If you already manage your on-premises virtual machines in Virtual Machine Manager, you can use this feature to perform some very basic actions on Azure instances without leaving the VMM console. For example, you can do the following:

  • Add or remove one or more Azure subscriptions by using the VMM console.
  • See a list view of details and statuses of all role instances in all deployments in that subscription.
  • Manually update the list of instances.
  • Perform the following basic actions on the instances:
    • Start
    • Stop
    • Shutdown
    • Restart
    • Connect through RDP

 

image

I tried to get this done all by PowerShell but it failed on me during lack of time to test this.

So basically you need a Azure Management Certificate

image

What you need to do is create a Certificate We use makecert and as you need the whole studio for just the makecert you can download the file from my onedrive http://1drv.ms/1GMrelk

What we need is just a display name , azure Subscription ID and a Certificate.

image

In my example you will need the Azure PowerShell Module.

You can download and install the Azure PowerShell modules by running the Microsoft Web Platform Installer. When prompted, click Run. The Web Platform Installer installs the Azure PowerShell modules and all dependencies. Follow the prompts to complete the installation.

First we make a self signed Certificate.

c:\makecert -sky exchange -r -n "CN=clustermvpazureFake" -pe -a sha1 -len 2048 -ss My "c:\clustermvpazureFake.cer"

Now that I have a Certificate I can upload this in my personal store.

Import-Certificate -FilePath "c:\clustermvpazureFake.cer" -CertStoreLocation ‘Cert:\currentuser\My’ -Verbose

image

sure you can do this manually but this is faster.

the next step is get my subscription ID

The basic steps to get my subscription is always the same get my publish file an list all my subscriptions

Import-Module Azure
Import-Module "C:\Program Files (x86)\Microsoft SDKs\Windows Azure\PowerShell\Azure\Azure.psd1"
Get-AzurePublishSettingsFile
Import-AzurePublishSettingsFile "c:\azureapril.publishsettings"
Get-AzureSubscription

Selecting my Subscription.

Select-AzureSubscription "MVP-Cluster"

 

Getting my ID in just some easy steps I get my ID

$getauzsub= Get-AzureSubscription | Where-Object {$_.Subscriptionname  -eq "MVP-Cluster"}
$azuresubid = $getauzsub.SubscriptionId
$azuresubid

This ID You can copy past this from the PowerShell into the GUI and selecting my certificate that we just created and imported in the store.

 

image

 

image

And As you will get a warning : The Subscription could not be authenticated by azure. Ensure that your Certificate and Subscription ID are valid.

image

We forgot to Upload the Certificate to Azure.

As there are many post on the web to upload the management certificate with PowerShell it all failed on me. So we upload the certificate by hand.

Set-AzureSubscription -SubscriptionName $azuresubname -SubscriptionId $azuresubid -Certificate $getCert

 

Uploading the just created Certificate to Azure.

In the Azure portal go to settings on the bottom and select management Certificates

image

And on the bottom there is an upload option you can select the Certificate and the subscription just make sure this will be the same as in the VMM console

image image

Now that the certificate is uploaded we go back to the VMM console and press finish and in a few seconds the Azure content is loaded in the VMM Console.

and Easy starting and stopping with the RDP is there real handy one step closer a a real hybrid Cloud.

image

 

Happy clustering

Robert Smit

follow me : @clusterMVP

https://robertsmit.wordpress.com

MVP Profile : http://mvp.microsoft.com

PowerShell Creating and Deploying Virtual Machines in VMM for Azure Pack #wapack #cloud #scvmm #Microsoft

Now that More and more customers are using SCVMM and with Clustering. I decided that I should post some helpful easy PowerShell scripts.

Ok I’m no Posh MVP the scripts are working and will get you started with things.

The First script I post is a Create a Virtual Machine with Powershell Based on a VHDX that is also used for VMM.

The Script can be found here  “Powershell Script to Create Hyper VM and copy syspreped VHDX to CSV “ it is still a GEN 1 VM!

https://gallery.technet.microsoft.com/Powershell-Script-to-b3ca124b

image

First we do set some variables for the script

# Variable
$vm= "MVPLOADTEST01"
$SMBShare= "SMBVM01"
$CPU= 2
$mem= 4GB
$HVcluster= "MVPTENANT001"
$VlanID= 1234
$HVswitch="Tenant Switch"

Next step is create a new VM and place this on the SMB share

# Create New VM
New-VM -Path \\MVPSofs001\$SMBShare\ -Name $vm -Generation 1 -newVHDPath "\\MVPSofs001\$SMBShare\$vm\Virtual Hard Disks\$VM.VHDX" -NewVHDSizeBytes 5GB -SwitchName $HVswitch -Memory 4GB

As the Disk is just a place holder and will be replaced by my template.

#VM adjustments Dynamic or Fixed
# Set-VM -Name $vm -DynamicMemory -MemoryMaximumBytes 4GB -MemoryMinimumBytes 4GB -MemoryStartupBytes 4GB -ProcessorCount 2
Set-VM -Name $vm -StaticMemory -MemoryStartupBytes "$mem" -ProcessorCount "$CPU"

Set a Vlan if needed else use the #

# Set VLAN
Set-VMNetworkAdapterVlan –VMName $vm -Access –VlanId $vlanid
#Get-VMNetworkAdapterVlan

Now that the VM is in place and connected I’ll replace the placeholder disk and use my own syspreped disk. from the SCVMM library

# Copy Template Disk
Copy-Item -Path "\\MVPSofs001\VMMLibrary\Templates\2012R2RU2.*" -Container -Destination "\\MVPSofs001\$SMBShare\$vm\Virtual Hard Disks\$vm _Disk_C.vhdx" -Recurse

# Remove Old Disk
Remove-VMHardDiskDrive -VMName $vm -ControllerType IDE -ControllerLocation 0 -ControllerNumber 0

# Add syspreped disk
Add-VMHardDiskDrive -VMName $vm -path "\\MVPSofs001\$SMBShare\$vm\Virtual Hard Disks\$vm _Disk_C.vhdx" -ControllerType IDE -ControllerLocation 0 -ControllerNumber 0

Or if you need More harddisks use this

# Add-VMHardDiskDrive -VMName $vm -path "\\MVPSofs001\$SMBShare\$vm\Virtual Hard Disks\$vm _Disk_D.vhdx" -ControllerType SCSI

# Delete Old Disk
Remove-Item -Path \\MVPSofs001\$SMBShare\$vm\Virtual Hard Disks\$vm.vhdx

#Add VM TO Cluster
Get-VM $vm | Add-VMToCluster -Cluster $HVcluster
Start-VM $vm

Easy Step by Step with a HA VM

Happy clustering

Robert Smit

@clusterMVP

https://robertsmit.wordpress.com

PowerShell Place custom VM into Windows Azure Pack Subscription #wapack #cloud #scvmm #Microsoft

During migrations there is always the trouble of all those settings and things to do before everything is running smoothly.

Well during my migration I needed to move several Machines to a private cloud subscription in Azure Pack.

As I’m not the Biggest Powershell Guru I like to keep things simple and I’m a big fan of the “ select Name “  and the  “ Out-GridView “

Options these options give you much more detail and make powershell a but more GUI ( don’t shoot )

#Set your SCVMM server and use -ForOnBehalfOf to make use of Service Provider Foundation.
Import-Module -Name virtualmachinemanager
$VMMSERVER = Get-SCVMMServer -ComputerName YOUR OWN VMM Server-ForOnBehalfOf

#Select WAP Cloud
$Cloud = Get-SCCloud -Name (Get-SCCloud | select Name | Out-GridView -Title "Select WAP Cloud" -PassThru).Name

#Select Select WAP User Subscription
$User = (Get-SCUserRole | Where-Object Cloud -Match $Cloud).Name | Out-GridView -PassThru -Title "Select WAP User Subscription"

# Show WAP Subscription User
$WAPUserrole = Get-SCUserRole | Where-Object Cloud -Match $Cloud | Where-Object Name -Like $User*
$WAPUserrole |ft name

# Select Single VM to WAP
$WAPVM = (Get-SCVirtualMachine ($Cloud | Get-SCVirtualMachine | select Name | Out-GridView -Title "Select Single VM to WAP" -PassThru).Name)

image

 

# show Selected VM to WAP Subscription
$WAPVM|ft name

#Place VM in WAP Subscription
Set-SCVirtualMachine -VM $WAPVM –UserRole $WAPUserrole –Owner $User

As there is a pick list there is no typo there when moving the VM

When Checking the Windows Azure Portal you will see after a refresh a VM that is migrated to Azure Pack.

 

image

Happy clustering

Robert Smit

@clusterMVP

https://robertsmit.wordpress.com