Azure / Azure/azure-powershell
Start-AzureRmAutomationDscCompilationJob: No way to automate compilation versions created, using the -IncrementNodeConfigurationBuild switch
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Cmdlet(s)
Start-AzureRmAutomationDscCompilationJob
### PowerShell Version
Instructions: to get PowerShell version, type `$PSVersionTable` and look for the value associated with `PSVersion`
```
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 5.1.15063.296
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.296
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
```
### Module Version
```
PS C:\> Get-Command Start-AzureRmAutomationDscCompilationJob
CommandType Name Version Source
----------- ---- ------- ------
Cmdlet Start-AzureRmAutomationDscCompilationJob 3.4.0 AzureRM.Automation
```
### OS Version
Instructions: to get OS version, type `$PSversionTable` and look for value associated with `BuildVersion`
Windows 10 Enterprise
### Description
#### Background
I originally thought this was an issue with the DSC VM extension, that I wrote about [here](https://github.com/Azure/azure-powershell/issues/4775). I have since managed to identify the exact cause of the issue; relates to managing DSC compilation versions, generated by using the `-IncrementNodeConfigurationBuild` switch as part of the aforementioned cmdlet. It might be caused by user error / lack of documentation, but afaik, the following holds true:
If a DSC configuration is compiled using the `-IncrementNodeConfigurationBuild` switch, in the portal, under Automation account > DSC configurations > {ConfigName} > Node configurations, we see [n] appended to the configuration' name, incrementing by 1, each time the configuration is compiled.
If compile _without_ the `-IncrementNodeConfigurationBuild` switch, the latest version is updated.
All well and good. This has recently been added to the documentation [here](https://docs.microsoft.com/en-us/powershell/module/azurerm.automation/start-azurermautomationdsccompilationjob?view=azurermps-4.4.1) (Example 2)
#### Problem
The problem is two-fold 1) how does one programmatically (using PowerShell) differentiate between these versions? None of the below cmdlets show the version numbers (array).
```
Get-AzureRmAutomationDscConfiguration
Get-AzureRmAutomationDscCompilationJob
Get-AzureRmAutomationDscCompilationJobOutput
```
I can see x objects, which relate to [0], [1], [2] etc but LCM needs the name which seems to include a version number. From the error in the Debug section:
`Cannot find module myDSCResource_1.4.4.11`
1.4.4.11 comes from Version=1.4.4.11 in the DSC .psd1 file.
The reason for this error is because the template is looking for myDSCResource_1.4.4.11 in MyConfiguration (which has been deleted) as opposed to myDSCResource_1.4.4.18 in MyConfiguration[3]
If I try to tell it to use `MyConfiguration[4]` it fails with a similar message that it cannot be found.
```
Start-DscConfigurationCompilation : An error occurred getting DscConfiguration: ResourceNotFound: The Resource
'Microsoft.Automation/automationAccounts/AA-003/configurations/MyConfiguration[3]' under resource group 'RG-XYZ-001' was not found.
At D:\REPO\Arcotek\Azure.Automation\BRANCH.Auto\PS.Modules\TemplateDeployment\functions\public\Invoke-ConfigurationPhase.ps1:153 char:13
+ Start-DscConfigurationCompilation `
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Start-DscConfigurationCompilation
```
I only seem to be able to reference the name of the original configuration.
The other problem is how to remove the configuration and all compilation versions. I can remove them from the portal, but once I re-publish and compile all versions come back. You may notice that I say version 1.4.4.11 was deleted. I can't recall exactly how I got rid of it, but I think it was a case of leaving it overnight. So something is being 'cached'.
#### Solution
IMHO, we need to be able to:
1. Specify the compilation instance [0],[1],[2] etc or the version 1.4.4.11, 1.4.4.12 etc... (If we can already, how?)
2. Add the version number to the output of the three listed commands (above) and a parameter for the input of a version number. Whether this is the instance or true module version number, is up to you.
### Debug Output
Full error below. I know this is showing a different cmdlet, but it's showing this error because I cannot reference the correct DSC configuration version:
```
New-AzureRmResourceGroupDeployment : 15:31:29 - Resource Microsoft.Compute/virtualMachines/extensions 'MyAzureVM/Configure-DSC' 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 'Configure-DSC'. Error message: \"DSC Configuration 'ConfigureLCMforAAPull' completed with error(s). Following are the first few: Cannot find module myDSCResource_1.4.4.11 from the server
https://wcus-agentservice-prod-1.azure-automation.net/accounts/d27g21fg-143c-2e4a-02dd-650a1d2218ee/Modules(ModuleName='myDSCResource',ModuleVersion='1.4.4.11')/ModuleContent.\"."
}
]
}
}'
At D:\Users\john\Source\Workspaces\ARCOTEK\Azure.Automation\BRANCH.Auto\PS.Modules\TemplateDeployment\Functions\Public\Invoke-Deployment.ps1:94 char:19
+ $Result = New-AzureRmResourceGroupDeployment @DeploySplat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
New-AzureRmResourceGroupDeployment : 15:31:30 - VM has reported a failure when processing extension 'Configure-DSC'. Error message: "DSC Configuration 'ConfigureLCMforAAPull' completed with error(s). Following are the first few: Cannot find module
myDSCResource_1.4.4.11 from the server https://wcus-agentservice-prod-1.azure-automation.net/accounts/d27g21fg-143c-2e4a-02dd-650a1d2218ee/Modules(ModuleName='myDSCResource',ModuleVersion='1.4.4.11')/ModuleContent.".
At D:\Users\john\Source\Workspaces\ARCOTEK\Azure.Automation\BRANCH.Auto\PS.Modules\TemplateDeployment\Functions\Public\Invoke-Deployment.ps1:94 char:19
+ $Result = New-AzureRmResourceGroupDeployment @DeploySplat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
New-AzureRmResourceGroupDeployment : 15:31:30 - Template output evaluation skipped: at least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
At D:\Users\john\Source\Workspaces\ARCOTEK\Azure.Automation\BRANCH.Auto\PS.Modules\TemplateDeployment\Functions\Public\Invoke-Deployment.ps1:94 char:19
+ $Result = New-AzureRmResourceGroupDeployment @DeploySplat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
New-AzureRmResourceGroupDeployment : 15:31:30 - Template output evaluation skipped: at least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
At D:\Users\john\Source\Workspaces\ARCOTEK\Azure.Automation\BRANCH.Auto\PS.Modules\TemplateDeployment\Functions\Public\Invoke-Deployment.ps1:94 char:19
+ $Result = New-AzureRmResourceGroupDeployment @DeploySplat
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet
```
### Support Teams
I'm not sure what the relationship is between the people who work on bugs raised in github and those dealing with bugs raised via support channels. Assuming Microsoft have their ducks in a row, I have an open support ticket on this issue. ID: 117101216486817. Raising a support request is a last resort as I find a better response on here as I assume I am dealing with the actual developers (product team), whereas my timezone dictates a delay in relaying information to the actual developer.
If you need further information, please do not hesitate to get in touch.
Contributor guide
Assessment
This issue has not been assessed yet.