How can I provide suggestions for parameter without enforcing validation in bicep?

55 views Asked by At

I'm developing bicep templates for our developers and wan't to provide suggestion for SKU's.

I'm using a user defined type for this but when doing that the user is enforced to choose one of the values that I declared, I want them able to choose what they want but get the suggestions from my type.

This is what I have:

type Sku = 'P0v3' | 'P1v3'

But I want something like this :

type Sku = 'P0v3' | 'P1v3' | *wildcard*

Is there any way or workaround to achieve that in bicep? Thanks!

1

There are 1 answers

5
Jahnavi On BEST ANSWER

You can use any() function in bicep as a workaround. In your scenario, it can be used to modify user input to Sku type. Sample way is shown below.

type Sku = 'P0v3' | 'P1v3' 
param skuInput string  
var skunew = any(skuInput)

I tried deploying a sample storage account by applying the above function and was deployed successfully as shown.

enter image description here

enter image description here

As an alternative workaround, you can define type Sku = String. Later developers can provide their own values accordingly as detailed in MSDoc.