并行编译Azure自动化帐户上的多个DSC配置

时间:2016-11-11 16:33:05

标签: powershell azure dsc

我的自动化帐户上有几个DSC配置。当我单独编译它们时一切都很好但是如果我同时运行2个或更多编译,则会发生一些编译因类似于以下错误而失败的错误:

  

运行命令已停止,因为首选项变量“ErrorActionPreference”或common参数设置为Stop:找不到路径'C:\ Users \ Client \ Temp \ tempconfig \ 946ab078-a97f-45ee-b6a5-5d24bd76489d \'因为它不存在。

  

收藏被修改;枚举操作可能无法执行。 (集合已修改;枚举操作可能无法执行。)

  

无法索引到空数组。 (无法索引到空数组。)

我的配置就像这样简单:

Configuration TempConfig
{
    Import-DscResource -ModuleName PSDesiredStateConfiguration

    Node 'localhost' {
        WindowsFeature InstallDotNetFrameworkCore
        {
            Ensure = 'Present'
            Name = 'NET-Framework-Core'
        }
    }
}

当我编译多次相同的配置以及编译不同的多个配置时(但就像上面的那个一样简单),会出现问题。 实际上没有规则,我随机得到这些错误。 这是Azure的某种限制还是我做错了什么?

2 个答案:

答案 0 :(得分:0)

@Loku,

您是否在配置中使用了集合?

当您同时多次编译相同的配置时,是否收到这些错误?

  
    

收藏被修改;枚举操作可能无法执行。 (集合已修改;枚举操作可能无法执行。)

         

无法索引到空数组。 (无法索引到空数组。)

  

您是否可以提供配置脚本(没有任何秘密)?

答案 1 :(得分:0)

我也遇到这个问题,解决方案是在配置资源中使用dependsOn属性将它们有效地链接在一起,因为它们是串行执行的,而不是并行执行的。

这是一个例子

    {
      "name": "[variables('dscConfigurations').DomainJoinConfig.name]",
      "type": "configurations",
      "apiVersion": "2015-10-31",
      "location": "[variables('location')]",
      "dependsOn": [
        "[variables('AutomationAccountName')]",
        "dscDomainAdmin"
      ],
      "properties": {
        "state": "Published",
        "overwrite": "true",
        "source": {
          "type": "uri",
          "value": "[concat(parameters('_artifactsLocation'), variables('dscConfigurations').DomainJoinConfig.script, parameters('_artifactsLocationSasToken'))]"
        }
      }
    },
    {
      "name": "[variables('dscConfigurations').AddServerRolesAndFeaturesArchive.name]",
      "type": "configurations",
      "apiVersion": "2015-10-31",
      "location": "[variables('location')]",
      "dependsOn": [
        "[variables('AutomationAccountName')]",
        "[variables('dscResources').xPendingReboot.name]",
        "[variables('dscConfigurations').DomainJoinConfig.name]"
      ],
      "properties": {
        "state": "Published",
        "overwrite": "true",
        "source": {
          "type": "uri",
          "value": "[concat(parameters('_artifactsLocation'), variables('dscConfigurations').AddServerRolesAndFeaturesArchive.script, parameters('_artifactsLocationSasToken'))]"
        }
      }
    },
    {
      "name": "[variables('dscConfigurations').AddServerRoleAndFeaturesContent.name]",
      "type": "configurations",
      "apiVersion": "2015-10-31",
      "location": "[variables('location')]",
      "dependsOn": [
        "[variables('AutomationAccountName')]",
        "[variables('dscResources').xPendingReboot.name]",
        "[variables('dscConfigurations').AddServerRolesAndFeaturesArchive.name]"
      ],
      "properties": {
        "state": "Published",
        "overwrite": "true",
        "source": {
          "type": "uri",
          "value": "[concat(parameters('_artifactsLocation'), variables('dscConfigurations').AddServerRoleAndFeaturesContent.script, parameters('_artifactsLocationSasToken'))]"
        }
      }
    },