ARM Template - Adding option for none for PublicIP results in null errors

Alex Gregory 96 Reputation points
2020-09-16T19:34:14.63+00:00

Hello- I have tried to add none as an option for "publicIpNewOrExisting" I am getting errors in the parser that have left me with no direction. There error I get is:

{"message":"Deployment template validation failed: 'The template resource '' at line '<null>' and column '<null>' is not valid. The name property cannot be null or empty. Please see https://aka.ms/arm-template/#resources for usage details.'."}

The low level details are:

{
  "deploymentStatusCode": -1,
  "stage": 6,
  "expected": true,
  "error": {
    "message": "Deployment template validation failed: 'The template resource '' at line '<null>' and column '<null>' is not valid. The name property cannot be null or empty. Please see https://aka.ms/arm-template/#resources for usage details.'."
  },
  "subscriptionId": "XXXXXXXXXXXX",
  "resourceGroupName": "aaaaaaa",
  "resourceGroupLocation": "westus",
  "deploymentName": "XXXXXXXX",
  "details": {
    "code": "InvalidTemplate",
    "message": "Deployment template validation failed: 'The template resource '' at line '<null>' and column '<null>' is not valid. The name property cannot be null or empty. Please see https://aka.ms/arm-template/#resources for usage details.'.",
    "additionalInfo": [
      {
        "type": "TemplateViolation",
        "info": {
          "lineNumber": 0,
          "linePosition": 0,
          "path": ""
        }
      }
    ]
  }
}

I have it working fine to add an IP, but not to add no IP. My public IP parameters are:

"publicIpNewOrExisting": { "type": "string", "defaultValue": "new", "allowedValues": [ "none", "new", "existing" ], "metadata": { "description": "Determines whether or not a new public IP should be provisioned." } }

The outputs of my mainTemplate.json has:

