{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "sql_server": {
      "type": "object"
    },
    "admin": {
      "type": "string"
    },
    "adminpwd":  {
      "type": "string"
    }
  },
  "variables": {
    "sql_server_name": "[concat(parameters('sql_server').name, '-', uniqueString(resourceGroup().id))]",
    "admin": "[parameters('admin')]",
    "adminpwd": "[parameters('adminpwd')]"
  },
  "resources": [
    {
      "type": "Microsoft.Sql/servers",
      "name": "[variables('sql_server_name')]",
      "apiVersion": "2014-04-01-preview",
      "location": "[resourceGroup().location]",
      "properties": {
        "administratorLogin": "[variables('admin')]",
        "administratorLoginPassword": "[variables('adminpwd')]",
        "version": "12.0"
      },
      "resources": [
        {
          "type": "databases",
          "name": "[parameters('sql_server').dbs.ordering]",
          "apiVersion": "2014-04-01-preview",
          "location": "[resourceGroup().location]",
          "properties": {
            "edition": "Standard",
            "collation": "SQL_Latin1_General_CP1_CI_AS",
            "maxSizeBytes": "1073741824",
            "requestedServiceObjectiveName": "S1"
          },
          "dependsOn": [
            "[concat('Microsoft.Sql/servers/', variables('sql_server_name'))]"
          ]
        },
        {
          "type": "databases",
          "name": "[parameters('sql_server').dbs.identity]",
          "apiVersion": "2014-04-01-preview",
          "location": "[resourceGroup().location]",
          "properties": {
            "edition": "Standard",
            "collation": "SQL_Latin1_General_CP1_CI_AS",
            "maxSizeBytes": "1073741824",
            "requestedServiceObjectiveName": "S1"
          },
          "dependsOn": [
            "[concat('Microsoft.Sql/servers/', variables('sql_server_name'))]"
          ]
        },
        {
          "type": "databases",
          "name": "[parameters('sql_server').dbs.catalog]",
          "apiVersion": "2014-04-01-preview",
          "location": "[resourceGroup().location]",
          "properties": {
            "edition": "Standard",
            "collation": "SQL_Latin1_General_CP1_CI_AS",
            "maxSizeBytes": "1073741824",
            "requestedServiceObjectiveName": "S1"
          },
          "dependsOn": [
            "[concat('Microsoft.Sql/servers/', variables('sql_server_name'))]"
          ]
        },      
        {
          "type": "firewallrules",
          "name": "AllowAllWindowsAzureIps",
          "apiVersion": "2014-04-01-preview",
          "location": "[resourceGroup().location]",
          "properties": {
            "startIpAddress": "0.0.0.0",
            "endIpAddress": "0.0.0.0"
          },
          "dependsOn": [
            "[concat('Microsoft.Sql/servers/', variables('sql_server_name'))]"
          ]
        },
        {
          "type": "firewallrules",
          "name": "AllConnectionsAllowed",
          "apiVersion": "2014-04-01-preview",
          "location": "[resourceGroup().location]",
          "properties": {
            "startIpAddress": "0.0.0.0",
            "endIpAddress": "255.255.255.255"
          },
          "dependsOn": [
            "[concat('Microsoft.Sql/servers/', variables('sql_server_name'))]"
          ]
        }
      ]
    }
  ],
  "outputs": {
  }
}
