Lesson 2: Deploying the HRApplicationServices Workflow Service
Objective: Learn how to set the deployment settings on a workflow service project in Visual Studio, and create the deployment package (a *.zip file). Then use the Internet Information Services (IIS) Management tool to deploy the package on IIS.
Purpose: To deploy an application that includes WCF and/or WF services.
Note the following prerequisites before you begin this lesson:
You must install and configure AppFabric. For more information, see Lesson 1: Getting Started.
You must install the tutorial files. For more information, see Lesson 1: Getting Started.
Creating a Deployment Package
To set deployment values in Visual Studio
Open Visual Studio 2010 and run it as administrator. On the Start menu click All Programs, open the Visual Studio 2010 folder, right-click Microsoft Visual Studio 2010 and click Run as administrator.
Build the solution. On the Build menu click Build Solution, or press F6.
Expand the HRApplicationServices node. This node contains the workflow service that you will deploy.
Expand the Web.config node. Not that there are two sub nodes: Web.Debug.config and Web.Release.config.
Open the Web.Release.config file and examine its contents. The default file contains only four elements: <xml>, <configuration>, <system.web> and <compiliation>. However the completed configuration file contains the following code:
<configuration xmlns:xdt= "http://schemas.microsoft.com/XML-Document-Transform"> <!--Modify the BaseURI key --> <appSettings> <add key="BaseURI" value="http://localhost/HRApplicationServices" xdt:Transform="SetAttributes(value)" xdt:Locator="Match(key)"/> </appSettings> <system.serviceModel> <client> <!--Modify the endpoint addresses for production --> <endpoint address="http://localhost/HRApplicationServices/SubmitApplication.xamlx" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IApplicationService" contract="IApplicationService" name="BasicHttpBinding_IApplicationService" xdt:Transform="SetAttributes(address)" xdt:Locator="Match(name)"/> </client> </system.serviceModel> <system.web> <compilation xdt:Transform="RemoveAttributes(debug)" /> </system.web> </configuration>
Note the <appSettings> element.
<appSettings> <add key="BaseURI" value="http://localhost/HRApplicationServices" xdt:Transform="SetAttributes(value)" xdt:Locator="Match(key)"/> </appSettings>
When deployed using MSDeploy, the transform will instruct the MSBuild process to locate the BaseURI node in the <appSettings> XML element and replace the attribute value with the one defined here: http://localhost/HRApplicationServices
When the project is built and the configuration file created, the following line appears in the transformed web.config:
<appSettings> <add key="BaseURI" value="http://localhost/HRApplicationServices" /> </appSettings>
The configuration also contains the <system.ServiceModel> element which defines the Windows Communication Foundation (WCF) values needed to connect to the service. In brief, the section supplies the address, binding, and contract information for the service. For more information, see Configuring Services Using Configuration Files.
On the Visual Studio toolbar switch the configuration from Debug to Release.
In the Solution Explorer right-click the HRApplicationServices project, and click Package/Publish Settings. This opens the Package/Publish Web section of the project’s properties page.
Under Items to deploy (applies to all deployment methods) ensure that Only files needed to run this application is selected.
Under Web Deployment Package Settings ensure that Create deployment package as a zip file is checked.
Copy the location where the package will be created to the clipboard. By default it is:
Set the IIS Web Site/Application name to be used on the destination server.
Save all files in the solution.
To Create the Deployment Package
- Right-click HRApplicationServices and click Build Deployment Package. You should see Publish succeeded as the status in the bottom left corner when the action has completed.
Importing the Application into IIS
In this section you will deploy the application and edit the Bindings setting to enable AppFabric to use the net.pipe protocol for communication.
To Import the HRApplicationServices Application
Open IIS Manager by clicking Start > Run and typing inetmgr.
Expand the Server node, expand Sites and right-click Default Web Site. Then click Deploy/Import and click Import Application.
Paste the path of the application’s .zip file into the dialog box.
In the Install an Application Package dialog, you will see the application and the database. Accept the default values.
Click Next three times to use the defaults on the rest of the Import Application Package wizard pages. When asked to run this application in the default .NET 4 application pool click Yes.
The Summary page will provide a high-level overview of some items that were installed from the package. The Details tab will give a lot of detail of exactly what was added.
Enabling the net.pipe Protocol
AppFabric installs a Workflow Management Service (WMS) that works with the workflow persistence store to provide reliability and instance control. WMS communicates with the workflow service using the net.pipe protocol. Therefore, this protocol must be enabled on the application.
To Enable the net.pipe Binding
In IIS Manager right-click Default Web Site and click Edit Bindings….
In the list, look for net.pipe with an asterisk (*) for its Binding information. If it is not present:
Click the Add button.
In the Add Site Binding dialog, select net.pipe.
In the Binding Information box type an asterisk (*).
What Did I Just Do?
In this lesson, you set the deployment settings in Visual Studio then created a deployment package. You also deployed the application by importing the package into the IIS Manager. Finally, you enabled AppFabric to communicate to your application using the net.pipe protocol.
Go to Lesson 3: Configuring the HRApplicationServices Application to configure AppFabric for monitoring and persistence.
Lesson 1: Getting Started
Lesson 3: Configuring the HRApplicationServices Application
Lesson 4: Monitoring the Health of the HRApplicationServices Application
Lesson 5: Resuming a Suspended Workflow Using AppFabric