2017-06-13 93 views
0

我需要保护的DSC配置参数(PSCredential的] RegistrationKey),所以我把它放在“settings.protectedSettings.configurationData”下这样的:ARM模板DSC:配置不“看” protectedSettings.configurationArguments

"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”,它的工作原理,因此,我认为没有什么不妥的语法,所以我相信这是与0123合作未包含在DSC配置中。

(我试图包括在PS1文件中的配置块,但是这引发了错误,这表明这不能完成)

现在我已经写了configurationdata的.psd1文件,包含以下内容:

$ConfigData = @{ 
    AllNodes = @(
     @{ 
     NodeName = "*" 
     PsDscAllowPlainTextPassword = $true 
     } 
    ) 
} 

并在settings.configurationdata.url中引用它。

现在,这将导致相同的错误面前:VM报告出现了故障......

ARM的模板是从PowerShell中称为:

$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 

在哪里,我相信这些参数被作为传递正确的类型。

我在做什么错?

参考模板: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/

回答

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" 
       } 
      ] 
     } 
    } 
} 

我知道使用它的旧格式,但是这样的工作,嗯。