Application Management – Service Templates, real reusable examples

Application Management – Service Templates, real reusable examples

  • Comments 4
  • Likes

Service Template Example Kit - General Web Lab

Download the STEK here.

In this blog post of this ongoing series we will look at some real world examples of service templates and how to start using them. One of the more challenging aspects of application management can be rapid lab deployments in a repeatable and dependable manner. In that vein I wanted to create a base set of templates with standard resources and a method in which I could quickly use them to create virtual environments. My plan is to use these Services for development, QA or test of 1, 2, and 3 tier web applications. They also could be used as base templates which become the model for a production Service deployment.

Since the majority of existing and new line of business applications are web applications I based the first set of service template examples on multiple web application architectures. In this example set of 4 the first is a standalone server with no customization, I then used it to create the second which is a single web server that is load balanced using Microsoft NLB. These can be used for applications without a middle tier where a database doesn’t exist or already is deployed to a database farm. The next adds its own standalone SQL 2012 server to the web server and finally the last is a three tier web application with a web service tier acting as a middle SOAP service tier. These actually become the base for most of the rest of my Service Templates. You can modify anyone of these easily to fit your needs, and I’ll give examples with applications including some of those from MSDN Gallery like BlogEngine and DotNETnuke in an upcoming post. Simply add the app, SQL DB and deploy.

image

Let’s look at some basic conventions I have chosen. These where picked for simplicity and ease of use but certainly are changeable based on your needs and resource capabilities. For load balancing I use Windows NLB, for me this was my only choice as I have no other load balancers in my environment. For OS it’s WS 2012 and for SQL it is SQL 2012. I’ve created 2 sysprepped VHDs using Convert-WindowsImage.ps1 and for SQL sys-prepping I followed these instructions located here. For many server customizations I created scripts that I will use for all templates. I simply created one standard resource folder that houses most of the scripts I use. Any specialized scripts needed for an individual Service will be created and attached to the Service Template itself. In some cases I may even simply add my standard scripts into these specialized scripts like code snippets just to simplify. For development and QA labs you may set up separate virtual networks, active directories or DNS servers to be used by development teams for templates like these used as lab services.

As part of this blog I’ve included a compressed folder that includes the standard scripts I currently use and the 4 base Service Template XML files to import into your Virtual Machine Manager Console. In future blog post I’ll describe in more detail the standard scripts so for the purposes of this post I’ll just say it made things easier to have one Custom Resource folder for Generic Command Execution (GCE) scripts.

DOWNLOAD
The files can be downloaded from the gallery here: http://gallery.technet.microsoft.com/Virtual-Machine-Manager-a570ccc6 

In the downloaded compressed folder (ServiceTemplateExamples04062013.zip) are the following files:

· ReadMe.docx – Example template explanation and user guide.

· 1-tier Single Server.Base v1.xml –Service Template of a single WS 2012 Data Center Server with no customizations. This is deployable.

· 1-tier Scalable Web Server.Base v1.xml – Service Template of a scalable WS 2012 Data Center web server. Includes features and roles for hosting basic .NET 4.5 web applications and NLB based load balancing.

· 2-tier Scalable Web Server w SQL.Base v1.xml – Based on the 1 tier scalable web application template with the addition of a SQL 2012 database tier.

· 3-tier Scalable Web Server w SQL.Base v1.xml – Based on the 2 tier scalable web application template with the addition of a middle web tier that is not scalable to act as a web service middle tier server.

· Standard_Scripts\Standard04062013.cr – Custom resource folder that includes all the standard scripts used by the above templates.

From these you can create Gold, Silver, and Platinum service templates based on these with different resources available like memory and CPU. You can modify tiers of each to host different types of applications for example a different version of SQL.

I included the following scripts to allow some basic changes while deploying. In these scripts I log to a central log called Output.log in the vm located in %windir%\temp. I also set exit codes explicitly so if need be you could take a separate action in the Service Template when a logic failure like no required parameter takes place.

Add_Account_to_LocalAdmins.cmd

Parameter/s: <domain\user>

