Azure Automation and Using Hybrid workers runbook on vSphere

During the day I have been digging into the Microsoft Operations Management Suite which is a collection of cloud services that you can get for a quite reasonable price.

The different services included is Log Analytics, Security, Automation, Availability.

I have registered my on premise Windows Servers in the log analyzer and started uploading logs getting a nice overview with several out of the box solutions that will give you a heads up on areas in your environment that needs attention…

Screen Shot 2015-08-25 at 15.19.37

 

So how about the automation? I have already been using the automaton for different services within Azure but in this case I wanted to see how I could utilize the Hybrid worker and the VMware environment residing there.

With the release of VMware PowerCLI 6 some of the stack are remade as PowerShell Modules.

So if I configure a hybrid worker on premise with the PowerCLI installed I can then utilize that in a runbook that as an example takes an input variable VMName and restarts the VM (in this case I do it without being nice and asking for a shutdown but just pulling the plug)

Screen Shot 2015-08-25 at 16.05.59

And here is the runbook:

Screen Shot 2015-08-25 at 16.02.38

And here I start the runbook with the variable,

Screen Shot 2015-08-25 at 15.51.25

And as you can see in the vSphere Client my VM winrecover restarts

Screen Shot 2015-08-25 at 15.55.19

This can of course be made a bit more complex and also as you can see in the Azure automation view, scheduled. So if you have something that needs to be automated at 11 PM every night within your VMware vSphere environment it can be done by Azure Automation and Hybrid workers..

 

TechDays Session: Managing your Azure workloads with Chef and PS DSC

Are you possibly going to the TechDays Sweden this autumn ? Me self and my friend and former colleague Fredrik Nilsson will have a session on this conference about automation and how to use Chef and PowerShell DSC for your deployment.

Screen Shot 2015-06-24 at 10.20.32
This session will focus on how Chef, a systems and cloud infrastructure automation framework, can manage both Windows and Linux workloads on Azure or any physical, virtual location no matter the size of the infrastructure easily.

We will also look at how Chef can interact with PowerShell Desired State Configuration to deliver a consistent and compliant infrastructure. In this session you will learn the basic paradigms of Chef, launching VM instances and deploying applications to these instances. It is DevOps times now with a faster and agile world where the IT-Dinosaurs will have to watch out! 

 

My Theater Community Session on Ignite – be there or …

Today I was browsing the session catalog on myIgnite and could see that my session “PowerShell Community Jewels” was now added to the list!

Screen Shot 2015-04-22 at 09.21.40

So if you will be going to Chicago and also attending the Microsoft Ignite conference I would love to see you on the Lounge B Theater on Tuesday!

Me self and The Swedish Chef will be there and maybe just maybe there will be a possibility for you to take a selfie with the Chef after the session!

10271304_745037768850455_7817596746289511557_o

(Last year at Teched Houston with Mr PowerShell himself)

 

Using PowerShell to download Teched Europe 2014 content

I have spent the evening exploring how to create a script to download the content from Teched with powerpoints and videos,

As some of you that follow me on twitter and other social media knows, I will be going to MVP summit in Redmond and the flight leaves early saturday morning and I wanted to be able to get the most important content from Channel 9.

My former colleague Tim has made a GUI session downloader and that is nice, but I wanted one with PowerShell and of course where I could select a category and in my case the CDP is most interesting.

I have borrowed some code to make the folders from Peter Schmidt, but went for the Invoke-RestMethod and also using BITS as the transfer engine.

It is just a simple script but still powerful, I check if the folder is already created and also if the files have been downloaded which means that I do not download the files again when new content has been added :-)

As you can see on the screendump I use switches for the different choices, so to download two different  you can use -CDP -WIN,

Updated 10 Nov: I have got an tip from Irwin to add info in the BITS transfer so you can see which PPT or Video that is currently downloading and updated the script with that :-)

Screen Shot 2014-11-10 at 20.50.25

 

The script is also on the Script Gallery at this link and please go in and vote if you like it.

Please also comment if you have ideas of improvement,  I have downloaded only -CDP as that one was my primary object for filling my HDD for the 10 hour flight over the atlantic and as I am a Hyper-V MVP with cloud and datacenter as a main interest :-) but you can choose if you want -All or just a couple of the different categories!

