How to replace thumbprint for certificate in cscfg for Azure deployment?

I think this in my cscfg:

since I want to use the any file variable substitution feature of Octopus. But MSBuild fails on building since it checks the “datatype” of the thumbprint value. How do I go about making this work?

Hi!

Thanks for getting in touch. I would recommend using the Additional Configuration Transforms feature which can be used to transform any XML file with a transform file. In this case you can put your development certificate thumbprint into the configuration file, and have any number of environment-specific transform files with the correct thumbprint for each environment.

For example: CloudService.#{Octopus.Environment.Name}.cscfg=>CloudService.cscfg

This way your original CloudService.cscfg has a valid certificate, MSBuild will pass, and you can tweak the thumbprint used when deploying your cloud service application.

Hope that helps!
Mike

Thank you, that makes sense. Can I put have the certificate thumbprint in the transform file be populated by a variable? Where do I store the transform file, with the actual config file?

Thanks,
/Hakan

Hakan Lindestaf
Vice President Software Development

EZLinks Golf LLC

I tried this, and it worked when I entered the actual thumbprint in the transform file. But I need it to read it from the Octopus variables, it doesn’t seem like that worked.

Thanks,
/Hakan

Hakan Lindestaf
Vice President Software Development

EZLinks Golf LLC

Hi Hakan,

Thanks for getting back to me. You should be able to use a combination of deployment features to achieve this:

  1. CloudService.cscfg has your development thumbprint
  2. CloudService.Environment.cscfg has the config transform, but where the value of the Thumbprint, use a Variable Substitution expression: xdt:Transform="SetAttributes(Thumbprint)" Thumbprint="#{MyThumbprint}"
  3. Enable the Substitute Variables in Files feature targeting the CloudService.Environment.cscfg file
  4. Enable the Additional Configuration Transforms feature targeting CloudService.Environment.cscfg=>CloudService.cscfg

Now when the deployment runs, Octopus will first perform the Substitute Variables in Files, updating your config transform file with the Thumbprints. Octopus will then run the Configuration Transform setting the attribute with the substituted thumbprint.

For more information on the ordering of these features take a look at our documentation.

Hope that helps!
Mike

Ah, got it, that worked, thanks!

Thanks,
/Hakan

Hakan Lindestaf
Vice President Software Development

EZLinks Golf LLC

Hi Hakan,

That’s great news. I’ll cross post this answer to the other thread as well.

Happy Deployments!
Mike