Skip to content

ARM Template with JSON Comments not working #316

Description

It seems that deploying ARM Templates that contain JSON comments isn't working. There are 2 parts to this:

Part 1: .jsonc files

When trying to deploy a ARM Template with a .jsonc extension, I get error: Unsupported template file type: <file-path>

Seems to be caused by this line:

if (templateFile && path.extname(templateFile).toLowerCase() !== ".json") {
throw new Error(errorMessages.unsupportedTemplateFile(templateFile));
}

Presumably here too:
path.extname(parametersFile).toLowerCase() !== ".json"
) {
throw new Error(errorMessages.unsupportedParametersFile(parametersFile));

Part 2: Comments in ARM Template JSON

When trying to deploy a ARM Template with inline comments, I get error: Expected double-quoted property name in JSON at position 9230 (line 240 column 36).
Per MS Docs, comments in ARM Templates are supported: https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/syntax#comments

I believe it's that the JSON.parse doesn't support comments...

const parametersContents = parameters ? JSON.parse(parameters) : undefined;
const templateContents = template ? JSON.parse(template) : undefined;

Unfortunately, that's as far as my understanding goes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions