ARM模板DSC:配置没有“看到”protectedSettings.configurationArguments

时间:2017-06-13 10:52:03

标签: json powershell azure dsc

我需要保护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”,它就有效,因此,我认为语法没有任何问题,所以我相信它与{ {1}}未包含在DSC配置中。

(我试图将配置块包含在PS1文件中,但这引发了错误,提示无法完成此操作)

我现在编写了一个配置数据.psd1文件,其中包含以下内容:

PsDscAllowPlainTextPassword = $true

并在$ConfigData = @{ AllNodes = @( @{ NodeName = "*" PsDscAllowPlainTextPassword = $true } ) } 中引用它。

现在导致与以前相同的错误:VM已报告失败...

从PowerShell调用ARM模板:

settings.configurationdata.url

我认为参数是作为正确的类型传递的。

我做错了什么?

参考模板:https://github.com/Azure/azure-quickstart-templates/blob/master/dsc-extension-azure-automation-pullserver/azuredeploy.json

更新以使用更新的DSC架构:https://blogs.msdn.microsoft.com/powershell/2016/02/26/arm-dsc-extension-settings/

1 个答案:

答案 0 :(得分:0)

这是我用于节点入职的模板:

{
    "name": "xxx",
    "type": "Microsoft.Compute/virtualMachines/extensions",
    "location": "[parameters('location')]",
    "apiVersion": "2015-06-15",
    "dependsOn": [
        "xxx"
    ],
    "properties": {
        "publisher": "Microsoft.Powershell",
        "type": "DSC",
        "typeHandlerVersion": "2.22",
        "autoUpgradeMinorVersion": false,
        "protectedSettings": {
            "Items": {
                "registrationKeyPrivate": "[parameters('registrationData')]"
            }
        },
        "settings": {
            "ModulesUrl": "https://github.com/Azure/azure-quickstart-templates/raw/master/dsc-extension-azure-automation-pullserver/UpdateLCMforAAPull.zip",
            "SasToken": "",
            "ConfigurationFunction": "UpdateLCMforAAPull.ps1\\ConfigureLCMforAAPull",
            "Properties": [
                {
                    "Name": "RegistrationKey",
                    "Value": {
                        "UserName": "PLACEHOLDER_DONOTUSE",
                        "Password": "PrivateSettingsRef:registrationKeyPrivate"
                    },
                    "TypeName": "System.Management.Automation.PSCredential"
                },
                {
                    "Name": "RegistrationUrl",
                    "Value": "xxx",
                    "TypeName": "System.String"
                },
                {
                    "Name": "NodeConfigurationName",
                    "Value": "xxx",
                    "TypeName": "System.String"
                },
                {
                    "Name": "ConfigurationMode",
                    "Value": "ApplyAndMonitor",
                    "TypeName": "System.String"
                },
                {
                    "Name": "ConfigurationModeFrequencyMins",
                    "Value": 15,
                    "TypeName": "System.Int32"
                },
                {
                    "Name": "RefreshFrequencyMins",
                    "Value": 30,
                    "TypeName": "System.Int32"
                },
                {
                    "Name": "RebootNodeIfNeeded",
                    "Value": true,
                    "TypeName": "System.Boolean"
                },
                {
                    "Name": "ActionAfterReboot",
                    "Value": "ContinueConfiguration",
                    "TypeName": "System.String"
                },
                {
                    "Name": "AllowModuleOverwrite",
                    "Value": true,
                    "TypeName": "System.Boolean"
                },
                {
                    "Name": "Timestamp",
                    "Value": "MM/dd/yyyy H:mm:ss tt",
                    "TypeName": "System.String"
                }
            ]
        }
    }
}

我知道它使用的是旧格式,但这样就可以了,嗯。