0

I have saved my arm template with yaml extension instead of json extension, because of this the vscode added trailing commas when I save the file.

Once I rename it, i am getting this error while arm template syntax check.

syntax error

How to fix this, there are many lines like these and unfortunately I don't have old file to replace.

My file:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata":
    {
      "_generator":
        {
          "name": "bicep",
          "version": "0.4.613.9944",
          "templateHash": "7822315097766237434",
        },
    },
  "parameters":
    {
      "adminUsername":
        {
          "type": "string",
          "metadata": { "description": "Username for the Virtual Machine." },
        },
      "adminPassword":
        {
          "type": "secureString",
          "minLength": 12,
          "metadata": { "description": "Password for the Virtual Machine." },
        },
      "publicIpName":
        {
          "type": "string",
          "defaultValue": "myPublicIP",
          "metadata":
            {
              "description": "Name for the Public IP used to access the Virtual Machine.",
            },
        },
      "publicIPAllocationMethod":
        {
          "type": "string",
          "defaultValue": "Dynamic",
          "allowedValues": ["Dynamic", "Static"],
          "metadata":
            {
              "description": "Allocation method for the Public IP used to access the Virtual Machine.",
            },
        },
      "publicIpSku":
        {
          "type": "string",
          "defaultValue": "Basic",
          "allowedValues": ["Basic", "Standard"],
          "metadata":
            {
              "description": "SKU for the Public IP used to access the Virtual Machine.",
            },
        },
      "OSVersion":
        {
          "type": "string",
          "defaultValue": "2019-Datacenter",
          "allowedValues":
            [
              "2008-R2-SP1",
              "2012-Datacenter",
              "2012-R2-Datacenter",
              "2016-Nano-Server",
              "2016-Datacenter-with-Containers",
              "2016-Datacenter",
              "2019-Datacenter",
              "2019-Datacenter-Core",
              "2019-Datacenter-Core-smalldisk",
              "2019-Datacenter-Core-with-Containers",
              "2019-Datacenter-Core-with-Containers-smalldisk",
              "2019-Datacenter-smalldisk",
              "2019-Datacenter-with-Containers",
              "2019-Datacenter-with-Containers-smalldisk",
            ],
          "metadata":
            {
              "description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version.",
            },
        },
      "vmSize":
        {
          "type": "string",
          "defaultValue": "Standard_D2_v3",
          "metadata": { "description": "Size of the virtual machine." },
        },
      "vmName":
        {
          "type": "string",
          "defaultValue": "simple-vm",
          "metadata": { "description": "Name of the virtual machine." },
        },
    },
  "functions": [],
  "variables":
    {
      "storageAccountName": "[format('bootdiags{0}', uniqueString(resourceGroup().id))]",
      "nicName": "myVMNic",
      "addressPrefix": "10.0.0.0/16",
      "subnetName": "Subnet",
      "subnetPrefix": "10.0.0.0/24",
      "virtualNetworkName": "MyVNET",
      "networkSecurityGroupName": "default-NSG",
      "dnsLabelPrefix": "[toLower(format('{0}-{1}', parameters('vmName'), uniqueString(resourceGroup().id, parameters('vmName'))))]",
      "location": "[resourceGroup().location]",
    },
  "resources":
    [
      {
        "type": "Microsoft.Storage/storageAccounts",
        "apiVersion": "2021-04-01",
        "name": "[variables('storageAccountName')]",
        "location": "[variables('location')]",
        "sku": { "name": "Standard_LRS" },
        "kind": "Storage",
      },
      {
        "type": "Microsoft.Network/publicIPAddresses",
        "apiVersion": "2021-02-01",
        "name": "[parameters('publicIpName')]",
        "location": "[variables('location')]",
        "sku": { "name": "[parameters('publicIpSku')]" },
        "properties":
          {
            "publicIPAllocationMethod": "[parameters('publicIPAllocationMethod')]",
            "dnsSettings":
              { "domainNameLabel": "[variables('dnsLabelPrefix')]" },
          },
      },
      {
        "type": "Microsoft.Network/networkSecurityGroups",
        "apiVersion": "2021-02-01",
        "name": "[variables('networkSecurityGroupName')]",
        "location": "[variables('location')]",
        "properties":
          {
            "securityRules":
              [
                {
                  "name": "default-allow-3389",
                  "properties":
                    {
                      "priority": 1000,
                      "access": "Allow",
                      "direction": "Inbound",
                      "destinationPortRange": "3389",
                      "protocol": "Tcp",
                      "sourcePortRange": "*",
                      "sourceAddressPrefix": "*",
                      "destinationAddressPrefix": "*",
                    },
                },
              ],
          },
      },
      {
        "type": "Microsoft.Network/virtualNetworks",
        "apiVersion": "2021-02-01",
        "name": "[variables('virtualNetworkName')]",
        "location": "[variables('location')]",
        "properties":
          {
            "addressSpace":
              { "addressPrefixes": ["[variables('addressPrefix')]"] },
            "subnets":
              [
                {
                  "name": "[variables('subnetName')]",
                  "properties":
                    {
                      "addressPrefix": "[variables('subnetPrefix')]",
                      "networkSecurityGroup":
                        {
                          "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]",
                        },
                    },
                },
              ],
          },
        "dependsOn":
          [
            "[resourceId('Microsoft.Network/networkSecurityGroups', variables('networkSecurityGroupName'))]",
          ],
      },
      {
        "type": "Microsoft.Network/networkInterfaces",
        "apiVersion": "2021-02-01",
        "name": "[variables('nicName')]",
        "location": "[variables('location')]",
        "properties":
          {
            "ipConfigurations":
              [
                {
                  "name": "ipconfig1",
                  "properties":
                    {
                      "privateIPAllocationMethod": "Dynamic",
                      "publicIPAddress":
                        {
                          "id": "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]",
                        },
                      "subnet":
                        {
                          "id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', variables('virtualNetworkName'), variables('subnetName'))]",
                        },
                    },
                },
              ],
          },
        "dependsOn":
          [
            "[resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]",
            "[resourceId('Microsoft.Network/virtualNetworks', variables('virtualNetworkName'))]",
          ],
      },
      {
        "type": "Microsoft.Compute/virtualMachines",
        "apiVersion": "2021-03-01",
        "name": "[parameters('vmName')]",
        "location": "[variables('location')]",
        "properties":
          {
            "hardwareProfile": { "vmSize": "[parameters('vmSize')]" },
            "osProfile":
              {
                "computerName": "[parameters('vmName')]",
                "adminUsername": "[parameters('adminUsername')]",
                "adminPassword": "[parameters('adminPassword')]",
              },
            "storageProfile":
              {
                "imageReference":
                  {
                    "publisher": "MicrosoftWindowsServer",
                    "offer": "WindowsServer",
                    "sku": "[parameters('OSVersion')]",
                    "version": "latest",
                  },
                "osDisk":
                  {
                    "createOption": "FromImage",
                    "managedDisk": { "storageAccountType": "StandardSSD_LRS" },
                  },
                "dataDisks":
                  [{ "diskSizeGB": 1023, "lun": 0, "createOption": "Empty" }],
              },
            "networkProfile":
              {
                "networkInterfaces":
                  [
                    {
                      "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",
                    },
                  ],
              },
            "diagnosticsProfile":
              {
                "bootDiagnostics":
                  {
                    "enabled": true,
                    "storageUri": "[reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))).primaryEndpoints.blob]",
                  },
              },
          },
        "dependsOn":
          [
            "[resourceId('Microsoft.Network/networkInterfaces', variables('nicName'))]",
            "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]",
          ],
      },
    ],
  "outputs":
    {
      "hostname":
        {
          "type": "string",
          "value": "[reference(resourceId('Microsoft.Network/publicIPAddresses', parameters('publicIpName'))).dnsSettings.fqdn]",
        },
    },
}
Sara June
  • 389
  • 4
  • 15

0 Answers0