Hi,
I got a challenge with certificate variables, when I wanted to add some additional logic to select needed certificate dynamically.
Normally when you add certificate variable (e.g. #{PrimaryCertificate}
), you can access all its’ properties - like #{PrimaryCertificate.Thumbprint}
, #{PrimaryCertificate.Password}
, etc.
However if I reference certificate variable in another variable - all these additional properties are lost. E.g. if there is #{RerefencedCertificate}
= #{PrimaryCertificate}
- you cannot use #{RerefencedCertificate.Thumbprint}
.
I understand it’s a bit too complex and probably not without a reason, but I can describe why it’s needed (maybe you will be able to give any other suggestion how to achieve similar thing).
Imagine we have a case (Service Fabric deployment) and need to switch primary and secondary certificate from time to time. So I added a variable saying which certificate is main one at the moment.
That’s how it looks like:
I just want to change only one variable (#{Certificate_Active}
) to be able to switch certificates.
#{Certificate_ServiceFabric_Primary}
returns same name as real certificate variable #{Certificate_ServiceFabric_1}
, which means variables logic itself is working.
However in this case I cannot use #{Certificate_ServiceFabric_Primary.Thumbprint}
.
I need three certificates properties (Thumprint, Pfx and Password), because I need to upload certificates to Azure Keyvault. So solution might be to replicate all above logic for all these properties separately, but it would be a bit too complicated to maintain, I strive to keep it more simple.
One of the options would be just rename #{Certificate_ServiceFabric_1}
variable to #{Certificate_ServiceFabric_2}
and vice versus, when you need to switch, but the problem that usually we need to switch only for one environment (we have 3). So in this case we would need to set certificate variable value to different certificate only for needed environment, but it would need much more steps - i.e. more space for mistakes.
Any ideas or other suggestions? Can it be workarounded somehow? Maybe it’s just should be referenced in a slightly different way?