Open afscrome opened 3 years ago
Good find - it would be great if we could somehow catch this at least for new resource declarations. For an existing
resource, I don't think we would be able to know if the identity
property was set until runtime.
Bicep version Bicep CLI version 0.3.255 (589f0375df) VSCode 0.3.255
Describe the bug
Auto Completion will recommend the
identity
property as existing on a web app resource. However this property isn't always defined, and thus if you try and access it in an output variable, it can lead to a deployment time error.Is it possible for bicep to detect this and turn this error into a compile time error/warning. (e.g. if the
identity
property was marked as nullable on the web apps API, could bicep present a warning onoutput x string = webApp.identity.principalId
about trying to access theprincipalId
property on a potentially null value?To Reproduce
Additional context
The root cause here is that the web app only contains an
identity
property if it has an identity assigned. (In hindsight this makes sense, although the error from the ARM Api isn't particularly helpful at helping you realise the root cause)The above template can be fixed by specifying a managed identity on the webApp resource: