Configuration Specification Command
Tips For the
PowerShellnewbies, you can then get detailed help on an individual command via aPowerShellcommand similar to:Get-Help -Name Merge-ConfigurationSpecification -Detailed
The Dsl.Configuration PowerShell module provides one single command to process XML configuration specification DSL files:
Merge-ConfigurationSpecification -Path <string[]> [-ConfigurationFileResolver <IConfigurationFileResolverStrategy[]>] [-CreateBackup] [-CreateUndo] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
Where
-
Pathindicates the configuration specificationDSLfiles to process —the targetXMLconfiguration files into which to merge are part of the specification too,— see Configuration SpecificationDSL; -
ConfigurationFileResolveris an ordered list of object instances of classes implementing the IConfigurationFileResolverStrategy interface that will participate in the resolution of target configuration file monikers, see Configuration File Monikers and Resolvers; -
CreateBackupindicates whether to perform a backup of each targetXMLconfiguration file before actually merging a configuration specification into it; -
CreateUndoindicates whether to generate, for eachXMLconfiguration file that is the target of a configuration specification, a reverse configuration specification capable of undoing all the modifications actually made.
Remark No backup will be performed nor an undo specification generated should the merge of a configuration specification would not result in any changes to an
XMLconfiguration file.
Configuration Specification DSL
The configuration specification DSL is an embedded XML DSL. As the following example illustrates, a configuration specification deceptively looks like an actual XML configuration file:
<configuration xmlns:config="urn:schemas.stateless.be:dsl:configuration:annotations:2020"
config:targetConfigurationFiles="global:clr4:machine.config">
<system.serviceModel>
<extensions>
<behaviorExtensions>
<add
name="propertyPropagator"
type="Be.Stateless.BizTalk.ServiceModel.Configuration.PropertyPropagationBehaviorExtension, Be.Stateless.BizTalk.ServiceModel, Version=2.1.0.0, Culture=neutral, PublicKeyToken=3707daa0b119fc14"
config:operation="insert"
config:key="name" />
</behaviorExtensions>
</extensions>
</system.serviceModel>
<system.web>
<applicationPool
maxConcurrentRequestsPerCPU="5000"
maxConcurrentThreadsPerCPU="0"
requestQueueLimit="5000"
config:operation="update"
config:key="name"
config:scrap="maxConcurrentThreadsPerCPU, requestQueueLimit" />
</system.web>
</configuration>
What distinguishes a configuration specification from an actual XML configuration lies in the following attributes:
-
The
XMLnamespace declaration attribute forurn:schemas.stateless.be:dsl:configuration:annotations:2020, which is required by the otherDSLattributes. This attribute is not required per se, but not declaring it would hide away anyDSLattribute from theDSLprocessing engine;Remark The namespace prefix
configis irrelevant and left to the developer’s discretion. -
The mandatory
targetConfigurationFilesattribute, which is a coma-separated list of targetXMLconfiguration file monikers, see Configuration File Monikers and Resolvers; -
The optional
operationattribute —actionis a supported alias,— which indicates what operation this annotated specification element must undergo to be merged into the targetedXMLconfiguration files. Theoperationmay have any single of the following values:-
insert, which indicates that this annotated specification element, together with its attributes, should be inserted into the targetedXMLconfiguration files; -
update, which indicates that the attributes of this annotated specification element should be merged —adding new ones or updating existing ones— into the attributes of the configuration element that corresponds to this specification element in the targetedXMLconfiguration files; -
upsert, which indicates that this annotated specification element should either be used to update the targetedXMLconfiguration files should a corresponding configuration element be found, or be inserted into otherwise; -
delete, which indicates that the configuration element corresponding to this annotated specification element should be deleted, altogether with its attributes and child elements; -
none, which indicates that the configuration element corresponding to this annotated specification element should be used as a simple pivot element, without undergoing any alteration, so as to preserve the document ordering existing among the siblings of this specification element when merging them into the targetedXMLconfiguration files.Remark The document ordering of the specification elements will always be preserved during their merge into the targeted
XMLconfiguration files.
-
-
The optional
keyattribute —discriminantis a supported alias,— which is a coma-separated list of attribute names denoting the set of attributes, together with their values, that will be used in addition to the path and name of this annotated specification element to find a corresponding element in the targetedXMLconfiguration files; -
The optional
scrapattribute, which can only be used in conjunction with anupdateoperation and is a coma-separated list of the names of the attributes that should be deleted when merging this annotated specification element.
Remark The annotation attributes which are specific to the configuration specification
DSLare naturally left off during the processing of a specification and not merged into the targetedXMLconfiguration files.
Configuration Specification Idempotence
Configuration specification are idempotent, in the sense that if a specification has already been successfully processed —i.e. merged into its target XML configuration files,— it should not fail if its processing is triggered again. In other word, if an XML configuration file has already undergone the successful merge of a configuration specification, this XML configuration file will not be altered in any new way should the same configuration specification be merged into again.
To that end, each operation defines and implements its own preserving notion of idempotency. Details about the algorithm applied during the merge of a configuration specification for each of the operations is given by the developer help of the `ConfigurationElement.Apply’ method, but roughly speaking, each operation behave according to the following principles:
-
The
insertoperation will succeed if one or no configuration element equivalent to the specification one is found, but will fail otherwise; -
The
updateoperation will succeed if one configuration element corresponding or equivalent to the specification one is found, but will fail otherwise; -
The
upsertoperation will succeed if any of itsinsertorupdatevariant will succeed, but will fail otherwise; -
The
deleteoperation will succeed if one or no configuration element equivalent to the specification one is found, but will fail otherwise.
Remark A configuration element is said to correspond to its specification element when both have the same name and both are located at the same relative place in their own respective
XMLinfoset —in other words, when both elements have the sameXPathlocation,—seeSpecificationElement.IsSatisfiedBymethod.
A configuration element is said to be equivalent to its specification element when it corresponds to this specification element and that for each of the specification attributes there is an configuration attribute having both the same name and value. By default, all the specified attributes are taken into account for determining the equivalence of the elements, but only those attributes listed in thekeyannotation are taken into account should this annotation be specified, seeSpecificationElement.IsEquatedBymethod.
Configuration File Monikers and Resolvers
The Dsl.Configuration PowerShell module provides two implementations of the IConfigurationFileResolverStrategy interface:
-
ConfigurationFileResolverStrategy, which can resolve traditional file paths, provided the files exist on disk, e.g.
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config; -
ClrConfigurationFileResolverStrategy, which can resolve
XMLconfiguration files monikers of the formglobal:clr?:[<32bits|64bits>:]<machine|web>.config, that is to say.NET’s globalXMLconfiguration files; e.g.global:clr4:machine.configwould resolve to both 32 and 64 bits global machine.config files for theCLR4, whileglobal:clr2:32bits:web.configwould resolve to the 32 bit global web.config of theCLR2.
The Dsl.Configuration PowerShell module will always append these two resolvers, ClrConfigurationFileResolverStrategy and ConfigurationFileResolverStrategy, in that order, to the list of custom object instances passed as arguments to the ConfigurationFileResolver command parameter.
When used throughout the BizTalk.Deployment PowerShell module, a third implementation of the IConfigurationFileResolverStrategy interface is always added before the preceding two resolvers:
- BizTalkConfigurationFileResolverStrategy, which can resolve
XMLconfiguration files monikers of the formglobal:[<32bits|64bits>:]biztalk.config, that is to say Microsoft BizTalk Server®’s globalXMLconfiguration files; e.g.global:64bits:biztalk.configwould resolve to 64 bits configuration fileC:\Program Files (x86)\Microsoft BizTalk Server\BTSNTSvc64.exe.config, whileglobal:biztalk.configwould resolve to both 32 and 64 bits configuration files.
Given that ordered list of custom and built-in XML configuration file moniker resolvers, the processing engine will only use the first resolver in this ordered list that can resolve a configuration file moniker and all the subsequent resolvers in the list will be ignored.