{
  "id": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Template",
  "description": "An Azure deployment template",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string",
      "description": "JSON schema reference"
    },
    "contentVersion": {
      "type": "string",
      "pattern": "(^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+$)",
      "description": "A 4 number format for the version number of this template file. For example, 1.0.0.0"
    },
    "variables": {
      "type": "object",
      "description": "Variable definitions"
    },
    "parameters": {
      "type": "object",
      "description": "Input parameter definitions",
      "additionalProperties": {
        "$ref": "#/definitions/parameter"
      }
    },
    "resources": {
      "type": "array",
      "description": "Collection of resources to be deployed",
      "items": {
        "oneOf": [
          {
            "allOf": [
              {
                "$ref": "#/definitions/resourceBase"
              },
              {
                "oneOf": [
                  {
                    "$ref": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json#/definitions/certificates"
                  },
                  {
                    "$ref": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json#/definitions/serverfarms"
                  }
                ]
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/definitions/resourceBaseForParentResources"
              },
              {
                "oneOf": [
                  {
                    "$ref": "http://schema.management.azure.com/schemas/2014-06-01/Microsoft.Web.json#/definitions/sites"
                  },
                  {
                    "$ref": "http://schema.management.azure.com/schemas/2014-04-01-preview/Microsoft.Sql.json#/definitions/servers"
                  },
									{
										"$ref": "http://schema.management.azure.com/schemas/2015-08-01/Microsoft.Compute.json#/resourceDefinitions/virtualMachines"
									}
                ]
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/definitions/resourceBaseExternal"
              },
              {
                "oneOf": [
                  {
                    "$ref": "http://schema.management.azure.com/schemas/2014-04-01/SuccessBricks.ClearDB.json#/definitions/databases"
                  }
                ]
              }
            ]
          },
          {
            "allOf": [
              {
                "$ref": "#/definitions/ARMResourceBase"
              },
              {
                "oneOf": [
                  {
                    "$ref": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json#/definitions/deployments"
                  },
                  {
                    "$ref": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json#/definitions/links"
                  },
                  {
                    "$ref": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Authorization.json#/definitions/locks"
                  }
                ]
              }
            ]
          }
        ]
      },
      "minItems": 1
    },
    "outputs": {
      "type": "object",
      "description": "Output parameter definitions",
      "additionalProperties": {
        "$ref": "#/definitions/output"
      }
    }
  },
  "additionalProperties": false,
  "required": [
    "$schema",
    "contentVersion",
    "resources"
  ],
  "definitions": {
    "resourceBase": {
      "allOf": [
        {
          "$ref": "#/definitions/resourceBaseForParentResources"
        },
        {
          "properties": {
            "resources": {
              "$ref": "#/definitions/childResources"
            }
          }
        }
      ]
    },
    "ARMResourceBase": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the resource"
        },
        "type": {
          "type": "string",
          "description": "Resource type"
        },
        "apiVersion": {
          "type": "string",
          "description": "API Version of the resource type"
        },
        "dependsOn": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Collection of resources this resource depends on"
        }
      },
      "required": [
        "name",
        "type",
        "apiVersion"
      ]
    },
    "proxyResourceBase": {
      "allOf": [
        {
          "$ref": "#/definitions/ARMResourceBase"
        },
        {
          "properties": {
            "resources": {
              "$ref": "#/definitions/childResources"
            },
            "location": {
              "$ref": "#/definitions/resourceLocations",
              "description": "Location to deploy resource to"
            }
          }
        }
      ]
    },
    "resourceBaseForParentResources": {
      "allOf": [
        {
          "$ref": "#/definitions/ARMResourceBase"
        },
        {
          "properties": {
            "kind": {
              "type": "string",
              "maxLength": 64,
              "pattern": "(^[a-zA-Z0-9_.()-]+$)",
              "description": "Kind of resource"
            },
            "location": {
              "$ref": "#/definitions/resourceLocations",
              "description": "Location to deploy resource to"
            },
            "tags": {
              "type": "object",
              "description": "Name-value pairs to add to the resource"
            },
            "plan": {
              "$ref": "#/definitions/resourcePlan"
            }
          },
          "required": [
            "location"
          ]
        }
      ]
    },
    "resourceBaseExternal": {
      "$ref": "#/definitions/resourceBase",
      "required": [
        "plan"
      ]
    },
    "childResources": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/ARMChildResources"
      }
    },
    "ARMChildResources": {
      "oneOf": [
        {
          "$ref": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Authorization.json#/definitions/locks"
        },
        {
          "$ref": "http://schema.management.azure.com/schemas/2015-01-01/Microsoft.Resources.json#/definitions/links"
        }
      ]
    },
    "resourcePlan": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the plan"
        },
        "promotionCode": {
          "type": "string",
          "description": "Plan promotion code"
        },
        "publisher": {
          "type": "string",
          "description": "Name of the publisher"
        },
        "product": {
          "type": "string",
          "description": "Name of the product"
        }
      },
      "required": [
        "name"
      ],
      "description": "Plan of the resource"
    },
    "resourceLocations": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "enum": [
            "East Asia",
            "Southeast Asia",
            "Central US",
            "East US",
            "East US 2",
            "West US",
            "North Central US",
            "South Central US",
            "North Europe",
            "West Europe",
            "Japan West",
            "Japan East",
            "Brazil South",
            "Australia East",
            "Australia Southeast",
            "Central India",
            "West India",
            "South India"
          ]
        }
      ]
    },
    "parameter": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/parameterTypes",
          "description": "Type of input parameter"
        },
        "defaultValue": {
          "$ref": "#/definitions/parameterValueTypes",
          "description": "Default value to be used if one is not provided"
        },
        "allowedValues": {
          "type": "array",
          "description": "Value can only be one of these values"
        },
        "minLength": {
          "type": "integer",
          "description": "Minimum number of characters that must be used"
        },
        "maxLength": {
          "type": "integer",
          "description": "Maximum number of characters that can be used"
        },
        "metadata": {
          "type": "object",
          "description": "Metadata for the parameter"
        }
      },
      "required": [
        "type"
      ],
      "description": "Input parameter definitions"
    },
    "output": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/definitions/parameterTypes",
          "description": "Type of output value"
        },
        "value": {
          "$ref": "#/definitions/parameterValueTypes",
          "description": "Value assigned for output"
        }
      },
      "required": [
        "type",
        "value"
      ],
      "description": "Set of output parameters"
    },
    "parameterTypes": {
      "enum": [
        "string",
        "securestring",
        "int",
        "bool",
        "object",
        "array"
      ]
    },
    "parameterValueTypes": {
      "type": [
        "string",
        "boolean",
        "integer",
        "number",
        "object",
        "array",
        "null"
      ]
    },
    "expression": {
      "type": "string",
      "pattern": "^\\[(concat|parameters|variables|reference|resourceId|resourceGroup|subscription|listKeys|listPackage|base64|providers|copyIndex|padLeft)\\(.*\\).*\\]$",
      "description": "Deployment template expression.  Expressions are enclosed in [] and must start with a function of concat(), parameters(), variables(), reference(), resourceId(), resourceGroup(), subscription(), listKeys(), listPackage(), base64(), providers(), copyIndex(), padLeft()"
    },
    "Iso8601Duration": {
      "type": "string",
      "pattern": "^P(\\d+Y)?(\\d+M)?(\\d+D)?(T(((\\d+H)(\\d+M)?(\\d+(\\.\\d{1,2})?S)?)|((\\d+M)(\\d+(\\.\\d{1,2})?S)?)|((\\d+(\\.\\d{1,2})?S))))?$"
    },
    "UTC": {
      "type": "string",
      "pattern": "^\\d{4}(-(0[1-9]|1[0-2])(-([012]\\d|3[01])(T((([01]\\d|2[0123]):[0-5]\\d)|(24:00))(:(([0-5]\\d)|60)(\\.\\d{1,}){0,1}){0,1}){0,1}((Z)|([+-]((([01]\\d|2[0123]):[0-5]\\d)|(24:00)))){0,1}){0,1}){0,1}$"
    },
    "apiVersion": {
      "type": "string",
      "pattern": "(^((\\d\\d\\d\\d-\\d\\d-\\d\\d)|([0-9]+(\\.[0-9]+)?))(-[a-zA-Z][a-zA-Z0-9]*)?$)",
      "description": "API version of the resource type"
    }
  }
}
