{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "db_user": {
      "type": "string",
      "minLength": 1,
      "defaultValue": "artifactory"
    },
    "db_password": {
      "type": "securestring",
      "defaultValue": "jFrog123"
    },
    "db_server": {
      "type": "string",
      "minLength": 1,
      "defaultValue": "artmssqlsrv"
    },
    "db_name": {
      "type": "string",
      "minLength": 1,
      "defaultValue": "artdb"
    },
    "db_location": {
      "type": "string",
      "defaultValue": ""
    },
    "db_edition": {
      "type": "string",
      "allowedValues": [
        "Basic",
        "Standard",
        "Premium"
      ]
    }
  },
  "variables": {
    "apiVersion": "2015-05-01-preview",
    "rtdbCollation": "Latin1_General_100_CS_AS",
    "db_location": "[if(equals(parameters('db_location'), ''), resourceGroup().location, parameters('db_location'))]"
  },
  "resources": [
    {
      "name": "[parameters('db_server')]",
      "type": "Microsoft.Sql/servers",
      "kind": "v12.0",
      "location": "[variables('db_location')]",
      "apiVersion": "[variables('apiVersion')]",
      "dependsOn": [
        
      ],
      "tags": {
        "displayName": "artifactoryDB"
      },
      "properties": {
        "administratorLogin": "[parameters('db_user')]",
        "administratorLoginPassword": "[parameters('db_password')]",
        "version": "12.0"
      },
      "resources": [
        {
          "name": "[uniqueString(parameters('db_server'), 'AllowAllWindowsAzureIps' )]",
          "type": "firewallrules",
          "location": "[variables('db_location')]",
          "apiVersion": "[variables('apiVersion')]",
          "dependsOn": [
            "[concat('Microsoft.Sql/servers/', parameters('db_server'))]"
          ],
          "properties": {
            "startIpAddress": "0.0.0.0",
            "endIpAddress": "0.0.0.0"
          }
        },
        {
          "name": "[parameters('db_name')]",
          "type": "databases",
          "kind": "v12.0,user",
          "location": "[variables('db_location')]",
          "apiVersion": "[variables('apiVersion')]",
          "dependsOn": [
            "[parameters('db_server')]"
          ],
          "tags": {
            "displayName": "artifactoryDB"
          },
          "properties": {
            "edition": "[parameters('db_edition')]",
            "maxSizeBytes": "1073741824",
            "collation": "[variables('rtdbCollation')]"
          }
        }
      ]
    }
  ],
  "outputs": {
    "jdbcConnString": {
      "type": "string",
      "value": "[concat('jdbc:sqlserver://', reference(concat('Microsoft.Sql/servers/', parameters('db_server'))).fullyQualifiedDomainName, ':1433')]"
    }
  }
}
