bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Create error when using a resource id/name when using symbolic name templates

Open stephaniezyen opened this issue 1 year ago • 2 comments

As discussed in #12906 , we should create an error when using ".name" or ".id in symbolic name templates when using the listAccountSAS function:

listAccountSAS(storageAccount.name, '2023-01-01', { ... })

stephaniezyen avatar May 15 '24 16:05 stephaniezyen

The following should be blocked with an error for symbolic name templates, because it will error during deployment:

listAccountSAS(storageAccount.name, '2023-01-01', { ... })

The following is still technically valid in symbolic name templates, but not optimal. Ideally it would just raise a warning, but could be an error if it's too complex to differentiate:

listAccountSAS(storageAccount.id, '2023-01-01', { ... })

anthony-c-martin avatar May 15 '24 16:05 anthony-c-martin

Do we also want to update the error message to "Use a full resource ID..." instead of "Use a resource reference..." for clarity's sake?

@stephaniezyen to answer this question - the latter is correct - we are trying to recommend:

// here we're using a resource reference
storageAccount.listAccountSAS('2023-01-01', { ... })

Instead of:

// here we're using a resource id
listAccountSAS(storageAccount.id, '2023-01-01', { ... })

anthony-c-martin avatar May 15 '24 17:05 anthony-c-martin