简体   繁体   English

通过ARM模板运行DSC配置之前,请配置Azure VM LCM

[英]Configure Azure VM LCM before running DSC Configuration via ARM template

I'm trying to configure an Azure VM via an ARM template and need to set the Local Configuration Manager on the VM to allow reboots prior to running the DSC configuration. 我正在尝试通过ARM模板配置Azure VM,并且需要在VM上设置本地配置管理器以允许重新引导,然后再运行DSC配置。 I have a method that works at times but not always. 我有一种方法有时会起作用,但并非总是如此。 I'm running the following script via the Azure CustomScriptExtension 我正在通过Azure CustomScriptExtension运行以下脚本

[DscLocalConfigurationManager()]
Configuration ConfigureLcm {
  Node localhost {
    Settings {
        RebootNodeIfNeeded   = $true
    }
  }
}

if (!(Get-DscLocalConfigurationManager).RebootNodeIfNeeded) {
    ConfigureLcm -OutputPath C:\Config
    Set-DscLocalConfigurationManager -Path C:\Config
}

then the DSC extension. 然后是DSC扩展名。 It seems like the CustomScriptExtension works but then the DSC extension changes RebootNodeIfNeeded back to false, maybe. 看起来CustomScriptExtension可以正常工作,但是DSC扩展名可能会将RebootNodeIfNeeded重新设置为false。 The DSC extension depends on the CustomScriptExtension. DSC扩展取决于CustomScriptExtension。

{
  "type": "extensions",
  "name": "DSC",
  "apiVersion": "2015-06-15",
  "location": "[resourceGroup().location]",
  "dependsOn": [
    "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]",
    "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'),  '/extensions/configlcm')]"

Has any one else experienced this? 还有其他人经历过吗?

The DSC Extension will overwrite the Local Configuration Manager (LCM), if you do not have explicit settings for the LCM they will revert to the default. DSC扩展将覆盖本地配置管理器(LCM),如果您没有对LCM的明确设置,它们将恢复为默认设置。 Therefore you need to set it again in the Configuration Function you are using for your DSC Extension: 因此,您需要在用于DSC扩展的配置功能中再次进行设置:

Configuration Main
{
  Node localhost
  {
    LocalConfigurationManager
    {
      RebootNodeIfNeeded = $true
      ...
    }
    # Your other resources
    ...
  }
}´

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM