I have an arm template to add new virtual network to an existing Event Hub Namespace.
The problem for is that i have to hard code, or ask as paramameter the vnet and subnet addresprefix.
Is there a way to not have to do this or extract those values and use the on the template ? Vnet exist subnet exist using reference function get's me the values but i get circular definition error if i use it on resource definition.
Tried to get ip's for vnet and subnet by using reference function but i cant use it in the param or variable and in resource i get Circular dependency error.
Basically i like to to this on a clean template.
"variables": {
"namespaceVirtualNetworkRuleName": "[concat(parameters('eventhubNamespaceName'), concat('/', parameters('vnetRuleName')))]",
"subNetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets/', parameters('vnetRuleName'), parameters('subnetName'))]"
},
resources : [
{
"apiVersion": "2018-01-01-preview",
"name": "[variables('namespaceVirtualNetworkRuleName')]",
"type": "Microsoft.EventHub/namespaces/VirtualNetworkRules",
"properties": {
"virtualNetworkSubnetId": "[variables('subNetId')]"
}
}
]
But i have to add vnet and subnet with correct ip for this to work.
"variables": {
"namespaceVirtualNetworkRuleName": "[concat(parameters('eventhubNamespaceName'), concat('/', parameters('vnetRuleName')))]",
"subNetId": "[resourceId('Microsoft.Network/virtualNetworks/subnets/', parameters('vnetRuleName'), parameters('subnetName'))]"
},
"resources": [
{
"apiVersion": "2018-01-01-preview",
"name": "[parameters('eventhubNamespaceName')]",
"type": "Microsoft.EventHub/namespaces",
"location": "[parameters('location')]",
"sku": {
"name": "Standard",
"tier": "Standard"
},
"properties": { }
},
{
"apiVersion": "2017-09-01",
"name": "[parameters('vnetRuleName')]",
"location": "[parameters('location')]",
"type": "Microsoft.Network/virtualNetworks",
"properties": {
"addressSpace": {
"addressPrefixes": [
"a.b.c.0/24",
"x.y.0.0/16"
]
},
"subnets": [
{
"name": "[parameters('subnetName')]",
"properties": {
"addressPrefix": "x.y.z.w/26",
"serviceEndpoints": [
{
"service": "Microsoft.EventHub"
}
]
}
}
]
}
},
{
"apiVersion": "2018-01-01-preview",
"name": "[variables('namespaceVirtualNetworkRuleName')]",
"type": "Microsoft.EventHub/namespaces/VirtualNetworkRules",
"dependsOn": [
"[concat('Microsoft.EventHub/namespaces/', parameters('eventhubNamespaceName'))]"
],
"properties": {
"virtualNetworkSubnetId": "[variables('subNetId')]"
}
}
]
Any idea on hou to remove the vnet part or at list get the ip's before the template and pass them as param ?