Wednesday, January 25, 2012

The real deal - Services (Part Two)

If you have tested the deployment of services in VMM 2012, you`re most likely familiar with the Stock Trader Service. You`re able to import this service into your VMM Library. (Check this blog post)
Instead of just deploying this service and show you some screenshots, I`ve de-coupled the service so I`m able to create it from scratch using VMM 2012 and explain the details and see how the Stock Trader service is built and designed.
Remember that VMM 2012 has native support for Web applications, Server App-V applications and SQL data-tier applications.

Creating and deploying a multi-tier service

Let`s pretend that we`re working close with some of our developers and actually know how this application is meant to work.

We also know that this application would require a SQL database server, two middle-tiers and a web-tier. The web-tier should also be able to scale out since it`s stateless and would therefor need a load balancer.

Step 1Creating the VM templates

The big hitch in cloud computing is the software dependencies. But with VMM 2012 you`re able to have loosely coupled services like web applications and Server App-V applications. To summarize, you only need a sysprep`d VHD with for example Windows Server 2008 R2 installed.

The SQL Database server requires a Microsoft SQL Server and VMM supports SQL Server Profiles in the Library (containing SQL configuration, service accounts, defines SQL Authentication or/and Trusted Authentication, installation media, TCP/IP and Named Pipes ++) which means we can deploy SQL server as part of our service during the deployment. However, the VHD-file that is used must be sysprep`d with a sysprep`d SQL server as well. (Check this blog post)

To summarize again: Sysprep 2 Windows Server 2008 R2 VM`s where one of them also have a sysprep`d SQL server. Right click your VMs in the VMs and Services view in VMM and click ‘Create’ and ‘VM Template’. VMM will now sysprep your VMs and place them in the library share that you specify.

Step 2 – Preparing the applications

Ok, our developers have sequenced the applications for our middle-tiers by using Server App-V.

If we take a closer look at the packages, we can explore the manifest.xml-files.

These files will show which server roles, server features and any other components that`s required for our VM template to work. The good news is that VMM is able to detect this when you add the application to the template.

Tip: if you know exactly what you`re doing when you`re sequencing your applications, you can have a package ready in a couple of minutes and you`re good to go. However, you`ll most likely have to test the sequencing process again and again and again to be sure that you have done everything correctly. In some cases, your applications are not suited for the Server App-V. But since this would require some testing (I guess) you should create a VM, install the Server App-V sequencer agent – which is included in your VMM setup and available in the library, and use checkpoints/snapshots during your testing. This is a scenario where snapshots are very neat and helpful.

VMM also includes WebDeploy so that you easily can import web applications to your IIS servers. For more information about WebDeploy, click here.

Basically, you install the WebDeploy kit on your web servers, export the application in IIS, and then you`re able to import these applications in to another web server (IIS). In some cases, you can also virtualize these applications by using Server App-V.

Our applications would also require some data-tier applications as well, and VMM has support for this too. A data-tier application (DACPAC) is an entity that contains all of the database and instance objects used by an application. A DAC provides a single unit for authoring, deploying and managing the data-tier objects instead of having to manage them separately. A DAC allows tighter integration of data-tier development with the development of the associated application code. It also gives administrators and application level view of resource usage in their system.

You can extract the data-tier applications by using SSMS 2008 R2.

For more detailed information about SQL data-tier applications, check this site.

Step 3 – Working with Application Profiles

Some new improvements in VMM are related to the Library. When it comes to your applications, you can create application profiles that are loosely coupled with your virtual machines, so you`re able to use them over and over again, with no need for sysprepping your VMs with the applications already present and installed.

Your application packages must be stored in the library and indexed by VMM. The default refresh interval is set to 1 hour but you can do this on demand manually by right clicking your library server/share and click refresh.

