asquarezone / AZUREClassRoom

ClassRoom Running Notes
0 stars 40 forks source link

Issue while executing template from portal #7

Open qt-yatin527 opened 5 years ago

qt-yatin527 commented 5 years ago

Below is my ARM template { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", "contentVersion": "1.0.0.0", "parameters": { "locate":{ "type": "string", "defaultValue": "Central US", "allowedValues": ["Central US", "East US"] }, "subnet-cidr":{ "type": "array", "defaultValue": ["10.0.0.0/24", "10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] }, "subnet-name":{ "type": "array", "defaultValue": ["max", "min", "med", "smax" ] }

},
"variables": {
    "vnetwork": {
        "type": "string",
        "defaultValue": "lgnetwork"
    },
    "space": {
        "type": "array",
        "defaultValue": ["10.0.0.0/16"]

    }
},
"resources":[
    {
        "name": "[variables('vnetwork')]",
        "type": "Microsoft.Network/virtualNetworks",
        "apiVersion": "2019-04-01",
        "location":"[parameters('locate')]",
        "properties": {
            "addressSpace":{
                "addressPrefixes": ["[variables('space')]"]
            }
        }
    },
    {
        "name": "[concat(variables('vnetwork'),'/', parameters('subnet-name')[copyIndex()])]",
        "type": "Microsoft.Network/virtualNetworks/subnets",
        "apiVersion": "2019-04-01",
        "location": "[parameters('locate')]",
        "properties": {
            "addressPrefix": "[parameters('subnet-cidr')[copyIndex()]]"
        },
        "dependsOn": 
            "[variables('vnetwork')]"
        ],
        "copy": {
            "name": "subnetloop",
            "count": "[length(parameters('subnet-cidr'))]",
            "mode": "Serial"
        }
    }

]

}

When i executed from portal facing an error

{"telemetryId":"7f66c350-9450-42cd-8fdc-18af594200e5","bladeInstanceId":"Blade_5d006d57516d4b989d0bd8da7fec62d4_50_0","galleryItemId":"Microsoft.Template","createBlade":"DeployToAzure","code":"InvalidTemplate","message":"Deployment template language expression evaluation failed: 'Unable to evaluate language function 'concat': all function arguments must be string literals, integer values, boolean values or arrays. Please see https://aka.ms/arm-template-expressions/#concat for usage details.'. Please see https://aka.ms/arm-template-expressions for usage details.","additionalInfo":[{"type":"TemplateViolation","info":{"lineNumber":0,"positionNumber":0,"snippet":""}}]}

Could you guys help me in resolving this issue.

Thanks, qt-Yatindra

blutter commented 4 years ago

variables('vnetwork') is an object here. But concat takes string arguments.