为Azure Resource Manager模板部署DSC扩展时遇到问题

ite*_*ong 1 iis powershell azure

我正在尝试为Windows虚拟机的配置部署Azure资源管理器模板。

目前,我正在将IIS Powershell脚本引导至DSC模块,以为通过ARM设置的Windows虚拟机设置IIS。

我不断收到与WinRM相关的错误:

New-AzureRmResourceGroupDeployment : 5:04:53 PM - Resource Microsoft.Compute/virtualMachines/extensions 'vmSVX-TESTAU-SQL1/dscExtension' failed with message '{
  "status": "Failed",
  "error": {
    "code": "ResourceDeploymentFailure",
    "message": "The resource operation completed with terminal provisioning state 'Failed'.",
    "details": [
      {
        "code": "VMExtensionProvisioningError",
        "message": "VM has reported a failure when processing extension 'dscExtension'. Error message: \"DSC Configuration 'vmDSC' completed with error(s). 
Following are the first few: The WinRM client cannot process the request. If the authentication scheme is different from Kerberos, or if the client computer is not joined to a domain, then HTTPS transport must be used or the destination machine must be added to the TrustedHosts configuration setting. Use winrm.cmd to 
configure TrustedHosts. Note that computers in the TrustedHosts list might not be authenticated. You can get more information about that by running the following command: winrm help config.\"."
      }
    ]
  }
}'
Run Code Online (Sandbox Code Playgroud)

与该VM的配置有关的ARM模板:

{
  "apiVersion": "2016-03-30",
  "type": "Microsoft.Compute/virtualMachines/extensions",
  "name": "[concat(variables('vmNameSQL'), '/', 'dscExtension')]",
  "location": "[variables('location')]",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', variables('vmNameSQL'))]"
  ],
  "properties": {
    "publisher": "Microsoft.Powershell",
    "type": "DSC",
    "typeHandlerVersion": "2.9",
    "autoUpgradeMinorVersion": true,
    "settings": {
      "configuration": {
        "url": "[variables('dscModulesUrl')]",
        "script": "[concat(variables('dscFunction'),'.ps1')]",
        "function": "[variables('dscFunction')]"
      },
      "configurationArguments": {
        "nodeName": "[variables('vmNameSQL')]"
      }
    },
    "protectedSettings": {
      "configurationUrlSasToken": "[parameters('_artifactsLocationSasToken')]"
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

至于已引导的IIS powershell脚本:

Configuration WindowsFeatures
{
  param ([string[]]$NodeName = 'localhost')

  Node $NodeName
  {
    #Install the IIS Role
    WindowsFeature IIS
    {
      Ensure = “Present”
      Name = “Web-Server”
    }

  }
} 
Run Code Online (Sandbox Code Playgroud)

Ctr*_*Dot 5

与各方聊天之后,我们最终删除了

      "configurationArguments": {
    "nodeName": "[variables('vmNameSQL')]"
  }
Run Code Online (Sandbox Code Playgroud)

从ARM模板中删除

param ([string[]]$NodeName = 'localhost')
Run Code Online (Sandbox Code Playgroud)

从DSC配置。我们还将节点设置为“ localhost”。

@iteong能够测试此新配置,并且有效。

要添加的另一点是完整的错误消息与上面显示的不同:

[错误]找不到与参数名称'nodeName'匹配的参数。\ n \ n另一个常见错误是指定类型为PSCredential的参数而没有显式类型。