Friday, February 25, 2011

appHostSchema provider ignoring files when synching

I was packaging the schema config files for IIS using the appHostSchema provider which included my custom file. When the package was created, my custom file wasn't included. This was also occuring when I was synching server to server, rather than using a package to see if that would make a difference. Again, my custom file was being excluded from the synch. This was working fine a couple of weeks ago.

Eventually I found out why this was occuring, I had recently put my custom file in source control which meant the file had become read-only. I manually copied the file to the config\schema folder on my local pc. When I tried to packing the files on my pc, it was now being excluded.

Once I turned off the read only setting, my file was once again included when synching.

Tuesday, December 14, 2010

Perfomance improvements using AppFabric's Auto-Start

Ron Jacobs has recently put up a post around how to leverage AppFabric's Auto-Start feature.

The post is here: http://blogs.msdn.com/b/rjacobs/archive/2010/12/09/wcf-and-appfabric-autostart.aspx

Long story short, you need to use a custom service host, and call the code which will perform the caching functionality etc within the ServiceHostFactoryBase.CreateServiceHost method (the factory method which creates the service host).

So this implies, Auto-Start creates the ServiceHost before the first call to the WCF service.

Thursday, November 11, 2010

"Unable to copy the file..." error when dynamically changing item names in a Visual Studio project template

I created a Visual Studio project template including creating a wizard using the instructions here: http://msdn.microsoft.com/en-us/library/ms185301.aspx. As part of the template I wanted to parameterise the name of items within the template - which I found the instructions to do so here: http://msdn.microsoft.com/en-us/magazine/cc188697.aspx#S6 (well not instructions, but what manual updates are required to the .vstemplate file - specifically Class1.cs).

