2017-06-13 5 views
0

Ich brauche einen DSC-Konfigurationsparameter ([PSCredential] RegistrationKey) zu schützen, so habe ich es ausdrückte unter "settings.protectedSettings.configurationData" so:ARM Template DSC: Konfiguration nicht 'sehen' protectedSettings.configurationArguments

"protectedSettings": { 
       "configurationArguments": { 
        "RegistrationKey": { 
        "UserName": "PLACEHOLDER_DONOTUSE", 
        "Password": "[parameters('dscAutomationRegistrationKey')]" 
        } 
       }, 
       "configurationUrlSasToken": "[parameters('artifactsLocationSasToken')]" 
       } 

ich den Fehler:

"VM has reported a failure when processing extension 'Microsoft.Powershell.DSC'. Error message: \"The DSC Extension failed to execute: Mandatory 
parameter RegistrationKey is missing. 

Wenn ich RegistrationKey aus „settings.protectedSettings.configurationArguments“, in „settings.configurationArguments“ bewegen, es funktioniert, also nehme ich an, es ist nichts falsch mit der Syntax, so dass ich glaube, es ist mitzu tun, die nicht in der DSC-Konfiguration enthalten war.

(Ich habe versucht, den Konfigurationsblock in der PS1-Datei aufgenommen werden, aber dies auf einen Fehler warf, was darauf hindeutet, dies nicht getan werden kann)

ich jetzt eine Konfigurationsdaten PSD1-Datei geschrieben, die folgende enthält:

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

und referenzierte es in settings.configurationdata.url.

Dies ergibt sich nun im gleichen Fehler wie zuvor: VM einen Fehler gemeldet hat ...

Die ARM-Vorlage wird von Powershell genannt:

$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 

Wo ich die Parameter glauben geben werden als die richtigen Typen.

Was mache ich falsch?

Referenzvorlage: https://github.com/Azure/azure-quickstart-templates/blob/master/dsc-extension-azure-automation-pullserver/azuredeploy.json

ein neueres DSC-Schema verwenden aktualisiert: https://blogs.msdn.microsoft.com/powershell/2016/02/26/arm-dsc-extension-settings/

Antwort

0

dies ist die Vorlage, die ich für Knoten Onboarding habe mit:

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

Ich weiß, sie eine mit altes Format, aber das funktioniert so, meh.

Verwandte Themen