【发布时间】:2017-06-13 10:52:02
【问题描述】:
我需要保护一个 DSC 配置参数([pscredential]RegistrationKey),所以我把它放在“settings.protectedSettings.configurationData”下面:
"protectedSettings": {
"configurationArguments": {
"RegistrationKey": {
"UserName": "PLACEHOLDER_DONOTUSE",
"Password": "[parameters('dscAutomationRegistrationKey')]"
}
},
"configurationUrlSasToken": "[parameters('artifactsLocationSasToken')]"
}
我得到错误:
"VM has reported a failure when processing extension 'Microsoft.Powershell.DSC'. Error message: \"The DSC Extension failed to execute: Mandatory
parameter RegistrationKey is missing.
如果我将 RegistrationKey 从“settings.protectedSettings.configurationArguments”移到“settings.configurationArguments”中,它会起作用,因此,我认为语法没有问题,所以我相信这与 PsDscAllowPlainTextPassword = $true 有关'不包含在 DSC 配置中。
(我试图将配置块包含在 PS1 文件中,但这引发了错误,提示无法完成)
我现在已经编写了一个配置数据 .psd1 文件,其中包含以下内容:
$ConfigData = @{
AllNodes = @(
@{
NodeName = "*"
PsDscAllowPlainTextPassword = $true
}
)
}
并在settings.configurationdata.url 中引用它。
现在这会导致与以前相同的错误:VM 报告了故障...
从 PowerShell 调用 ARM 模板:
$oAutomationAccount = Get-AzureRmAutomationAccount -ResourceGroupName $AAresourceGroupName -Name $AutomationAccountName
$RegistrationInfo = $oAutomationAccount | Get-AzureRmAutomationRegistrationInfo
$DscRegKeyString = $RegistrationInfo.PrimaryKey
$ssDscAutomationRegistrationKey = (ConvertTo-SecureString -string $DscRegKeyString -AsPlainText -Force)
#Automation Account EndPoint Uri
$DscRegistrationUrl = $RegistrationInfo.Endpoint
$params = @{
artifactsLocationSasToken = $TemplateSas
vmName = "XYZ"
dscAutomationRegistrationKey = $ssDscAutomationRegistrationKey
dscAutomationRegistrationUrl = $DscRegistrationUrl
dscNodeConfigurationName = "CreateAFolder.localhost"
dscTimeStamp = (Get-Date -f "MM/dd/yyyy H:mm:ss tt") #"MM/dd/yyyy H:mm:ss tt"
dscResourceUrl = $DscResourceUrl
dscConfigurationUrl = $DscConfigurationUrl
dscResourceScript = $DscResourceScriptName
dscResourceFunction = "ConfigureLCMforAAPull"
#sequenceId = $sequenceId
}
New-AzureRmResourceGroupDeployment @params `
-Name "$TemplateInstance-$branch" `
-ResourceGroupName $DeploymentResourceGroup.ResourceGroupName `
-Mode Incremental `
-DeploymentDebugLogLevel All `
-TemplateUri $TemplateUri `
-Verbose
我认为参数是作为正确类型传递的。
我做错了什么?
更新为使用更新的 DSC 架构:https://blogs.msdn.microsoft.com/powershell/2016/02/26/arm-dsc-extension-settings/
【问题讨论】:
标签: json powershell azure dsc