"outputs": { "ssh-command": { "type": "string", "value": "[if(equals(parameters('publicIpNewOrExisting'), 'none'), 'no public ip, vnet access only', concat('ssh ', parameters('adminUsername'), '@', reference(resourceId(parameters('publicIpRGName'), 'Microsoft.Network/publicIPAddresses', parameters('publicIpName')), '2018-04-01').dnsSettings.fqdn))]" }

Which seems to be correct. Is there anyone that can assist in figuring out why I am getting the vague errors for deployment?

Azure Managed Applications
Azure Managed Applications
An Azure service that enables managed service providers, independent software vendors, and enterprise IT teams to deliver turnkey solutions through the Azure Marketplace or service catalog.
112 questions
0 comments No comments
{count} votes

Accepted answer
  1. Alex Gregory 96 Reputation points
    2021-01-14T07:15:59.067+00:00

    For anyone else that comes across this, this was a bug that I worked with Microsoft support (long and hard) on. It was acknowledged that there was an error in their handling and the issue has been resolved on their end.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Stanislav Zhelyazkov 21,181 Reputation points MVP
    2020-09-17T12:37:21.03+00:00

    Hi,
    Can you please share the whole template? It is hard to troubleshoot if you do not have the full picture. Looking at the parts that you have provided may be you provider some dummy value for parameter publicIpName this will work. Seems to me that even if you do not want to have public IP you still need to provide some value for publicIpName just so the template can pass validation.

    P.S. Don't forget to mark the reply as answer if this has helped.


  2. Alex Gregory 96 Reputation points
    2020-09-17T19:52:34.807+00:00

    Thanks for replying, Stan. I also very much appreciate the help. With the null reports back I am struggling to find the issue.

    I have a createUI and an azuredeploy...

    {  
       "$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json#",  
       "handler": "Microsoft.Azure.CreateUIDef",  
       "version": "0.1.2-preview",  
       "parameters": {  
          "basics": [ {}  
          ],  
          "steps": [   
            {  
              "name": "networkSettings",  
              "label": "Network Settings",  
              "subLabel": {  
                  "preValidation": "Required",  
                  "postValidation": "Done"  
              },  
              "bladeTitle": "Network Settings",  
              "elements": [  
                {  
                      "name": "vnetSpec",  
                      "type": "Microsoft.Network.VirtualNetworkCombo",  
                      "label": {  
                          "virtualNetwork": "Virtual network",  
                          "subnets": "Subnets"  
                      },  
                      "toolTip": {  
                          "virtualNetwork": "",  
                          "subnets": ""  
                      },  
                      "defaultValue": {  
                          "name": "vnet01",  
                          "addressPrefixSize": "/16"  
                      },  
                      "constraints": {  
                          "minAddressPrefixSize": "/16"  
                      },  
                      "subnets": {  
                          "subnet": {  
                              "label": "Instance subnet",  
                              "defaultValue": {  
                                  "name": "subnet",  
                                  "addressPrefixSize": "/24"  
                              },  
                              "constraints": {  
                                  "minAddressPrefixSize": "/24",  
                                  "minAddressCount": 12,  
                                  "requireContiguousAddresses": true  
                              }  
                          }  
                      }  
                  },  
                  {  
                    "name": "publicIpAddress",  
                    "type": "Microsoft.Network.PublicIpAddressCombo",  
                    "label": {  
                        "publicIpAddress": "Public IP Address for the VM",  
                        "domainNameLabel": "DNS Prefix for the public IP Address"  
                    },  
                    "toolTip": {  
                        "publicIpAddress": "Public IP Address for the VM",  
                        "domainNameLabel": "DNS Prefix for the public IP Address, must be globally unique"  
                    },  
                    "defaultValue": {  
                        "publicIpAddressName": "PublicIP",  
                        "domainNameLabel": "mydomain"  
                    },  
                    "options": {  
                        "hideExisting": false,  
                        "hideNone": false  
                    },  
                    "constraints": {  
                      "required": {  
                        "domainNameLabel": true  
                      }  
                    },  
                  },  
                  {  
                    "name": "ipRangeToSSHFrom",  
                    "type": "Microsoft.Common.TextBox",  
                    "label": "IP range to allow SSH, HTTP and HTTPS from",  
                    "defaultValue": "0.0.0.0/0",  
                    "toolTip": "CIDR block to restrict SSH access to (Recommended). By default, SSH access is available from anywhere",  
                    "constraints": {  
                        "required": true,  
                        "regex": "^(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\\.(25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)\/(\\d|[1-2]\\d|3[0-2])$",  
                        "validationMessage": "IP range must be a valid CIDR range of the form x.x.x.x/x"  
                    }  
                  }  
              ]  
            },  
            {  
            "name": "vmSettings",  
            "label": "VM Settings",  
            "bladeTitle": "VM Settings",  
            "subLabel": {  
                "preValidation": "Provide VM settings",  
                "postValidation": "Done"  
            },  
            "elements": [  
              {  
                "name": "vmName",  
                "type": "Microsoft.Common.TextBox",  
                "label": "Virtual Machine name",  
                "toolTip": "The name of the Virtual Machine.",  
                "defaultValue": "Cloud",  
                "constraints": {  
                    "required": true,  
                    "regex": "^[a-z0-9A-Z-]{3,79}$",  
                    "validationMessage": "The VM Name must be between 3 and 79 characters long and contain letters, numbers and hyphens only."  
                }  
              },    
              {  
                    "name": "adminUsername",  
                    "type": "Microsoft.Compute.UserNameTextBox",  
                    "label": "Admin username",  
                    "osPlatform": "Linux",  
                    "constraints": {  
                        "required": true,  
                        "regex": "^(?=.{5,20}$)(?![_.-])[a-zA-Z][a-zA-Z0-9-_]+$",  
                        "validationMessage": "Username must only contain letters, numbers, hyphens, and underscores, may not start with a hyphen or number and the value must be 5-20 characters long."  
                    },  
                    "toolTip": "Provide admin username for shell access to the virtual machine"  
                },  
                {  
                    "name": "adminPasswordOrKey",  
                    "type": "Microsoft.Compute.CredentialsCombo",  
                    "label": {  
                      "authenticationType": "Authentication type",  
                      "password": "Password",  
                      "confirmPassword": "Confirm password",  
                      "sshPublicKey": "SSH public key"  
                    },  
                    "toolTip": {  
                      "authenticationType": "",  
                      "password": "",  
                      "sshPublicKey": ""  
                    },  
                    "constraints": {  
                      "required": true,  
                      "customPasswordRegex": "^((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])|(?=.*[0-9])(?=.*[a-z])(?=.*[!@#$%^&*])|(?=.*[0-9])(?=.*[A-Z])(?=.*[!@#$%^&*])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])).{12,172}$",  
                      "customValidationMessage": "Password must be at least 12 characters long and have 3 out of the following: one number, one lower case, one upper case, or one special character"  
                    },  
                    "options": {  
                      "hideConfirmation": false,  
                      "hidePassword": false  
                    },  
                    "osPlatform": "Linux",  
                    "visible": true  
                },  
                {  
                  "name": "standaloneVmSize",  
                  "type": "Microsoft.Compute.SizeSelector",  
                  "label": "VM size",  
                  "toolTip": "Select VM Size",  
                  "recommendedSizes": [  
                          "Standard_D2s_v3",  
                          "Standard_D2_v3",  
                          "Standard_D3_v2",  
                          "Standard_B2s",  
                          "Standard_B2ms",  
                          "Standard_D4_v3",  
                          "Standard_D4s_v3",  
                          "Standard_B4ms",  
                          "Standard_B8ms",  
                          "Standard_B2s",  
                          "Standard_D8s_v3"  
                  ],  
                  "constraints": {  
                      "allowedSizes": [  
                          "Standard_D2s_v3",  
                          "Standard_D2_v3",  
                          "Standard_D3_v2",  
                          "Standard_B2s",  
                          "Standard_B2ms",  
                          "Standard_D4_v3",  
                          "Standard_D4s_v3",  
                          "Standard_B4ms",  
                          "Standard_B8ms",  
                          "Standard_B2s",  
                          "Standard_D8s_v3"  
                      ]  
                  },  
                  "options": {  
                    "hideDiskTypeFilter": false  
                  },  
                  "osPlatform": "Linux"   
                }  
              ]  
          },  
          {  
            "name": "Settings",  
                  "label": "Settings",  
                  "subLabel": {  
                      "preValidation": "Admin Password",  
                      "postValidation": "Done"  
                  },  
                  "bladeTitle": "Credentials",  
      
            "elements": [  
              {  
                "name": "AdminPassword",  
                "type": "Microsoft.Compute.CredentialsCombo",  
                "label": {  
                  "password": "Superadmin Password",  
                  "confirmPassword": "Confirm Superadmin Password"  
                },  
                "toolTip": {  
                  "password": "Enter the password that will be used to retrieve the password from the publicweb."  
                },  
                "constraints": {  
                  "required": true,  
                  "customPasswordRegex": "^((?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])|(?=.*[0-9])(?=.*[a-z])(?=.*[!@#$%^&*])|(?=.*[0-9])(?=.*[A-Z])(?=.*[!@#$%^&*])|(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*])).{12,172}$",  
                  "customValidationMessage": "Password must be at least 12 characters long and have 3 out of the following: one number, one lower case, one upper case, or one special character"  
                },  
                "options": {  
                  "hideConfirmation": false  
                },  
                "osPlatform": "Linux",  
                "visible": true  
              }  
            ]  
          }  
        ],  
          "outputs": {   
            "adminUsername": "[steps('vmSettings').adminUsername]",  
            "location": "[location()]",  
            "authenticationType": "[steps('vmSettings').adminPasswordOrKey.authenticationType]",  
            "adminPassword": "[steps('vmSettings').adminPasswordOrKey.password]",  
            "sshPublicKey": "[steps('vmSettings').adminPasswordOrKey.sshPublicKey]",  
            "standaloneVmSize": "[steps('vmSettings').standaloneVmSize]",  
            "vmName": "[steps('vmSettings').vmName]",  
            "AdminPassword": "[steps('Settings').AdminPassword.password]",  
            "virtualNetworkName": "[steps('networkSettings').vnetSpec.name]",  
            "virtualNetworkNewOrExisting": "[steps('networkSettings').vnetSpec.newOrExisting]",  
            "virtualNetworkExistingRGName": "[steps('networkSettings').vnetSpec.resourceGroup]",  
            "virtualNetworkAddressPrefix": "[steps('networkSettings').vnetSpec.addressPrefix]",  
            "publicIpNewOrExisting": "[steps('networkSettings').publicIpAddress.newOrExistingOrNone]",  
            "publicIpName": "[steps('networkSettings').publicIpAddress.name]",  
            "publicIpDns": "[steps('networkSettings').publicIpAddress.domainNameLabel]",  
            "publicIpRGName": "[steps('networkSettings').publicIpAddress.resourceGroup]",  
            "publicIpAddressType": "[steps('networkSettings').publicIpAddress.publicIpAllocationMethod]",  
            "publicIpSku": "[steps('networkSettings').publicIpAddress.sku]",  
            "subnetName": "[steps('networkSettings').vnetSpec.subnets.subnet.name]",  
            "subnetPrefix": "[steps('networkSettings').vnetSpec.subnets.subnet.addressPrefix]",  
            "subnetStartAddress": "[steps('networkSettings').vnetSpec.subnets.subnet.startAddress]",  
            "ipRangeToSSHFrom": "[steps('networkSettings').ipRangeToSSHFrom]"  
          }  
       }  
    }  
    

    Here is the mainTemplate:

    {  
      "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",  
      "contentVersion": "1.0.0.0",  
      "parameters": {  
        "location": {  
          "type": "string",  
          "defaultValue": "[resourceGroup().location]",  
          "metadata": {  
            "description": "Location for all resources."  
          }  
        },  
        "vmName": {  
          "type": "string",  
          "defaultValue": "Cloud",  
          "metadata": {  
            "description": "Unique host name for instance."  
          }  
        },  
        "adminUsername": {  
          "type": "string",  
          "metadata": {  
            "description": "User name for the Virtual Machine."  
          }  
        },  
        "authenticationType": {  
          "type": "string",  
          "defaultValue": "sshPublicKey",  
          "allowedValues": [  
            "password",  
            "sshPublicKey"  
          ],  
          "metadata": {  
            "description": "Type of authentication to use on the Virtual Machine. SSH key is recommended."  
          }  
        },  
        "adminPassword": {  
          "type": "securestring",  
          "defaultValue": "",  
          "metadata": {  
            "description": "Password for the Virtual Machine."  
          }  
        },  
        "sshPublicKey": {  
          "type": "string",  
          "defaultValue": "",  
          "metadata": {  
            "description": "SSH Public Key for the Virtual Machine."  
          }       
        },  
        "standaloneVmSize": {  
          "type": "string",  
          "defaultValue": "Standard_D2s_v3",  
          "metadata": {  
            "description": "Size of standalone VM"  
          }  
        },  
        "virtualNetworkName": {  
          "type": "string",  
          "metadata": {  
            "description": "Name of the virtual network that the consumer wants to use"  
          }  
        },  
        "virtualNetworkNewOrExisting": {  
          "type": "string",  
          "defaultValue": "new",  
          "allowedValues": [  
            "new",  
            "existing"  
          ],  
          "metadata": {  
            "description": "Identifies whether to use new or existing Virtual Network"  
          }  
        },  
        "virtualNetworkExistingRGName": {  
          "type": "string",  
          "defaultValue": "[resourceGroup().name]",  
          "metadata": {  
            "description": "Name of resource group of existing Virtual Network (if applicable)"  
          }  
        },  
        "virtualNetworkAddressPrefix": {  
          "type": "string",  
          "defaultValue": "10.0.0.0/16",  
          "metadata": {  
            "description": "Virtual network address CIDR"  
          }  
        },  
        "subnetName": {  
          "type": "string",  
          "defaultValue": "subnet",  
          "metadata": {  
            "description": "Subnet for the instance"  
          }  
        },  
        "subnetPrefix": {  
          "type": "string",  
          "defaultValue": "10.0.0.0/24",  
          "metadata": {  
            "description": "Instance subnet CIDR"  
          }  
        },  
        "subnetStartAddress": {  
          "type": "string",  
          "defaultValue": "10.0.0.20",  
          "metadata": {  
            "description": "Instance subnet start address"  
          }  
        },  
        "AdminPassword": {  
          "type": "securestring",  
          "metadata": {  
            "description": "Superadmin Password for Credentials."  
          }  
        },  
        "ipRangeToSSHFrom": {  
          "type": "string",  
          "defaultValue": "0.0.0.0/0",  
          "metadata": {  
            "description": "CIDR block to restrict SSH access from"  
          }  
        },  
        "_artifactsLocation": {  
          "type": "string",  
          "metadata": {  
              "description": "The base URI where artifacts required by this template are located including a trailing '/'"  
          },  
          "defaultValue": "[deployment().properties.templateLink.uri]"  
        },  
        "_artifactsLocationSasToken": {  
            "type": "securestring",  
            "metadata": {  
                "description": "The sasToken required to access _artifactsLocation.  When the template is deployed using the accompanying scripts, a sasToken will be automatically generated. Use the defaultValue if the staging location is not secured."  
            },  
            "defaultValue": ""  
        },  
        "publicIpNewOrExisting": {  
          "type": "string",  
          "defaultValue": "new",  
          "allowedValues": [  
            "none",  
            "new",  
            "existing"  
          ],  
          "metadata": {  
            "description": "Determines whether or not a new public IP should be provisioned."  
          }  
        },  
        "publicIpName": {  
          "type": "string",  
          "defaultValue": "PublicIP",  
          "metadata": {  
            "description": "Name of the public IP address"  
          }  
        },  
        "publicIpDns": {  
          "type": "string",  
          "defaultValue": "[concat('linux-vm-', uniqueString(resourceGroup().id))]",  
          "metadata": {  
            "description": "DNS of the public IP address for the VM"  
          }  
        },  
        "publicIPAddressType": {  
          "type": "string",  
          "defaultValue": "Dynamic",  
          "allowedValues": [  
            "Dynamic",  
            "Static",  
            ""  
          ],  
          "metadata": {  
            "description": "Type of public IP address"  
          }  
        },  
        "publicIpRGName": {  
          "type": "string",  
          "defaultValue": "[resourceGroup().name]",  
          "metadata": {  
            "description": "Name of the resource group for the public IP address"  
          }  
        },  
        "publicIpSku": {  
          "type": "string",  
          "defaultValue": "Basic",  
          "allowedValues": [  
            "Basic",  
            "Standard",  
            ""  
          ],  
          "metadata": {  
            "description": "Public IP sku"  
          }  
        }  
    },  
       "variables": {  
        "singleQuote": "'",  
        "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'salinuxvm')]",  
        "nicName": "[concat(parameters('vmName'),'NIC')]",  
        "storageAccountType": "Standard_LRS",  
        "linuxConfiguration": {  
          "disablePasswordAuthentication": true,  
          "ssh": {  
            "publicKeys": [  
              {  
                "path": "[concat('/home/', parameters('adminUsername'), '/.ssh/authorized_keys')]",  
                "keyData": "[parameters('sshPublicKey')]"  
              }  
            ]  
          }  
        },  
        "osSettings": {  
          "imageReference": {  
            "publisher": "primekey",  
            "offer": "xxxxxxxxxxxxxxxx",  
            "sku": "xxxxxxxxx",  
            "version": "x.x.x"  
          }  
      
        },  
        "publicIpAddressId": {  
          "id": "[resourceId(parameters('publicIpRGName'), 'Microsoft.Network/publicIPAddresses', parameters('publicIpName'))]"  
        },  
        "securityGroupName": "nsg",  
        "AdminPasswordBase64": "[base64(parameters('AdminPassword'))]",  
        "scriptFileUri": "[uri(parameters('_artifactsLocation'), concat('scripts/node-setup.sh', parameters('_artifactsLocationSasToken')))]"  
      },  
      "resources": [  
        {  
          "apiVersion": "2019-05-01",  
          "name": "xxxxxxxxxxxx",  
          "type": "Microsoft.Resources/deployments",  
          "properties": {  
              "mode": "Incremental",  
              "template": {  
                  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",  
                  "contentVersion": "1.0.0.0",  
                  "resources": []  
              }  
          }  
        },   
        {  
          "type": "Microsoft.Storage/storageAccounts",  
          "name": "[variables('storageAccountName')]",  
          "apiVersion": "2018-07-01",  
          "location": "[parameters('location')]",  
          "sku": {  
            "name": "[variables('storageAccountType')]"  
          },  
          "kind": "Storage",  
          "properties": {}  
        },  
        {  
          "condition": "[equals(parameters('publicIpNewOrExisting'), 'new')]",  
          "type": "Microsoft.Network/publicIPAddresses",  
          "apiVersion": "2019-08-01",  
          "name": "[parameters('publicIpName')]",  
          "location": "[parameters('location')]",  
          "sku": {  
            "name": "[parameters('publicIPSku')]"  
          },  
          "properties": {  
            "publicIPAllocationMethod": "[parameters('publicIPAddressType')]",  
            "dnsSettings": {  
              "domainNameLabel": "[parameters('publicIpDns')]"  
            }  
          }  
        },  
        {  
          "condition": "[equals(parameters('virtualNetworkNewOrExisting'), 'new')]",  
          "apiVersion": "2019-08-01",  
          "type": "Microsoft.Network/virtualNetworks",  
          "name": "[parameters('virtualNetworkName')]",  
          "location": "[parameters('location')]",  
          "properties": {  
            "addressSpace": {  
              "addressPrefixes": [  
                "[parameters('virtualNetworkAddressPrefix')]"  
              ]  
            },  
            "subnets": [  
              {  
                "name": "[parameters('subnetName')]",  
                "properties": {  
                  "addressPrefix": "[parameters('subnetPrefix')]"  
                }  
              }  
            ]  
          }  
        },  
        {  
          "apiVersion": "2019-08-01",  
          "type": "Microsoft.Network/networkSecurityGroups",  
          "name": "[variables('securityGroupName')]",  
          "location": "[parameters('location')]",  
          "properties": {  
            "securityRules": [  
              {  
                "name": "Allow-SSH",  
                "properties": {  
                  "description": "Allows SSH traffic",  
                  "protocol": "Tcp",  
                  "sourcePortRange": "*",  
                  "destinationPortRange": "22",  
                  "sourceAddressPrefix": "[parameters('ipRangeToSSHFrom')]",  
                  "destinationAddressPrefix": "*",  
                  "access": "Allow",  
                  "priority": 100,  
                  "direction": "Inbound"  
                }  
              },  
              {  
                "name": "Allow-HTTP",  
                "properties": {  
                  "description": "Allows HTTP traffic on port 80",  
                  "protocol": "Tcp",  
                  "sourcePortRange": "*",  
                  "destinationPortRange": "80",  
                  "sourceAddressPrefix": "[parameters('ipRangeToSSHFrom')]",  
                  "destinationAddressPrefix": "*",  
                  "access": "Allow",  
                  "priority": 110,  
                  "direction": "Inbound"  
                }  
              },  
              {  
                "name": "Allow-HTTPS",  
                "properties": {  
                  "description": "Allows HTTPS traffic on port 443",  
                  "protocol": "Tcp",  
                  "sourcePortRange": "*",  
                  "destinationPortRange": "443",  
                  "sourceAddressPrefix": "[parameters('ipRangeToSSHFrom')]",  
                  "destinationAddressPrefix": "*",  
                  "access": "Allow",  
                  "priority": 120,  
                  "direction": "Inbound"  
                }  
              }  
                
            ]  
          }  
        },  
        {  
          "apiVersion": "2019-08-01",  
          "type": "Microsoft.Network/networkInterfaces",  
          "name": "[variables('nicName')]",  
          "location": "[parameters('location')]",  
          "dependsOn": [  
            "[parameters('publicIpName')]",  
            "[parameters('virtualNetworkName')]",  
            "[variables('securityGroupName')]"  
          ],  
          "properties": {  
            "ipConfigurations": [  
              {  
                "name": "ipconfig1",  
                "properties": {  
                  "privateIPAllocationMethod": "Dynamic",  
                  "privateIPAddress": "[parameters('subnetStartAddress')]",  
                  "subnet": {  
                    "id": "[resourceId(parameters('virtualNetworkExistingRGName'), 'Microsoft.Network/virtualNetworks/subnets/', parameters('virtualNetworkName'), parameters('subnetName'))]"  
                  },  
                  "publicIPAddress": "[if(not(equals(parameters('publicIpNewOrExisting'), 'none')), variables('publicIpAddressId') , json('null'))]"  
                }  
              }  
            ],  
            "networkSecurityGroup": {  
              "id": "[resourceId('Microsoft.Network/networkSecurityGroups', variables('securityGroupName'))]"  
            }  
          }  
        },  
        {  
          "apiVersion": "2019-07-01",  
          "type": "Microsoft.Compute/virtualMachines",  
          "name": "[parameters('vmName')]",  
          "location": "[parameters('location')]",  
          "plan": {  
            "name": "[variables('osSettings').imageReference.sku]",  
            "publisher": "[variables('osSettings').imageReference.publisher]",  
            "product": "[variables('osSettings').imageReference.offer]"  
          },  
          "dependsOn": [  
            "[resourceId('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",  
            "[resourceId('Microsoft.Network/networkInterfaces/', variables('nicName'))]"  
          ],  
          "properties": {  
            "hardwareProfile": {  
              "vmSize": "[parameters('standaloneVmSize')]"  
            },  
            "osProfile": {  
              "computerName": "[parameters('vmName')]",  
              "adminUsername": "[parameters('adminUsername')]",  
              "adminPassword": "[parameters('adminPassword')]",  
              "linuxConfiguration": "[if(equals(parameters('authenticationType'), 'password'), json('null'), variables('linuxConfiguration'))]"  
            },  
            "storageProfile": {  
              "imageReference": "[variables('osSettings').imageReference]",  
              "osDisk": {  
                "name": "[concat(parameters('vmName'),'_OSDisk')]",   
                "caching": "ReadWrite",  
                "createOption": "FromImage"  
              },  
              "dataDisks": [  
                {  
                  "diskSizeGB": 100,  
                  "lun": 0,  
                  "createOption": "Empty"  
                }  
              ]  
            },  
            "networkProfile": {  
              "networkInterfaces": [  
                {  
                  "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"  
                }  
              ]  
            },  
            "diagnosticsProfile": {  
              "bootDiagnostics": {  
                "enabled": true,  
                "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), '2019-04-01').primaryEndpoints.blob)]"  
              }  
            }  
          }  
        },  
        {  
          "apiVersion": "2019-07-01",  
          "type": "Microsoft.Compute/virtualMachines/extensions",  
          "name": "[concat(parameters('vmName'), '/node-setup')]",  
          "location": "[parameters('location')]",  
          "dependsOn": [  
            "[concat('Microsoft.Compute/virtualMachines/', parameters('vmName'))]",  
            "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"  
          ],  
          "properties": {  
            "publisher": "Microsoft.Azure.Extensions",  
            "type": "CustomScript",  
            "typeHandlerVersion": "2.0",  
            "autoUpgradeMinorVersion": true,  
            "protectedSettings": {  
              "fileUris": ["[variables('scriptFileUri')]"],  
              "commandToExecute": "[concat('bash node-setup.sh', ' -p ', variables('singleQuote'), variables('AdminPasswordBase64'), variables('singleQuote'))]"  
            }  
          }  
        }  
      ],  
      "outputs": {  
        "ssh-command": {  
          "type": "string",  
          "value": "[if(equals(parameters('publicIpNewOrExisting'), 'none'), 'no public ip, vnet access only', concat('ssh ', parameters('adminUsername'), '@', reference(resourceId(parameters('publicIpRGName'), 'Microsoft.Network/publicIPAddresses', parameters('publicIpName')), '2018-04-01').dnsSettings.fqdn))]"  
        }  
      }  
    }  
    
    
    
      
    
    0 comments No comments