How can we keep IIS ApplicationID's in sync for session-state server

We are trying to deploy our sites to a web-farm. Some of these sites rely on session-state. These sessions have to be non-sticky. Therefore we’ve configured IIS to use SQL Server as a state manager to share our sessions across all machines in the “web server” role.

The problem we are running into is that the ApplicationID’s for each site are different on each web-server. Since IIS uses this ID to store and retrieve sessions, this means that a SessionID will point to a separate session for each machine in the “web server” role, instead of the desired shared session.

My question is: Does Octopus provide a means to either fixate the ApplicationID across machine, or to specify this ID as a parameter? By default, Octopus seems to assign the ApplicationID by determining the current highest ID and incrementing this.

I attempted to create a custom deploy script that uses the octopus project-ID (stripped of the “projects-” prefix) plus an offset (say 10.000) to fixate the project ID, but the step-template we use is based on “Deploy a NuGet package”, of which the powershell script does not seem to be publicly available.

Please note that setting this ID manually in IIS is not a viable option, since this a) requires a full IIS reset and b) reduces us to manual IIS configuration, avoiding which is precisely why we are using Octopus.

Another alternative we considered is using a custom SessionID provider, but this would mean we’d have to alter all of our applications.

Hi Hilmar,

Thanks for getting in touch!

Octopus doesn’t provide a setting to control the application ID - IIS actually generates these automatically. As I’m sure you can appreciate, there are thousands of settings in IIS, and adding them all to the Octopus UI would make for one confusing UI!

Your best bet might be to not use the built-in IIS configuration settings, and instead use your own PowerShell script to create the IIS site. If it helps, I’ve posted the PowerShell script that Octopus already uses to configure IIS, so it should be a good starting point:

Hope that helps!

Paul

Hi Paul,

Thanks for the response. For my information: If I were to create a step template based on “deploy nuget package”, how would I replace the built-in site creation process with this one? Can I set this script as the “deploy” script?

And just FYI: your script does, in fact, generate the ID. On line 255 it takes the current highest ID and increments this. On the subsequent line it passes this value as a parameter when creating the site.

$id = (dir iis:\sites | foreach {$_.id} | sort -Descending | select -first 1) + 1
new-item $sitePath -bindings @{protocol="http";bindingInformation=":81:od-temp.example.com"} -id $id -physicalPath $webRoot -confirm:$false

Hilmar

I would also like the ability to specify this as part of the configuration/deployment. We have many apps that are served from the same environment and we need to be able to specify this so that sessions are maintained in a load balanced environment.