Azure / Azure/bicep

Bicep Extension: Option to Extract Parameters from a Module

Open
#17,609 3 comments 1 reaction 0 assignees View on GitHub
enhancement Needs: Upvote
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 21m
Merged PRs (30d)
79

Description

**Is your feature request related to a problem? Please describe.**

Scenario:
- You've created a module which has lots of parameters, you've spent lots of time adding descriptions, allowed lists, etc for your users.
- You then create a `main.bicep` file and add a reference to your module
- You want to deploy to Dev, Test and Production environments so you create 3x `.bicepparams` file and import the parameters from `main.bicep`.

**Because `main.bicep` doesn't include the parameters for your module, you have to manually re-create each parameters to connect everything up.** For example, if your module has "SKU" then you need to create a "SKU" parameter in `main.bicep`.

This isn't a big issue itself but if your end-users don't have direct access to your published modules (i.e Bicep Registry) then **users cannot see the descriptions** so you also have to manually extract these from the module and place these in `main.bicep` for them.

**Describe the solution you'd like**

After importing module, it would be great if you could right click on the module, select an option named something like "Extract Parameters" and for it to automatically make a copy of the parameters.

Here's a very basic example. Assume this is `main.bicep`:
```
module myModule 'br:myacr/module/mymodule:1.0.0' = {
name: 'myname'
params:
{
Sku: //TODO
}
}
```
Selecting the resource and extracting parameters could result in this:
```
@description('The SKU of this module') // Extracted from the module
@allowed([ // Extracted from the module
'1',
'2',
])

param string myModule_Sku // Extracted from the module Note the name is format "resource_paramName"

module myModule 'br:myacr/module/mymodule:1.0.0' = {
name: 'myname'
params:
{
Sku: myModule_Sku // Automatically applied during the extract process
}
}
```

I could use Copilot to quickly create the parameters again fairly quickly but I don't believe it would be able to extract the @description etc.

Thank you for your consideration!

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Start by locating the Bicep extension entry point for module actions and parameter handling, then review how imported module metadata is exposed. Done means a module action can extract parameter descriptions and constraints, create main-file parameters, and wire them into the module call.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.