Templates/VNet.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vnetName": {
      "type": "string",
      "defaultValue": "vnet%UID%",
      "metadata": {
        "description": "Virtual Network Name."
      }
    },
    "vnetLocation": {
      "type": "string",
      "defaultValue": "%LOCATION%",
      "metadata": {
        "description": "Virtual Network Location."
      }
    },
    "vnetAddressPrefix": {
      "type": "string",
      "defaultValue": "10.0.0.0/20",
      "metadata": {
        "description": "Address prefix for the virtual network"
      }
    },
    "vnetEnableDdosProtection": {
      "type": "bool",
      "defaultValue": false,
      "metadata": {
        "description": "Enable DDOS Protection"
      }
    },
    "ddosPlanName": {
      "type": "string",
      "defaultValue": "",
      "metadata": {
        "description": "Name of the DDoS Standard Plan."
      }
    },
    "vnetTags": {
      "type": "object",
      "defaultValue": {
        "Date": "%DATE%"
      },
      "metadata": {
        "description": "VNet Tags."
      }
    }
  },
  "variables": {
    "vnetLocation": "[if(empty(parameters('vnetLocation')), resourceGroup().location, parameters('vnetLocation'))]",
    "ddosProtectionPlanResourceId": {
      "id": "[resourceId('Microsoft.Network/ddosProtectionPlans', parameters('ddosPlanName'))]"
    }
  },
  "resources": [
    {
      "apiVersion": "2018-04-01",
      "type": "Microsoft.Network/virtualNetworks",
      "name": "[parameters('vnetName')]",
      "location": "[variables('vnetLocation')]",
      "tags": "[parameters('vnetTags')]",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "[parameters('vnetAddressPrefix')]"
          ]
        },
        "subnets": [],
        "enableDdosProtection": "[not(empty(parameters('ddosPlanName')))]",
        "ddosProtectionPlan": "[if(empty(parameters('ddosPlanName')), json('null'), variables('ddosProtectionPlanResourceId'))]"
      }
    }
  ],
  "outputs": {}
}