Share via

VM DSC Extension not registering with Automation Account

Patrick Horne 5 Reputation points
2024-01-29T21:36:55.09+00:00

I'm provisioning a VM via bicep, I use the following code to include the DSC extension which should register with an automation account and connect to DSC and use a NodeConfiguration:
The extension provisions but never connects to the automation account to try o download the config. I know the registration URL and access key are correct as I output them at the end of the bicep deployment to ensure they are resolving correctly in the deployment and I've matched them with what I can see for the automation account in the portal (and via powershell). The nodeconfguration name is correct as well.

When the I check the extension after it has deployed I see this in the log

A DSC configuration was not provided. PowerShell DSC has been enabled on the VM, will exit now.\r\n[2024-01-29 21:31:42Z] Settings handler status to 'success'

As far as I can see I am providing the config as seen in my bicep code below. I check the dsc logs on the vm and see no errors (or any attempts to apply any config).

I've even tried hardcoding the Registration URL and Access Key instead of using parameters and variables and I get the same result.

Im at a complete loss as to where to look next? Anyone got any ideas?

(I should add that if I deploy without the extension and then add it as a node to Azure DSC after, it installs the extension and connects and downloads the config no problem)

// Deploy DSC Extension
resource resDcDscExtension 'Microsoft.Compute/virtualMachines/extensions@2023-09-01' = {
  parent: resDcVm
  name: 'Dsc-Extension-Dc01'
  location: parLocation
  properties: {
    publisher: 'Microsoft.Powershell'
    type: 'DSC'
    typeHandlerVersion: '2.9'
    autoUpgradeMinorVersion: true
    settings: {
      wmFVersion: 'latest'
      configuration: {
        name: parDscConfigName
        RegistrationUrl: varRegistrationUrl
        NodeConfigurationName: 'createDomain.Localhost'
        }
      privacy: {
        datacollection: 'disable'
      }
    }
  protectedSettings: {
    configurationArguments: {
      RegistrationKey: {
        username: 'NOT_USED'
        password: varRegistrationKey
      }
    }
  }
  }
}
Azure Automation
Azure Automation

An Azure service that is used to automate, configure, and install updates across hybrid environments.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Amira Bedhiafi 41,386 Reputation points MVP Volunteer Moderator
    2026-05-04T16:22:44.13+00:00

    protectedSettings.configurationArguments

    he issue is most likely the DSC extension schema, not the Automation Account URL/key.

    In your Bicep, you are putting these values inside:

    settings.configuration
    

    But settings.configuration is not where RegistrationUrl, RegistrationKey or NodeConfigurationName should go. That block must define the DSC configuration package to execute, using fields like url, script and function. DSC extension schema shows configuration.url, configuration.script and configuration.function while parameters go under configurationArguments.

    https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/dsc-template

    Because your configuration block does not contain a valid script/package, the handler logs a DSC configuration was not provided, so it enables DSC locally and exits without registering the node.

    resource resDcDscExtension 'Microsoft.Compute/virtualMachines/extensions@2023-09-01' = {
      parent: resDcVm
      name: 'Dsc-Extension-Dc01'
      location: parLocation
      properties: {
        publisher: 'Microsoft.Powershell'
        type: 'DSC'
        typeHandlerVersion: '2.77'
        autoUpgradeMinorVersion: true
        settings: {
          wmfVersion: 'latest'
          configuration: {
            url: parRegistrationMetaConfigZipUrl
            script: 'RegistrationMetaConfigV2.ps1'
            function: 'RegistrationMetaConfigV2'
          }
          configurationArguments: {
            RegistrationUrl: varRegistrationUrl
            NodeConfigurationName: 'createDomain.Localhost'
            ConfigurationMode: 'ApplyAndMonitor'
            ConfigurationModeFrequencyMins: 15
            RefreshFrequencyMins: 30
            RebootNodeIfNeeded: false
            ActionAfterReboot: 'ContinueConfiguration'
            AllowModuleOverwrite: true
          }
          privacy: {
            dataCollection: 'disable'
          }
        }
        protectedSettings: {
          configurationArguments: {
            RegistrationKey: {
              userName: 'NOT_USED'
              password: varRegistrationKey
            }
          }
        }
      }
    }
    

    The important change is:

    RegistrationUrl
    NodeConfigurationName
    ConfigurationMode
    RefreshFrequencyMins
    

    should be under:

    settings.configurationArguments
    

    and the registration key should be under:

    protectedSettings.configurationArguments
    
    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.