AZ-104: Deploy and manage Azure compute resources lab08 not working

Melvin Baskin 0 Reputation points
2024-07-13T20:32:24.4466667+00:00

If you past the supplied json file into the template, it will not validate and reports multiple errors:

In {

        "type": "Microsoft.Compute/virtualMachines/extensions",

        "name": "az104-08-vm1/customScriptExtension",

        "apiVersion": "2018-06-01",

        "location": "[resourceGroup().location]",

        "dependsOn": [

            "az104-08-vm1"

        ],

        "properties": {

            "publisher": "Microsoft.Compute",

            "type": "CustomScriptExtension",

            "typeHandlerVersion": "1.7",

            "autoUpgradeMinorVersion": true,

            "settings": {

                "commandToExecute": "powershell.exe Install-WindowsFeature -name Web-Server -IncludeManagementTools && powershell.exe remove-item 'C:\\inetpub\\wwwroot\\iisstart.htm' && powershell.exe Add-Content -Path 'C:\\inetpub\\wwwroot\\iisstart.htm' -Value $($env:computername)"

          }

        }

    },, the save bubble, block the end of the script, so you can't see how should be terminated 

    {

        "type": "Microsoft.Compute/virtualMachines/extensions",

        "name": "az104-08-vm1/customScriptExtension",

        "apiVersion": "2018-06-01",

        "location": "[resourceGroup().location]",

        "dependsOn": [

            "az104-08-vm1"

        ],

        "properties": {

            "publisher": "Microsoft.Compute",

            "type": "CustomScriptExtension",

            "typeHandlerVersion": "1.7",

            "autoUpgradeMinorVersion": true,

            "settings": {

                "commandToExecute": "powershell.exe Install-WindowsFeature -name Web-Server -IncludeManagementTools && powershell.exe remove-item 'C:\\inetpub\\wwwroot\\iisstart.htm' && powershell.exe Add-Content -Path 'C:\\inetpub\\wwwroot\\iisstart.htm' -Value $($env:computername)"

          }

        }

    },
Azure DevTest Labs
Azure DevTest Labs
An Azure service that is used for provisioning development and test environments.
263 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. mikelydick 76 Reputation points
    2024-07-13T22:15:56.5366667+00:00

    There are duplicated JSON listed, was there a reason for this?

    The provided JSON is missing some required elements for an Azure VM ARM template, which could be the reason for its failure. To further diagnose the issue, we would need the specific error message. Below is a more complete example with additional adjustments:

    1. Trailing Commas: Removed the trailing commas after the last elements in arrays and objects.
    2. Invalid Escape Sequences: Ensured that backslashes are properly escaped by using double backslashes (\\).
    3. Duplicate Entries: Removed the duplicated JSON object to ensure there is only one instance of the object.
    4. Missing JSON elements: Added the missing outer structure to make it a complete ARM template

    Updated example:

    {
    
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    
      "contentVersion": "1.0.0.0",
    
      "parameters": {},
    
      "variables": {},
    
      "resources": [
    
    {
    
      "type": "Microsoft.Compute/virtualMachines/extensions",
    
      "name": "az104-08-vm1/customScriptExtension",
    
      "apiVersion": "2018-06-01",
    
      "location": "[resourceGroup().location]",
    
      "dependsOn": [
    
        "az104-08-vm1"
    
      ],
    
      "properties": {
    
        "publisher": "Microsoft.Compute",
    
        "type": "CustomScriptExtension",
    
        "typeHandlerVersion": "1.7",
    
        "autoUpgradeMinorVersion": true,
    
        "settings": {
    
          "commandToExecute": "powershell.exe Install-WindowsFeature -name Web-Server -IncludeManagementTools && powershell.exe remove-item 'C:\\inetpub\\wwwroot\\iisstart.htm' && powershell.exe Add-Content -Path 'C:\\inetpub\\wwwroot\\iisstart.htm' -Value $($env:computername)"
    
        }
    
      }
    
    }
     ],
    
      "outputs": {}
    
    }
    
    0 comments No comments