Sitecore 9 rule-based configuration and numbered roles
The other day I was digging around and stumbled upon an undocumented feature for the (somewhat) new rule-based configuration released with Sitecore 9.
You can append -{number}
to the role definition (in <appSettings>
in Web.config
) and it will work as both the full role name and without the -{number}
part, e.g. ContentManagement-1
works as both ContentManagement
and ContentManagement-1
.
Web.config:
<cofiguration>
<appSettings>
<!-- The standard way -->
<setting name="role:define" value="ContentManagement" />
<!-- Numbered version -->
<setting name="role:define" value="ContentManagement-1" />
</appSettings>
</configuration>
Any Sitecore config patch file:
<configuration>
<sitecore>
<settings>
<!-- Both approaches below will work with 'ContentManagement-1' role -->
<setting name="my.setting" value="1234" role:require="Content-Management" />
<setting name="my.setting" value="1234" role:require="Content-Management-1" />
</settings>
</sitecore>
</configuration>
It's nothing too special and nothing you couldn't do before, but it's a bit simpler to configure if you have multiple servers with the same role, where one specific server needs specific settings - e.g. if only the primary CM server should have some feature enabled.