Andrew D
Andrew D

Reputation: 37

add another resource in the ARM template

We have already an function app plan named ""ap-d-function1". we want to create another app plan named ""ap-d-function2". How can I include "ap-d-function2" in the existing parameters template? I tried with following but did not work.

"hostingPlanName": {
      "value": "ap-d-function1"
    },
    "hostingPlanSku": {
      "value": "P2V2"
    },

updated parameter template:

"hostingPlanName": {
      "value": "ap-d-function1","ap-d-function2"
    },
    "hostingPlanSku": {
      "value": "P2V2"
    },

tried this too

"hostingPlanName": [
{
  "value": "ap-d-function1",
    },
{
  "value": "ap-d-function2",
    }
],

Upvotes: 0

Views: 44

Answers (1)

Matt
Matt

Reputation: 13399

You could use an array type for this, e.g. declared as:

"hostingPlanNames": {
  "type": "array"
}

Then in the parameter file:

"hostingPlanNames": {
  "value": [
    "ap-d-function1",
    "ap-d-function2"     
  ]
}

Or simply use two separate parameters:

"hostingPlanName1": {
  "value": "ap-d-function1"
}

"hostingPlanName2": {
  "value": "ap-d-function2"
}

If using arrays, the simplest option is to reference them as shown in this document, e.g. to use the first value:

"someValue": "[parameters('hostingPlanNames')[0]]"

Or you can loop using a copy element within your resource and use the copyIndex() function to access the array:

"resources": [
  {
    "type": "some/resource/type",
    "name": "[parameters('hostingPlanNames')[copyIndex()]]",
    ...
    "copy": {
      "name": "myCopy",
      "count": "2"
    }
  }
]

There are various other functions that can also be used with arrays, see this document.

Upvotes: 1

Related Questions