Azure / Azure/template-analyzer

An exception occurred while analyzing template.

Open
#323 7 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
143
Forks
47
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

We receive this error when we analyze bicep templates containing the metadata keyword. Removing the metadata keyword solves this problem, but we need this keyword for documentation and information purposes.

Information regarding this can be found in the reproduction steps.

We get the following errors:
![image](https://user-images.githubusercontent.com/9531411/226325807-90dc052c-95aa-4143-be19-a55c78624e86.png)

### Expected behavior

Template files are analyzed with the metadata section.

### Reproduction Steps

Sample bicep

`metadata info = {
name: 'RBAC Module'
description: 'This module deploys a Role Based Access assignments'
version: '1.0.0'
author: 'Maik van der Gaag'
}

param principalId string
param roleDefinitionResourceId string

@description('This is the built-in Contributor role. See https://docs.microsoft.com/azure/role-based-access-control/built-in-roles#contributor')
resource roleDefinition 'Microsoft.Authorization/roleDefinitions@2018-01-01-preview' existing = {
scope: subscription()
name: roleDefinitionResourceId
}

resource roleAssignment 'Microsoft.Authorization/roleAssignments@2020-04-01-preview' = {
name: guid(resourceGroup().id, principalId, roleDefinition.id)
properties: {
roleDefinitionId: roleDefinition.id
principalId: principalId
principalType: 'ServicePrincipal'
}
scope: resourceGroup()
}`

When we analyze this with '.\TemplateAnalyzer.exe analyze-template D:\source\rbac.bicep -v'

### Environment

- Local and on Microsoft build agents
- .Net 6

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.