Skip to content

Instantly share code, notes, and snippets.

@chgeuer
Last active March 30, 2017 09:14
Show Gist options
  • Save chgeuer/064efb3ca38a9fd3f36f74dd450bcc52 to your computer and use it in GitHub Desktop.
Save chgeuer/064efb3ca38a9fd3f36f74dd450bcc52 to your computer and use it in GitHub Desktop.

User specifies whether he wants VPN or not

https://github.com/chgeuer/td/blob/master/ARM/azuredeploy.json#L28-L35

 "parameters": {
       "deployVPN": {
            "type": "string",
            "defaultValue": "enabled",
            "allowedValues": [
                "enabled",
                "disabled"
            ]
        },

remember this in large commonSettings property bag

https://github.com/chgeuer/td/blob/master/ARM/azuredeploy.json#L117

"variables": {
   "commonSettings": {
      "deployVPN": "[parameters('deployVPN')]",

Deploy the optional resource

https://github.com/chgeuer/td/blob/master/ARM/azuredeploy.json#L237-L256

"resources": [
{
   "name": "vpn,
   "type": "Microsoft.Resources/deployments",
   "apiVersion": "[variables('commonSettings').constants.apiVersions.deployments]",
   "dependsOn": [
       "[concat('Microsoft.Resources/deployments/', 'shared-resources')]"
   ],
   "properties": {
       "mode": "Incremental",
       "templateLink": {
           "uri": "[concat(variables('commonSettings').repositoryUrl, 'ARM/', concat('deployVPN-', parameters('deployRegServer'), '.json'))]",
           "contentVersion": "1.0.0.0"
       },
       "parameters": {
           "commonSettings": {
               "value": "[variables('commonSettings')]"
           }
       }
   }
},

deployVPN-disabled.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": { "commonSettings": { "type": "object" } },
    "resources": [ ]
}

deployVPN-enabled.json

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": { "commonSettings": { "type": "object" } },
    "resources": [
    
    { 
       "type": "Microsoft.Network/virtualNetworkGateways",
       "name": "[concat(parameters('commonSettings').names.tenantName, '-vpn')]",
       "apiVersion": "parameters('commonSettings').apiVersions.virtualNetworkGateways",
       "properties": {
         "ipConfigurations": [
           {
              "name": "...",
              "properties": {
                "subnet": {
                  "id": "[concat('/subscriptions/', subscription().subscriptionId, '/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', 'vnetname', '/subnets/', 'subnet-vpn')]",
                },
    }
    ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment