{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "machineName": {
      "defaultValue": "",
      "type": "string",
      "minLength": 1,
      "maxLength": 15,
      "metadata": {
        "description": "The name of the virtual machine. "
      }
    },
    "deployname": {
      "type": "string"
    },
    "existingStorageUrl": {
      "type": "string",
      "metadata": {
        "description": "The storage Url. Example is like https://{storageaccountname}.blob.core.windows.net/{containername}/{blobname}. "
      }
    },
    "existingSASKey": {
      "type": "securestring",
      "metadata": {
        "description": "The sasToken required to access existingStorageUrl. It requires read and write permissions to save some temp data. "
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    },
    "RoleType": {
      "type": "string",
      "defaultValue": "Passive",
      "allowedValues": [
        "DP",
        "MP",
        "SUP"
      ],
      "metadata": {
        "description": "Role type of VM."
      }
    }
  },
  "variables": {
    "Quotes": "\""
  },
  "resources": [
    {
      "condition": "[equals(parameters('RoleType'),'MP')]",
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2018-06-01",
      "name": "[concat(parameters('machineName'),'/WorkFlow-MP',parameters('deployname'))]",
      "location": "[parameters('location')]",
      "properties": {
        "publisher": "Microsoft.Powershell",
        "type": "DSC",
        "typeHandlerVersion": "2.21",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "modulesUrl": "[Uri(parameters('existingStorageUrl'),concat('scripts/DSCConfiguration.zip',parameters('existingSASKey')))]",
          "configurationFunction": "MPConfigurationExist.ps1\\MPconfigurationExist"
        }
      }
    },
    {
      "condition": "[equals(parameters('RoleType'),'DP')]",
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2018-06-01",
      "name": "[concat(parameters('machineName'),'/WorkFlow-DP',parameters('deployname'))]",
      "location": "[parameters('location')]",
      "properties": {
        "publisher": "Microsoft.Powershell",
        "type": "DSC",
        "typeHandlerVersion": "2.21",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "modulesUrl": "[Uri(parameters('existingStorageUrl'),concat('scripts/DSCConfiguration.zip',parameters('existingSASKey')))]",
          "configurationFunction": "DPConfigurationExist.ps1\\DPconfigurationExist"
        }
      }
    },
    {
      "condition": "[equals(parameters('RoleType'),'SUP')]",
      "type": "Microsoft.Compute/virtualMachines/extensions",
      "apiVersion": "2018-06-01",
      "name": "[concat(parameters('machineName'),'/WorkFlow-SUP',parameters('deployname'))]",
      "location": "[parameters('location')]",
      "properties": {
        "publisher": "Microsoft.Powershell",
        "type": "DSC",
        "typeHandlerVersion": "2.21",
        "autoUpgradeMinorVersion": true,
        "settings": {
          "modulesUrl": "[Uri(parameters('existingStorageUrl'),concat('scripts/DSCConfiguration.zip',parameters('existingSASKey')))]",
          "configurationFunction": "SUPConfigurationExist.ps1\\SUPconfigurationExist"
        }
      }
    }
  ],
  "outputs": {

  }
}
