我尝试使用DSC模块xWebConfigKeyValue
的{{1}}资源在我们的应用程序的web.config文件中设置多个值。这是我们配置的摘录,其中包含围绕web.config更改的主要活动:
xWebAdministration
但是当我尝试运行配置时,我收到以下错误:
Add-NodeKeys:关键属性组合 ' C:\企业\ ManagementPortal :: AppSettings的'是重复的键 ' WebsitePath,ConfigSection'资源' xWebConfigKeyValue'在节点中 ' MYNODE&#39 ;.请确保每个关键属性都是唯一的 节点中的资源。在行:160 char:9 + Add-NodeKeys $ keyValues $ keyNames $ keywordName + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidOperation :( :) [Write-Error],InvalidOperationException + FullyQualifiedErrorId:DuplicateKeyInNode,Add-NodeKeys
看到错误后,我看了一下模块schema.mof文件,发现appSettings键不是Configuration C4M
{
Param(
[Parameter(Mandatory)]
[string] $BuildDropLocation
)
Import-DscResource -Module xWebAdministration
Node $AllNodes.NodeName
{
$managementPortalInstallPath = 'c:\Company\ManagementPortal'
File ManagementPortalContents
{
DestinationPath = $managementPortalInstallPath
SourcePath = "$BuildDropLocation\ManagementPortal"
Type = 'Directory'
Recurse = $True
}
xWebConfigKeyValue RecaptchaPublicKey
{
WebsitePath = $managementPortalInstallPath
ConfigSection = 'AppSettings'
Key = 'recaptchaPublicKey'
Value = $Node.RecaptchaPublicKey
DependsOn = '[File]ManagementPortalContents'
}
xWebConfigKeyValue RecaptchaPrivateKey
{
WebsitePath = $managementPortalInstallPath
ConfigSection = 'AppSettings'
Key = 'recaptchaPrivateKey'
Value = $Node.RecaptchaPrivateKey
DependsOn = '[File]ManagementPortalContents'
}
}
}
配置的关键:
C:\Program Files\WindowsPowerShell\Modules\xWebAdministration\DSCResources\MSFT_xWebConfigKeyValue\MSFT_xWebConfigKeyValue.schema.mof
由于只有站点路径和配置部分是键,因此我无法将多个资源实例指向同一个appSettings块,但使用不同的appSetting键。如何配置多个appSetting键呢?
答案 0 :(得分:3)
您无法在同一个配置中配置两个xWebConfigKeyValue资源,因为您已经找到,资源键仅包含WebsitePath和ConfigSection属性,并且不会区分Key属性。< / p>
我认为您的直接选择是:
或
这些都不是一个特别好的解决方案,但它可能会阻止你,直到出现更好的解决方案。