Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.21k stars 745 forks source link

Suggestion: Refactor: Extract variable, parameter, type #14535

Open SimonWahlin opened 2 months ago

SimonWahlin commented 2 months ago

Is your feature request related to a problem? Please describe. I often start to write a bicep template by creating a resource (manually or exported from existing resource) and then add parameters and potential logic from there.

Adding parameters is a tedious and time consuming task.

Describe the solution you'd like It would be really nice to be able to create a parameter from any property in my template by for example right-clicking and choosing "create parameter" or by setting the cursor on a property and use a command for "create parameter".

I would expect the parameter to have the same name and type as the property (maybe even a resource derived type if that feature is enabled) as the property and have a default value of what is currently assigned to the property.

The property should then have the parameter reference as a value.

If the property has a description in the type definition I would also expect the parameter to have the same description.

StephenWeatherford commented 2 weeks ago

Issue: open enums

Upvote if you want better support for this: https://github.com/Azure/bicep/issues/10432

One of the most common issues I'm seeing in generating user-defined param types for resource properties is open unions e.g.:

param kind 'BlobStorage' | 'BlockBlobStorage' | 'FileStorage' | 'Storage' | 'StorageV2' | string = 'StorageV2'

This is equivalent to "allow any string but here are suggestions".

These are the choices I see: Image I'm currently going with (4) since it is semantically equivalent, but you do lose intellisense.