After making this update (where $fileinputname$ is now the parameter which determines the file name, the following error was thrown..."Unable to copy the file Class1.cs from the project template to the project. Can't find the file \Class1.cs".

After some quick Googling, I found the solution in the following thread: http://forums.asp.net/t/941773.aspx. What would have been benefical to me is if I had found this article first http://msdn.microsoft.com/en-us/library/ys81cc94.aspx (as mentioned in the forum) - where it now contains the steps required to update rename files with parameters (i.e update the compile include to have the parameter name, rather than the original file name before it is renamed). The MSDN article fails to mention this.

Monday, October 18, 2010

Performance and loading testing WCF services with JMeter

JMeter is great for performance and load testing WCF services. It's a free Java app available for download here - http://jakarta.apache.org/site/downloads/downloads_jmeter.cgi.

JMeter has numours components available to create a test plan such as
  • logic controllers, which allows you define conditions when requests are sent (e.g. every 2nd thread make a request using this web request).
  • timers, define the stand down period before a thread will make another request
  • assertions, parse the response to assert that the request was successful
  • listeners, various ways to display the response data received by JMeter.
An example on how to create a web service test plan using JMeter is available here - http://jakarta.apache.org/jmeter/usermanual/build-ws-test-plan.html

EDIT: I've created a new post on how to set up with a CSV data set.

Wednesday, October 13, 2010

Troubleshooting AppFabric

Just a quick tip on where to start to help out trouble shooting AppFabric. The error messages displayed with AppFabric aren't very explicit - however a lot of info is logged in the Application Server-System Services Admin event log. This is available in the Event Viewer under Application and Services Logs --> Microsoft --> Windows -->Application Server-Applications.

Make sure the log is enabled by right clicking on the Admin node and selecting Enable Log.

No monitoring data displayed in the AppFabric dashboard

One thing to keep in mind when viewing the monitoring events in AppFabric is that AppFabric uses the user account (that is the user that is viewing the logs), rather than the account that the website's AppPool is running under (the service account) to authenticate to the underlying monitoring SQL Server database.
So each user that needs to use AppFabric will have to have the appropriate rights to the Monitoring database in order to view the events logged. (i.e. be a member of a group which is a member of the Monitoring database's ASMonitoringDbReader database role).

This had me stumped for a while as I confirmed that the events where being processed by the AppFabric ETW service as they were appearing in the staging table - ASStagingTable, and the SQL job was moving them into the events table - ASWcfEventsTable.

However, they weren't being displayed when I viewed them in AppFabric. Unfortunately AppFabric doesn't give much info as to why the events are not being displayed apart from "The specified database is not a valid Monitoring database or is not available.", "Object reference not set to an instance of an object." & "No connection string". Nothing about any login failing, and the connection string hasn’t changed, and other user accounts could view the events.

Fortunately I checked out the Services pane in AppFabric where you can select the Monitoring Statistics tab, and when I selected it I received the following error:
The specified database is not a valid Monitoring database or is not available.
Cannot open database "ApplicationServerMonitoring" requested by the login. The login failed.
Login failed for user ‘[domain\user]'

Wednesday, September 29, 2010

MSDeploy with Declare and Set parameter files

One of the most undocumented parts of MSDeploy is the declare and set parameter xml files you can use to encapsulate the parameters declaration and setting rather than having them clogging up the command line call to MSDeploy.

So firstly, here is how to include them when packaging and deploying:

msdeploy.exe" -verb:sync -source:apphostconfig="default web site/application” -dest:archivedir="C:\packages\application" -declareParamFile="C:\source\application\deployment\declareParamsFile.xml"

msdeploy.exe" -verb:sync -dest:apphostconfig="default web site/application” -source:archivedir="C:\packages\application" -setParamFile="C:\source\application\deployment\setParamsFile.xml"

You can verify that the parameters were correctly generated when the package was generated by examining the parameters file in the package folder.

The format of the declareParamFile is exactly the same as the parameter file that is generated in the package when you specify them manually in the command line – e.g. below is the content of the declareParamsFile.xml file.

<parameters>
<parameter name="enabledProtocols" defaultValue="http,net.pipe">
<parameterEntry kind="DeploymentObjectAttribute" scope="application" match="application/@enabledProtocols" />
</parameter>
<parameter name="applicationPool" defaultValue="synctest">
<parameterEntry kind="DeploymentObjectAttribute" scope="application" match="application/@applicationPool" />
</parameter>
<parameter name="providerServiceAddress" >
<parameterEntry kind="XmlFile" scope="web.config" match="//configuration/system.serviceModel/client/endpoint[@name='NetNamedPipeBinding_ProviderCustomerDetails']/@address" />
</parameter>
<parameter name="physicalPathLocation" description="Physical path where files for this Web application will be deployed." defaultValue="E:\Install\Services\ExampleService\" tags="PhysicalPath">
<parameterEntry kind="DestinationVirtualDirectory" scope="Default\ Web\ Site/iag\.application\.services\.exampleservice/" match="" />
</parameter>


Parameters are defined using various kind types. The common type is DeploymentObjectAttribute which allows you to configure the values within the archive.xml file using an XPath expression to determine where the update should be made. The archive.xml file is generated when the package is created and defines configuration for the deployment – e.g. if a website was packaged using the AppHostConfig provider, then it will contain the setting for which AppPool to use when the site is deployed. Create a deployment package, then open the archive.xml to better understand what this means. For a list of parameter kinds available see here http://64.4.11.252/en-us/library/dd569084(WS.10).aspx.

Once the deployment package is created, the parameter file generated within the package will contain the parameters specified in the declareParamFile.

Below is an example of the setParamfile and the format that should be used. Note that the name of the setParameter elements is the same name as their corresponding declaration in the declareParamFile example above.

<parameters>
<setParameter name="enabledProtocols" value="http, net.pipe"/>
<setParameter name="applicationPool" value="ServiceNameAppPool"/>
<setParameter name="providerServiceAddress" value="net.pipe://server/servicename/endpoint.svc"/>
<setParameter name="physicalPathLocation" value="C:\Services\ServiceName\"/>
</parameters>


When performing the deployment to the destination web server, to include the setParamFile file use the –setParamFile switch in the command line – e.g. setParamFile="C:\source\application\deployment\setParamsFile.xml"

Probably my favourite parameter kind is XmlFile (providerServiceAddress) which allows you to specify a xml file (which would typically be the web.config when deploying web applications) to be updated when the deployment is executed. You specifiy a XPath expression to indicate where you want to update the file. This is great when moving through different environments as the web.config usually contains environment specific settings.