Intellisense Support for VM DSC Extension Parameters
- Dominant language
- Bicep
- Stars
- 3.6k
- Forks
- 830
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 81
Description
A common requirement with Azure is to deploy a Virtual Machine and then provide a level of one-off configuration to the operating system. This is typically done through either the Custom Script Extension or the DSC Extension. The DSC extension supports configuration arguments to pass variables in at runtime. Currently in ARM (and bicep) templates it is the developers job to manually ensure that the arguments provided match up with both the parameter names and parameter types defined in the DSC Configuration. This can often lead to long retry attempts as DSC is often one of the last things to fail at deployment time.
An example Extension template would be:
```
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(parameters('VMName'),'/Microsoft.Powershell.DSC')]",
"apiVersion": "2020-06-01",
"location": "[resourceGroup().location]",
"properties": {
"publisher": "Microsoft.Powershell",
"type": "DSC",
"typeHandlerVersion": "2.77",
"autoUpgradeMinorVersion": true,
"settings": {
"configuration": {
"url": "[concat(parameters('_artifactsLocation'), '/DSC/DSC.zip')]",
"script": "ConfigureVM.ps1",
"function": "BasicVM"
},
"configurationArguments": {
"VMName": "[parameters('VMName')]",
"EnableVerboseLogging": false,
"ConsoleURL": "www.test.local"
}
},
"protectedSettings": {
"configurationUrlSasToken": "[parameters('_artifactsLocationSasToken')]"
}
}
}
```
With associated DSC:
```
configuration BasicVM
{
param
(
[Parameter(mandatory = $true)]
[string]$VMName,
[Parameter()]
[bool]$EnableVerboseMsiLogging = $false,
[Parameter(Mandatory = $true)]
[String]
$ConsoleURL
)
Node localhost
{
LocalConfigurationManager
{
RebootNodeIfNeeded = $true
ConfigurationMode = "ApplyOnly"
}
//Config Goes Here
}
}
```
What I would like to see is the automatic reading of defined DSC file parameters in a similar way to the way that bicep picks up module parameters and enables IntelliSense and compile-time checking of parameters. This would also possibly enable easier support for things like PowerShell credential objects (not the most intuitive to add to an ARM Template) and possibly even warning about having a secure string as an unprotected setting.
I appreciate that this task means understanding another language (PowerShell) however I believe that querying the PowerShell Abstract Syntax Tree or relying on the parser already written for PowerShell 7 (which is also MIT licensed, Microsoft owned and written in c#) should reduce the development needed. Alternatively, I don't know about how VS Code Extensions work but would it be possible to just rely on the PowerShell extension to expose sufficient data to the bicep extension?
Contributor guide
Research direction
The issue names no repository files or tests. Start by locating Bicep's existing module-parameter IntelliSense and compile-time validation entry points, then investigate whether PowerShell's AST/parser or VS Code PowerShell extension can expose DSC parameters. Done means matching parameter names and types and warning on insecure secrets in VM DSC extension configuration.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell, vscode
- Domain
- cloud, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100