Usage: adds the user that is provided by the parameter to local admins.

AddEntryToDns.ps1

Parameter/s: <FQDN Of DNS Server> <Server Name Alias> [IP Address to point to]

Usage: Adds an entry to DNS. IP Address is optional, if left blank the script will use first IP off adapter 1. (Good use case would be to add an ‘A’ record for a SQL server to point your connection strings)

EnablePowerShellScripts.cmd

Parameter/s: none
Usage: Sets the PowerShell execution policy to RemoteSigned allowing local scripts and configurations to run unsigned.

Mod_DefaultWebSite.cmd

Parameter/s: <Site Name>

Usage: Deletes the ‘Default Web Site’ and creates a new folder in wwwroot and new site named after the parameter, using binding for port 80 and DefaultAppPool.

Mod_DefaultWebSite_AppPool.cmd

Parameter/s: <Site Name>

Usage: Deletes the ‘Default Web Site’ and creates a new folder in wwwroot, new app pool, and new site named after the parameter, using binding for port 80 and new app pool.

Mod_FolderPermissions.cmd

Parameter/s: <Site Name>

Usage: Changes folder permission to c:\inetpub\wwwroot\<Site Name> to everyone. Example usage of a permission script when new web site requires new read write access.

Note: <> is for required parameters and [] are optional

To Use

You will need to copy the Standard folder to your library and make sure the library is refreshed before you try to import the templates. After the refresh you can import the templates one at a time and remap any resources required. Some basic things I know for sure you will have to remap will be the VHDX files used for each template, any run-as accounts I used that you do not have, and of course network and load balancers will need remapping. Prior to importing templates here are some basic steps to confirm.

1. Windows Server 2012 Data Center VHDX is sysprepped and in library

2. Using above VHDX prepare a SQL Server 2012 image for sysprepping. Be sure to remember instance name and local directory of SQL install files in VM. (note: Install all SQL features, including Management Studio when using for development lab, limit features for production if required)

3. Create VIP Template for load balancers (note: Follow the instructions here for setting up NLB in VMM)

4. Create any run as accounts you’ll use. For example a run as for joining the domain during deployment.

Here is a view of importing the 3 Tier template. This requires 5 resources to be remapped. The 2 VHDX files, a SQL account for the service to run as, a VIP Template for NLB load balancing and the VM network. (note: this screenshot is not exact as the 5 resources exist so they do not show an clip_image004 icon next to each as your will)

clip_image006

In addition to the above remapping of resources there are some basic changes inside the templates that need to be mapped to your environment. Right click imported template and open design view.

All Tiers - Hardware Configuration:

- Select Network adapter/s

(note) Load balanced tiers require Static IP from pool and MAC address spoofing

clip_image008

All Tiers - OS Configuration:

- Change domain to join and account used to join to the domain.

- Add local Admin password. Default is Pass@word1

clip_image010

SQL Tier – SQL Server Config

- Correct Instance name

- Change ‘Media source’

- Change or add users to SQL Server Administrators

(note: all settings are based on your Prepped SQL settings.)

clip_image012

clip_image014

 

Optional All Tiers:
- Change server names for each tier. Default is *, which will name them SERVICEVM##### consecutively. (note: any scalable tier will need at a minimum to be wild carded with # for scaling out. ie: DevLabWeb## can scale to 99)

clip_image016

Adding or confirm Load Balancer on Scalable Web Tier:

- Select Add Load Balancer and map to network ( note: to create VIP template see step 3 avoce)

clip_image018

To Deploy:

- Provide a site name for the required parameter used by Pre-Install Script
@NameforIISSite@

(note: this will create a directory of the same name the site uses under wwwroot folder)

- Provide the VMM Servers service account for the parameter used by Pre-Install Script. (note: this is required for NLB setup)
@VMMserviceaccount@

clip_image020

 

Video: Importing and configuring

 


In upcoming blog post we’ll deep dive into scripts and troubleshooting as well as some example applications and how to prepare a running web site for deploying in a service template.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Excellent post, hope to see many more like this in the future.