Quantcast
Channel: Azure Networking (DNS, Traffic Manager, VPN, VNET) forum
Viewing all articles
Browse latest Browse all 6513

Azure Resource Manager - Multiple VM NAT Rules

$
0
0

I am trying to create an ARM template that will provision multiple webservers with directly accessible ports. For instance I want a VM to have either port 9001 or 9002 open based on what the index of the VM is.

I am struggling to get the frontendPort parameter to accept a function. Here is the documentation that I have used.

Here is what the relevant portion of my template looks like:

"inboundNatRules": [
{
    "copy": {
        "name": "natCopy",
        "count": "[parameters('numberOfVms')]"
    },
    "name": "[concat('directHttps-', copyIndex())]",
    "properties": {
        "frontendIPConfiguration": {
            "id": "[concat(variables('lbID'),'/frontendIPConfigurations/LoadBalancerFrontEnd')]"
        },
        "frontendPort": "[add(9001, copyIndex())]",
        "backendPort": 9001,
        "enableFloatingIP": false,
        "idleTimeoutInMinutes": 4,
        "protocol": "Tcp",
        "backendIPConfiguration": {
            "id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('vmNicName'), copyIndex()), 'ipconfig')]"
        }
    }
}
]

I was hoping that the this particular port would result in either "9001", or "9002".

"frontendPort": "[add(9001, copyIndex())]"
Instead, I see an error in Visual Studio's Intellisense, and when I try to deploy the solution.



Create template deployment 'deploymenttemplate-0107-1555'.
New-AzureRmResourceGroupDeployment : Resource Microsoft.Network/loadBalancers 'webserverLb'
failed with message 'Unable to process template language expressions for resource
'/subscriptions/some random guid/resourceGroups/webservers/providers/Microsoft.Network/loadBalancers/webserverLb'
at line '102' and column '10'. 'The template function 'copyIndex' is not expected at this location.
The function can only be used in a resource with copy specified.

Long story short, I'm simply trying to have the same number of NAT rules as I have VM's in the template, and dynamically assign the external port number.

Please let me know if I can provide any more information. Thank you.


Viewing all articles
Browse latest Browse all 6513

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>