So since the service we`re about to deploy is based on the native applications that VMM supports, we will create some application profiles that will install the Server App-V agent and WebDeploy.

WebDeploy and Server App-V is stored default in the library, and when you add a new library server, you have the option to import the default Application Frameworks into the library (which contains Server App-V sequencer and agent, WebDeploy and scripts that would install this automatically during service deployment.

To install these components, you must add a script to the application profile.
Since you would require either WebDeploy or Server App-V agent to be installed prior to the applications, you would normally create a Pre-install script.
Specify the executable and the parameters, and browse to the package located in one of your libraries. Select a Run as Account with proper permissions to install the package in the virtual guest OS.
In addition, you can specify advanced scripting logging for troubleshooting in case the deployment fails.

Once this is configured, you may add the applications and applications scripts required to get the applications up and running. It really depends which application you`re dealing with, and you should work closely with your developers/application owners to get this correct, and fill in the required parameters and instructions for the installation of the applications.

The example above shows the deployment of WebDeploy and a web applications with application scripts.
The same rules apply for the Server App-V applications and SQL data-tier applications.  

Step 4 – Working with the Service Template Designer

We`ve now got our application profiles and the VM templates configured and stored in the Library.
Navigate to the Library workspace and select Service Templates, right click and click Create Service Template.

This will launch the service template designer.

VMM ships with some patterns to get you started really quick. Either a single-tier template or a multi-tier template.

We will start from scratch in this example.

As you can see, you can drag your VM Templates into the designer. We need four VMs for this service, and will therefor use a VM template which contains the sysprepped SQL server, and an empty sysprepped VM for the rest of our tiers.

Let`s start by configuring our SQL Server VM.

This tier would require a SQL server and the SQL data-tier applications. From the service canvas we`re able to click on the ‘Add application’ button and select profiles and applications from our library. (You can also configure the HW and OS profiles for your VMs – directly from this view).

Now, let`s do the same for our middle-tiers and add the Server App-V applications

Now, we have to add our web applications to our web tier.
Since our web-tier should be able to scale out, we must also configure a load balancer. The good news is that Microsoft NLB is integrated into VMM by default, and the only thing you have to do is to create a VIP Template. In this example I`ve created a HTTP VIP Template and associated it with the NLB load balancer in Network in the Fabric view. Once you have done this, you only have to add the NLB feature in the OS configuration on your VM template – along with any other required Web-roles/features to get your web-tier up and running.

VMM knows immediately that this tier should be able to scale out, and during the deployment installs and configure NLB automatically, after you have added the load balancer into the service canvas and defined the connectivity, and set the scale limit.

After you have added all the required profiles, applications and configured the VMs, you should ask yourself: how would I normally deploy this service if I did it manually?

Eventually, this leads us to the Application Deployment order.
In this example, I want my SQL server to be deployed first so it`s able to receive connections and data from the other applications, since they rely on this tier. Second, I want my web-tier to be deployed, and my mid-tiers as number 3 and 4.

Once you have configured all this and feel quite satisfied, you can save and validate the configuration. If there are any errors related to the configuration, VMM will notice you before you go any further.
If everything seems fine, click Configure Deployment, give your service a name and place it either on a host group or a private cloud.

Once you click ‘OK’, intelligent placement will kick in and check where the service should be able to run. If everything is OK, you can start the deployment of your service.

I will most likely create a webcast that demonstrate the entire process in the near future. Please give me a note if you have any questions etc or want me to cover.

The next blog post will focus on the service lifecycle in VMM.


Unknown said...

Very nice article. thank you so much for sharing. i hope you can have the kindle english version of your book.

Kirpal Singh said...


I want to deploy application by scvmm 2012, in which one vm has application package and another one has SQL instance with Application DB, i have deployed SQL instance and Application package but dont know the syntex of script to deploy SQL DB, kindly suggest , DB is already uploaded in SCVMM library.

Kirpal Singh

Kirpal Singh said...


Beiers indo para o Quebec said...

very nice article, but I tried the same way and the NLB has not beeing set up automacticaly after deploy

Kristian Nese said...

It`s important that you Place that instance tier behind a load balancer in the service canvas during creation. Can you verify this?