End to End Application Packaging, Deployment and State Management using Server App-V
This blog post will cover a portion of my MMS session (AM-B316) and will be useful if you're looking to familiarize yourself with some of the key value propositions of Server App-V. This post will allow you to:
- Grasp how packaging using the Server App-V Sequencer works
- Understand how deployment with PowerShell is easy
- Understand how Server App-V allows for application portability through state separation
This post has 3 sections; Packaging, Deployment and Application Portability. Enjoy!
1. Packaging
Required Installers:
- Server App-V Sequencer (RTM)
- Apache: httpd-2.2.17-win32-x86-openssl-0.9.9o.msi
- PHP: php-5.3.5-Win32-VC6-x86.msi
- PHPBB3: phpbb 3.0.8
- MySQL: mysql-essential-5.0.41-win32.msi
Pre-Requisites:
- You're an administrator on the sequencing work station
- All the installers and the files attached in the installphpbb.zip, at the end of the blog post below, are in c:\installers
- Ensure the phpbb3.zip is extracted to C:\installers (i.e. C:\installers\phpbb3)
- Ensure the installphpbb.zip is extracted to C:\installers (i.e. C:\installers\installphpbb.bat and C:\installers\httpd.conf)
- The Sequencer's virtual drive should remain as the default Q drive
- Sequencer OS is Windows Server 2008 R2 (I used Standard edition)
Instructions:
- Install the Server App-V Sequencer with all default settings. After installing the Server App-V Sequencer, launch it and select "Create a New Virtual Application Package"
- Resolve any issues that show up in the "Prepare the computer for creating a virtual package." screen and click Next
- Select perform a custom installation
- Name your virtual application package as BlogPhpBB and click next
- At the Install your applications now screen, you can now install the application
- Open Windows Explorer, navigate to C:\installers and run installphpbb.bat as administrator
Installing Apache
- After running installphpbb.bat, the Apache installer will launch
- Click Next in the Apache installer, accept the license agreement, click Next, click Next
- Make sure "for All Users, on Port 80, as a Service" is selected, click Next
- Select "Custom," click Next
- Confirm the install path is Q:\BlogPhpBB, click Next
- Click Install then Finish
Installing PHP
- After completing the Apache installation, the php installer will launch
- Click Next, accept the license agreement and click Next
- Confirm the install path is Q:\BlogPhpBB\PHP, click Next
- Select Apache 2.2.x Module, click Next
- Confirm the Apache Configuration Directory is Q:\BlogPhpBB\conf\
- Click Next, Click Install then Finish
Installing phpbb Application
At this stage the command prompt should show the phpbb folder being copied into your package. Once it completes, the MySQL installer will launch
Installing MySQL
- Click Next at the first screen
- Select Custom and click Next
- Confirm the install path is Q:\BlogPhpBB\MySQL\ click Next
- Click Install, Next, Next
- At the Wizard Completed screen, uncheck configure the MySQL Server now and click Finish
- The script will then configure MySQL then complete and exit
- At this point opening Internet Explorer, type in localhost in the address bar and IE will present the phpBB Installation Panel. Close IE (you can install phpBB to have the installation as part of the package if you choose, but for this post we won’t)
Complete Sequencing
- This should complete the packaging process. At this stage you can return to the Sequencer UI and check the box, "I am finished installing" and click Next
- The Sequencer will take a few moments to collect system changes and once that is complete the "Configure Software" screen will be presented. Since we don’t need to configure any software, click Next and the Sequencer will again collect additional changes that may have occurred in the case that we actually run any programs in the Configure Software screen
- The package will then be created and you should see the “Package Completed” screen. Some files may be excluded from the package and the following screen will be presented. Click close to see the Deployment Configuration screen for the package
- You can now review the deployment configuration for the package. The detected Apache and MySQL services will be displayed and browsing the various tabs should show you the package’s registry and file system etc.
- Click file and save your package. Create a folder named blogphpbb and save your package into that folder (it should have the default name blogphpbb). After saving, close the Sequencer and verify that your package contents are similar to the screenshot below
- Remember to copy the package folder off the sequencer machine to a network file share so that we can deploy it on another VM.
2. Deployment
Required Installers:
- Server App-V Agent (RTM)
- Server App-V Agent PowerShell cmdlets (RTM)
- PowerShell 2.0 (available by default on Windows Server 2008 R2)
Pre-Requisites:
- You're an administrator on the Agent work station
- The package folder is on a local drive, e.g. c:\packages\
- Agent OS is Windows Server 2008 R2 (I used Standard edition)
Instructions
- Install the Server App-V Agent and Agent Cmdlets using default settings
- Launch PowerShell as administrator
- Run: import-module serverappvagent (note: you may need to turn remote signing on by running the following cmdlet: set-executionpolicy remotesigning –force)
- Run: add-serverappvpackage –name blogphpbb –manifest “path to manifest file” –SFT “path to SFT file” –configuration “path to deployment configuration file”
- The package will successfully add
- Start the virtual environment for the package by running: start-serverappvpackage blogphpbb
- At this point you can now launch IE, go to localhost and see the phpBB Installation Panel
- To get rid of the error on the top of the page open an elevated notepad and edit php.ini in the php installation directory - Q:\blogphpbb\php. Find the line that contains: '; date.timezone = ""' and replace it with: 'date.timezone = America/New_York' (without the single quotes, of course). Save the file and restart the Apache service from the Services control manager will effect the change
- At this stage you can proceed to complete the installation and customize your application
Configuring phpBB After Deployment
- Click the “Install” tab
- Click “proceed to next step”, then “start install”
- Provide the following information:
- Db server: 127.0.0.1
- Db server port: 3311
- Db name: phpBB
- Db username: root
- Db pw: 123
- Click “proceed to next step”
- Provide the following information:
- Administrator username: administrator
- Administrator password: password
- Contact email address: test@emailaddress.com
- Click “proceed to next step” until you reach to the congratulations screen. Ignore sending statistical information and click “Return to the ACP if you do not wish to send statistical information to phpBB”
- Click login to complete the installation
- Delete the install directory under Q:\blogphpbb\htdocs so that you don’t see the admin control panel every time you access the application
- You can now configure your board to customize your installation from the Administration Control Panel (Board Configuration section). For example I modified Board setting to provide a site name and description. I also created new forums and categories from the Forums tab
- After completing configuring the application, proceed to the final step to learn how to manage your application’s state
3. Application Portability
Once a virtual application is running, the Server App-V Agent tracks all local state changes for the application. Server App-V separates the state changes from the immutable virtual application package. State changes include all configuration and file changes that are in the virtual environment. In this section we will illustrate how Server App-V allows you to move an application’s state from one machine to another.
Application portability is relevant for numerous scenarios. The most common scenario is when patching an OS. For example if you need to deploy a patched version of an OS and want to minimize unavailability of your application you can deploy the same application package from section 1 (Packaging) to a machine with the new, patched version of Windows Server, backup state from your non-patched version of Windows Server and restore the state on the new machine with the patched version of Windows Server. Once you verify that your application is working satisfactorily, you can choose when to make it available as you deprecate the already deployed server.
Backing Up Virtual Application State
Pre-Requisites:
- You're an administrator on the Agent work station
- The Server App-V Agent PowerShell Cmdlets are installed
- You are on a machine with a virtual package deployed (preferably the VM we just deployed the package in the Deployment section above)
Instructions
- Since we made changes to our deployed virtual application we can perform a backup of our application state to capture all the local configuration drift that occurred post deployment
- Note this will be performed on a machine with the Server App-V Agent and the Server App-V PowerShell cmdlets installed. the machine we deployed the package above will suffice
- Create a folder in the packagestate under the C drive (c:\packagestate)
- Launch PowerShell as administrator
- Run: import-module serverappvagent (note: you may need to turn remote signing on by running the following cmdlet: set-executionpolicyremotesigning –force)
- Backup the package state. Run backup-serverappvpackagestate blogphpbb c:\packagestate\
- You can browse to the package state location and confirm the package state was created
- You can now copy the package state from c:\packagestate to a network share
Restoring Virtual Application State
To illustrate how this occurs, we will deploy the virtual application package we packaged in section 1 (Packaging) to a new VM. To perform this, follow the instructions from section 2 (Deployment) until step 7 (At this point you can now launch IE, go to localhost and see the phpBB Installation Panel) then proceed with the instructions staying in the open PowerShell prompt.
Instructions
- Using Windows Explorer, create a folder in the packagestate under the C drive (c:\packagestate)
- Run: import-module serverappvagent (note: you may need to turn remote signing on by running the following cmdlet: set-executionpolicyremotesigning –force)
- Restore the package state: restore-serverappvpackagestate blogphpbb c:\packagestate\
- Start the package: start-serverappvpackage blogphpbb
- You should now observe all the state changes from your previous machine applied to your new machine by launching IE and navigating to localhost
Thanks for reading. I hope this helps you understand how Server App-V can be used to simplify deployment and management of applications in your datacenter.
Derrick Isoka, Program Manager Server App-V