Conditional IIS Bindings

Hello. I save a project set up in Octopus that is deploying nicely to our Development environment. I need to deploy the application with a different IIS binding depending on the environment. I have one Development environment and two Production Environments (Load Balanced).

So I’ve configured three variables in the project in Octopus to resolve to True depending on the deployment scope, and I’ve added these variables to the IIS binding ‘Enabled’ field. When testing, the Development deployments run perfectly when I only have one IIS binding present (using the variables in the Enabled field). But as soon as I add a second or third binding with the variables in the Enabled field, the deployment fails for all environments with the following error:

System.FormatException: String was not recognized as a valid Boolean.

I have attached screenshots of everything that I can think of, and a copy of the deployment log in Raw format.

Is there something I’m doing wrong here?

Thanks!

2017-10-04_11_15_52-.png

ServerTasks-1746.log.txt (13 KB)

Hi Chris,

Thanks for getting in touch! It looks like you are using our Variable Scoping feature a little wrong. Not to worry! I can provide you with some pointers here to get you going. I think the easiest way would for me to show you how I would configure my variables here.

Instead of creating multiple bindings and using IF logic to tell Octopus whether it should be enabled or not, you can create a single binding where the values are all variables which will be substituted based on scope.

Variable | Value | Scope
Host | Host1 | Dev
Host | Host2 | Test
Host | Host3 | Prod
Address | 10.1.7.13 | Dev
Address | 10.1.7.12 | Test
Address | 10.1.7.14 | Prod
Certificate | CertName | Dev
Certificate | CertName | Test
Certificate | CertName | Prod

IIS Bindings section in step.

Protocol: https
Port: 443
IP Address: #{Address}
Host: #{Host}
SSL certificate thumbprint: #{Certificate}

This lets you have a neater IIS Bindings section and have your values correctly defined based on the scoping of your choice. (I just used Environmental scoping for this example)

Does the above example along with the documentation help you out here?

Let me know how you go. :slight_smile:

Best regards,
Daniel

Hi Daniel, thanks for getting back to me. That worked perfectly. It seemed obvious once you’d pointed it out :-). I do have a follow-up question though.

In the log file I supplied previously (and in my now successful deployment log file), Octopus is warning that I have duplicate variables between the Step Template and my Project or Variable sets. I can’t see why it might think this as I’ve only declared them in one place? As a result, whilst the deployment has been marked as successful and is a nice green colour, there is an exclamation mark on the icon which I’d like to get to the bottom of.

Thanks again.

Hi Chris,

Thanks for the update! I’m glad I could help you make your scoping more efficient! As for your new question, we recently made a change which will display any duplicate variables in your deployment process. However we are finding a few edge cases where this is not performing as expected, and or the message is not entirely relevant. I can link you to our related open GitHub issues and provide you with a variable to suppress the warning in case you just want to ignore it. :slight_smile:
https://github.com/OctopusDeploy/Issues/issues/3819
https://github.com/OctopusDeploy/Issues/issues/3814
https://github.com/OctopusDeploy/Issues/issues/3776

We have released a variable which you can use to disable this. The variable can be added to your project and will suppress this warning for said project:

OctopusSuppressDuplicateVariableWarning |  True

Let me know how you go here. :slight_smile:

Best regards,
Daniel

Worked a treat. Thanks for your help.