I am deploying a resource group by using the Azure REST API and supplying the ARM templates. In the virtual machine resource, I have an extension that is of type DSC
. The code snippet is as follows:
{
"resources": [
{
"name": "[concat(variables('VMName'),'/SetupScript')]",
"type": "Microsoft.Compute/virtualMachines/extensions",
"location": "[parameters('DNSLocation')]",
"apiVersion": "2015-05-01-preview",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('VMName'))]"
],
"tags": {
"displayName": "SetupScript"
},
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "1.7",
"settings": {
"modulesUrl": "[variables('SetupScriptConfigurationFile')]",
"sasToken": "",
"configurationFunction": "[variables('SetupScriptConfigurationFunction')]",
"properties": {
"DomainName": "[parameters('DomainName')]",
"DomainAdminUsername": "[parameters('VMAdminUsername')]",
"DomainAdminPassword": "[parameters('VMAdminPassword')]"
}
},
"protectedSettings": {
}
}
}
]
}
The DSC configuration that is being called is shown bellow:
Configuration DNSConfig
{
param
(
[string]$NodeName ='localhost',
[Parameter(Mandatory=$true)][string]$DomainName,
[Parameter(Mandatory=$true)][string]$DomainAdminUsername,
[Parameter(Mandatory=$true)][string]$DomainAdminPassword
)
#Import the required DSC Resources
Import-DscResource -Module xComputerManagement
Import-DscResource -Module xActiveDirectory
$securePassword = ConvertTo-SecureString -AsPlainText $DomainAdminPassword -Force;
$DomainAdminCred = New-Object System.Management.Automation.PSCredential($DomainAdminUsername, $securePassword);
Node $NodeName
{ #ConfigurationBlock
WindowsFeature DSCService {
Name = "DSC-Service"
Ensure = "Present"
IncludeAllSubFeature = $true
}
WindowsFeature ADDSInstall
{
Ensure = 'Present'
Name = 'AD-Domain-Services'
IncludeAllSubFeature = $true
}
WindowsFeature RSATTools
{
DependsOn= '[WindowsFeature]ADDSInstall'
Ensure = 'Present'
Name = 'RSAT-AD-Tools'
IncludeAllSubFeature = $true
}
xADDomain SetupDomain {
DomainName= $DomainName
DomainAdministratorCredential= $DomainAdminCred
SafemodeAdministratorPassword= $DomainAdminCred
DependsOn='[WindowsFeature]RSATTools'
}
#End Configuration Block
}
}
WHen I run the DSC script locally, to successfully generate the MOF file for this DSC Script, I need to pass in a hashtable for the ConfigurationData like so:
$ConfigData = @{
AllNodes = @(
@{
NodeName = '*'
PSDscAllowPlainTextPassword = $true
}
)
}
DNSConfig -ConfigurationData $ConfigData -DomainName "mydomain.com" ...
My problem now is that, I want to pass this type of ConfigurationData
through the ARM template that I showed first. Is it even possible? If not, then how should I set the ConfigurationData of the DSC Script that is executed by the VM Extension?
Thanks!