0

I try to minimize my ARM Template but I'm stuck here...

My original template is :

    "parameters": {
        "subscriptionId": {
            "type": "String"
        },
        "resourcegroupName": {
            "type": "String"
        },
.....
        "databases": {
            "type": "Array"
        },
        "failoverPolicy": {
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Sql/servers/failoverGroups",
            "name": "[concat(parameters('primaryServer'), '/', parameters('failovergroupName'))]",
            "apiVersion": "2015-05-01-preview",
            "location": "eastus",
            "properties": {
                "readWriteEndpoint": {
                    "failoverPolicy": "[parameters('failoverPolicy')]"
                },
                "partnerServers": [
                    {
                        "id": "[concat('/subscriptions/',parameters('subscriptionId'),'/resourceGroups/',parameters('resourcegroupName'),'/providers/Microsoft.Sql/servers/',parameters('partnerServer'))]"
                    }
                ],
                "databases": "[parameters('databases')]"
            },
            "dependsOn": [
                "[concat('Microsoft.Sql/servers/',parameters('partnerServer'))]",
                "[concat('Microsoft.Sql/servers/',parameters('partnerServer'),'/elasticPools/',parameters('primaryElasticPoolName'))]"
            ]
        },
....

and my parameters file contains:

    "parameters": {
        "subscriptionId": {
            "value": "11111-4444-5555-666-777777777"
        },
        "resourcegroupName": {
            "type": "RG-ElasticPool"
        },

        "primaryElasticPoolName": {
            "value": "crelasticpool01"
        },

....
            "databases": {
            "value": [
                "/subscriptions/11111-4444-5555-666-777777777/resourceGroups/RG-ElasticPool/providers/Microsoft.Sql/servers/crelasticsrv01/databases/crelasticdb03",
                "/subscriptions/11111-4444-5555-666-777777777/resourceGroups/RG-ElasticPool/providers/Microsoft.Sql/servers/crelasticsrv01/databases/crelasticdb02",
                "/subscriptions/11111-4444-5555-666-777777777/resourceGroups/RG-ElasticPool/providers/Microsoft.Sql/servers/crelasticsrv01/databases/crelasticdb01"
            ]
        },
        "failoverPolicy": {
            "value": "Manual"
        }
    }

I would be able to have only :

"databases": {
            "value": [
                "crelasticdb03",
                "crelasticdb02",
                "crelasticdb01"
            ]

in my parameters file instead of the long id and concat the long id in my template file

I try with several config like:

"databases": "[concat('/subscriptions/',parameters('subscriptionId'),'/resourceGroups/',parameters('resourcegroupName'),'/providers/Microsoft.Sql/servers/',parameters('primaryServer'),'/databases/',parameters('databases')[copyIndex()])]"

but I always get an deployment error relative to the copyindex...

4c74356b41
  • 69,186
  • 6
  • 100
  • 141
Chris
  • 77
  • 1
  • 5

1 Answers1

1

you cannot use copy function to create array, unfortunately. you can only create array of objects with it. you seem to require an array of string, which is not possible.

you can work around with nested template and looping, but its a lot easier\cleaner to just go with what you have, tbh.

4c74356b41
  • 69,186
  • 6
  • 100
  • 141