Coder Perfect

Use @decorators in Bicep for params of type object?

Problem

I can use @decorators for some form of “validation” with a “simple” argument in Bicep, like this:

@minLength(3)
@maxLength(20)
@description('Name of database administrator')
param dbAdminUsername string = 'dbadmin'

This would make the dbAdminUsername param between 3 and 20 characters long, as well as provide a description.

I’d like to “collect together” all of the database parameters I have, such as username, password, server name, database name, and so on. So here’s how I’d define an object:

param db object = {
  adminName: 'dbadmin'
  serverName: 'foo'
  size: 42
  // ...
}

Object-related questions:

Asked by Alexander Skwar

Solution #1

It isn’t feasible (yet). There‚Äôs ongoing discussion how to define such conditions: https://github.com/Azure/bicep/issues/622

Any extra information is much appreciated!

Answered by Miq

Post is based on https://stackoverflow.com/questions/68037504/use-decorators-in-bicep-for-params-of-type-object