Azure Automation and Runbook Gallery generally available

Today as the Teched Europe kicks off with the Keynote there where several new announcements and one was that Azure Automation and the Runbook gallery now are General Available.

If you have not tried the Automation during the preview then you now can create a Automation account from the portal and start playing!

Screen Shot 2014-10-28 at 15.11.55

Click on create and name it something smart and to what subscription it should be part of, right now not all regions in azure can be used for the automation accounts. The following regions can be chosed:

  • East US
  • South east Asia
  • West Europe
Screen Shot 2014-10-28 at 15.11.04

When you have an account you can see the first page where some good links reside for you to dig into and learn more about the Azure Automation:

Screen Shot 2014-10-28 at 15.12.27

When you want to create your first Runbook, Microsoft has the Runbook Gallery that you can use to get speed in the automation process as there are several scripts that can help you get started, maybe there is already a script that fits or maybe just need a small customization to get it to do exactly what you want!

Screen Shot 2014-10-28 at 17.36.27

Out of the box you get one module in each Automation account and that is the Azure Module, and it is the latest version right now 0.8.9. There is a possibility to add your own modules, scripts, credentials and certificates.

So what is the cost for running azure Automation? Now you get 500 minutes of runtime in your subscription but you can change that if you run out of “free” time to standard and then you will be billed, the 500 minutes as described below is for all your automation accounts in that subscription.

Screen Shot 2014-10-28 at 15.13.14

In this earlier post I created a Runbook script to check and manage my daughters Minecraft server so you can see an simple example of some azure automation :-)

Using Azure Automation to check health of Minecraft server in Azure

As every responsible dad out there I have set up an Minecraft server to my daughter so she can play with her friends!

Screen Shot 2014-10-23 at 16.16.59

I  have deployed a Windows Server on Azure in which I installed the Minecraft server with the right mods, apparently that is important 😉 I have not myself got lost in the Minecraft world, maybe because I grew up in the 80´s and had games that was mega-pixel and now I want that high definition graphics!

To see that it is working and alive I wanted some kind health check so here Azure Automation comes into play! Of course there would have been easier ways but I want try new stuff and also test and see how Azure Automation works and can be utilized.

So I created a runbook that checks the status and try to remediate the issue if it is not working:

I have utilised the YAMS so that the Minecraft Server is handled by a Windows Service. If there is some outage or maintenance on Azure the VM can be restarted and then it is good to know that the Minecraft Server will start even if no user is logged in. If for some reason the YAMS service is stopped or the Minecraft Server has stopped my runbook can remidiate that!

In Azure Automation I can schedule a check every 1 hour:

Screen Shot 2014-10-23 at 16.25.24

And as you can see when checking a job it reports that my Minecraft server is working!

Screen Shot 2014-10-23 at 16.45.23

To connect to the VM´s powershell endpoint I have added SessionOption -SkipCACheck thus letting me connect without getting a cert from a trusted certificate authority or importing the servers cert. Saw this option on Tim´s blog post and borrowed it:-)

In the deployed VM I have also done as explained in the PowerShell Tip from powershell.com to be able to connect to it as it is not part of a domain and when PowerShell remoting is enabled it uses Kerberos by default and the Minecraft server is standalone thus Kerberos not working!

Probably I will do some tweaking and update the script later but you can at least see the possibilities and power of using Azure automation!

Automation the future of IT Operations or prepare to die

So you are an IT Pro or maybe an CIO or CTO and have been sleeping under your desk the latest years or so? But the IT Operations departments are under a lot of stress these days coping in being able to deliver the services to the business in the pace that they demand! Do you recognize this? For example your development division request 50 VM´s and wanted them yesterday, Your response is that come back in a week or two….

Many IT departments are seeing their internal customers such as Dev or Business going outside of the organisation and buying their services directly from Azure or another public cloud provider delivered instantly and that also cheaper than you could produce internally..

Here the Hybrid way of thinking becomes important and why, well you will not be able to compete with all the services that the public cloud can give you in a cheaper and more reliable way so IT Operations of tomorrow will utilize the public cloud as their own and be able to use it for their needs where their private cloud lacks functionality or capacity and in that way respond to the requests from the departments.

