为Azure Resource Manager模板部署DSC扩展时出现问题

时间:2017-06-30 00:07:34

标签: powershell azure iis

我尝试为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.\"."
      }
    ]
  }
}'

与此虚拟机配置相关的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')]"
    }
  }
}

至于已经引导的IIS powershell脚本:

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

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

  }
} 

2 个答案:

答案 0 :(得分:4)

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

      "configurationArguments": {
    "nodeName": "[variables('vmNameSQL')]"
  }

从ARM模板中删除

param ([string[]]$NodeName = 'localhost')

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

@iteong能够测试这个新配置并且有效。

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

  

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

答案 1 :(得分:2)

使用VM Extension通过ARM模板应用DSC配置时,Node参数必须始终为 localhost。

从Azure自动化中提取DSC配置时,您可以使用变量并执行一些奇特的工作来确定Node接收哪些配置。