Azure / bicep

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

Bicep REPL #11963

Open mattias-fjellstrom opened 1 year ago

mattias-fjellstrom commented 1 year ago

Is your feature request related to a problem? Please describe. Constructing complicated expressions using one or more built-in functions in Bicep can be tricky, and there is a need to test the expressions. In my experience this is most often string manipulation functions, but it could also be something else. To test these types of expressions today you need to create an actual deployment at a scope in Azure. This is unnecessarily time consuming.

Describe the solution you'd like A REPL/console experience similar to what Terraform has (terraform console) that has most functions available for testing. Only functions that make sense need to be included, i.e. resourceGroup() would not make sense in a REPL unless you can scope the REPL to a given scope in Azure (e.g. a resource group).

Example:

$ az bicep console
> take('one two three', 3)
'one'
>
> var arrayString = [
  'one'
  'two'
  'three'
]
> join(arrayString, ',')
'one,two,three'
mattias-fjellstrom commented 11 months ago

Addendum:

Perhaps the REPL can be started in a given scope by adding a flag to the command, then even scope-like functions like resourceGroup() would be available, e.g.:

$ az bicep console --scope /subscriptions/<id>/resourceGroups/rg-sample
> resourceGroup().location
'swedencentral'
>
> resourceGroup().name
'rg-sample'