Giving the users an self service portal where they can order and see the cost of their engagements is an important part of this and when you implement this you have to have  automation as a key part because the users want things to happen when they press the build button!

51075482-98cb-11e3-82f1-12313b12ccaf-large

Taking Microsofts Azure data centers as an example, they have automated enormously and that from the physical layer all the way into the virtual machines and networks. How does this automation gain you with your environment and becoming more agile and not just run around putting out fires but being able to address the needs of the company IT challenges today and also tomorrow!

Some say that we are in the second machine age and that the IT will have to change big time. Just look at the public cloud Company’s and their services, if they would have done things in a traditional way they would have to charge xx times the amount the charge for their services and also be xx more manpower on the data centers to cope with the day to day operation.

In the latest year Microsoft have released several automation solutions that have been developed and gives you the tools for this must-have automation platform. First of is the Service Management Automation (SMA) which is a robust orchestration engine based on PowerShell workflows and this has also been released as Azure Automation. Secondly we have Microsofts investment in Desired State Configuration and here this also utilize PowerShell. The DSC have some development left but it is so powerful and really large web services utilize this today and keeping their massive services compliant and up to date! DSC can be used for provisioning different things including third party software solutions and for example, Microsoft Azure offers different web services (jomla, wordpress etc) deployed in an automated way probably with some DSC technology behind the curtains.

Of course this gigantic automation project will not be done over a night and will cost quite a bit of money in initial investment but the winning and surviving IT Department is the one successful in their automation processes!

9 years ago I started an onboarding automation process and on that time I had VB script to work with but that manual labor every time a new employee was hired was painful and so boring and already at that time I found the will and inspiration to learn techniques to automate. Still today there are several processes in companies that are perfect candidates for automation but for some reason still being done manually…

Let me help you get Strategic in your IT (automation) delivery!

Adding more external IP´s to your WAP NVGRE VM´s

So I have been during these two last days been in deep waters to find out a customers demands and the possibility to add more than one external IP to the same NVGRE enabled VM network within WAP and VMM and the Hyper-V Network Virtualization Gateway this as the ports from the external application the customer has cannot be altered and they need to access several different VM´s simultaneously.

Described in this visio diagram the customer wish is:

Drawing1

 

As you maybe know, within the VMM when you have configured the HNV there is no possibility to add more external addresses in the GUI and configure port forwarding.

networknatvmm

So how to do this then, well there is a way and that is called PowerShell on the HNV Gateway and first you add the external address and then add the NAT rules

Here is a screendump of an addition of a port rule:

newnetnatbinding

To get the NatName I added the first external IP and Port rules through VMM and then I could use that information when creating the rest config from within the HNV gateway.

The following cmdlets are available on the HNV GW

Screen Shot 2014-06-03 at 19.01.09

Observe though that when adding these things directly in the HNV GW you cannot manage these rules and IP addresses in Windows Azure Pack portal or VMM!

 

Channel 9 videos available from TechEd US 2014

Recordings and code from SMA and Powershell webinar with Veeam

Last week I had two webinars together with Veeam in the subject of “Automating daunting virtualization tasks”. Now these have been uploaded and shared on Veeams web. One is in swedish and one in english. during the webinar I show some different tasks that can be managed and handled with the Service Management Automation (SMA) and utilizing PowerShell.

51075482-98cb-11e3-82f1-12313b12ccaf-large

here is the english version: http://www.veeam.com/videos/webinar-replay-service-management-automation-akerlund-en-3932.html

and here is the swedish version: http://www.veeam.com/videos/webinar-replay-service-management-automation-akerlund-sw-3649.html

Here are some of the tasks and the PowerShell code,

First one of the tasks was adding VM´s to cluster where I utilize the function in this link

Next task that can be automated that you always will have a percentage free on the C drive for the VM´s (it both shrinks and expands), I am utilizing the generation 2 VM´s so for this to work your VM´s have to be configured with this latest virtual hardware version on Hyper-V 2012 R2

As you can see when I extend the size I make the VHDx about 230 MB larger to be able to set the partition to the size calculated regarding the overhead of the virtual disk, so if I would have tried to make both the VHDx and partition 15GB it would fail..

The rest of the scripts will be uploaded later in a follow up post. Of course there can be improvements in the ways to do things and if you have any comments or ideas please share :-)