Looping through values in ARM templates











up vote
0
down vote

favorite












I've been working on an issue I'm having with ARM templates for over a day now, and seem to be stuck, so asking on SO in case anyone can help.



To describe the issue, I've got an existing Azure Key Vault setup, and wish to add a number of access policies to this resource group. For reference purposes, the following is the ARM template reference for adding Key Vault Access Policies:



https://docs.microsoft.com/en-gb/azure/templates/Microsoft.KeyVault/2018-02-14/vaults/accessPolicies



I have a number of users I wish to assign the same permissions to, and this list of users is unlikely to change frequently, so I wish to hardcode an array of objectIds referring to these users within the template itself, and then use the "copy" functionality to create multiple access policy . Essentially I want the end result to be close to this, where the only value that changes between access policies is the objectID identifying the user:



{
"name": "TestKeyVault/add",
"type": "Microsoft.KeyVault/vaults/accessPolicies",
"apiVersion": "2018-02-14",
"properties": {
"accessPolicies": [

{
"tenantId": "tenantIDStringGoesHere",
"objectId": "guidForUser1GoesHere",
"permissions": {
"keys": ["List"],
"secrets": ["List"],
"certificates": ["List"]
}
},

{
"tenantId": "tenantIDStringGoesHere",
"objectId": "guidForUser2GoesHere",
"permissions": {
"keys": ["List"],
"secrets": ["List"],
"certificates": ["List"]
}
}

]
}
}


The reason I want to sort this out with a loop rather than duplicating the access policies by hand is that I believe it'll make maintenance easier, as personnel changes can be handled by adding or removing values from an array rather than having to duplicate or remove larger portions of text.



I've tried to understand the "copy" syntax outlined here, but I haven't found the right combination that works for my use case:



https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple



The closest I've got is the following:



{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {

"keyVaultName": {
"type": "string",
"metadata": {
"description": "Name of the Vault"
}
},

"tenantId": {
"type": "string",
"defaultValue": "[subscription().tenantId]",
"metadata": {
"description": "Tenant Id of the subscription. Get using Get-AzureRmSubscription cmdlet or Get Subscription API"
}
},

"objectId": {
"type": "array",
"defaultValue": [
"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
],
"metadata": {
"description": "Object Id of the AD user. Get using Get-AzureRmADUser or Get-AzureRmADServicePrincipal cmdlets"
}
},

"secretsPermissions": {
"type": "array",
"defaultValue": [
"list"
],
"metadata": {
"description": "Permissions to secrets in the vault. Valid values are: all, get, set, list, and delete."
}
}

},

"variables": {
"objectIdCount": "[length(parameters('objectId'))]"
},

"resources": [
{

"type": "Microsoft.KeyVault/vaults/accessPolicies",
"name": "TestKeyVault/add",
"apiVersion": "2018-02-14",
"properties": {
"accessPolicies": [{
"tenantId": "[parameters('tenantId')]",
"objectId": "[parameters('objectId')[copyIndex('objectIdCopy')]]",
"permissions": {
"secrets": "[parameters('secretsPermissions')]"
},
"copy": {
"name": "objectIdCopy",
"count": 2
}


}]
}

}
]

}


Worth noting that whilst I've replaced the objectIds in this SO version with X's and Y's, the code works in the real version if I replace "objectId": "[parameters('objectId')[copyIndex('objectIdCopy')]]" with "objectId": "[parameters('objectId')[0]]" (in other words, if I just hardcode the array index it works, but if I try to use copyIndex it does not).



I've had various error messages with the different variants of this template that I've tried, but with this latest iteration the error message I get when attempting to deploy the template through PowerShell can basically be summarised as "The template function 'copyIndex' is not expected at this location".



Talking of the PowerShell I've been using to test it, the following is a simplified version:



Clear-Host

$deploymentResourceGroupName = 'TestRG'

$templatePath = 'test_template.json'

$templateParameterObject = @{}
$templateParameterObject += @{'keyVaultName' = 'TestKeyVault'}

New-AzureRmResourceGroupDeployment -ResourceGroupName $deploymentResourceGroupName -TemplateFile $templatePath -TemplateParameterObject $templateParameterObject


I realise this is a long question, but I'm hoping I've provided sufficient information to help with debugging this.



Any suggestions what I should change to get the copy functionality working?










share|improve this question


























    up vote
    0
    down vote

    favorite












    I've been working on an issue I'm having with ARM templates for over a day now, and seem to be stuck, so asking on SO in case anyone can help.



    To describe the issue, I've got an existing Azure Key Vault setup, and wish to add a number of access policies to this resource group. For reference purposes, the following is the ARM template reference for adding Key Vault Access Policies:



    https://docs.microsoft.com/en-gb/azure/templates/Microsoft.KeyVault/2018-02-14/vaults/accessPolicies



    I have a number of users I wish to assign the same permissions to, and this list of users is unlikely to change frequently, so I wish to hardcode an array of objectIds referring to these users within the template itself, and then use the "copy" functionality to create multiple access policy . Essentially I want the end result to be close to this, where the only value that changes between access policies is the objectID identifying the user:



    {
    "name": "TestKeyVault/add",
    "type": "Microsoft.KeyVault/vaults/accessPolicies",
    "apiVersion": "2018-02-14",
    "properties": {
    "accessPolicies": [

    {
    "tenantId": "tenantIDStringGoesHere",
    "objectId": "guidForUser1GoesHere",
    "permissions": {
    "keys": ["List"],
    "secrets": ["List"],
    "certificates": ["List"]
    }
    },

    {
    "tenantId": "tenantIDStringGoesHere",
    "objectId": "guidForUser2GoesHere",
    "permissions": {
    "keys": ["List"],
    "secrets": ["List"],
    "certificates": ["List"]
    }
    }

    ]
    }
    }


    The reason I want to sort this out with a loop rather than duplicating the access policies by hand is that I believe it'll make maintenance easier, as personnel changes can be handled by adding or removing values from an array rather than having to duplicate or remove larger portions of text.



    I've tried to understand the "copy" syntax outlined here, but I haven't found the right combination that works for my use case:



    https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple



    The closest I've got is the following:



    {
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {

    "keyVaultName": {
    "type": "string",
    "metadata": {
    "description": "Name of the Vault"
    }
    },

    "tenantId": {
    "type": "string",
    "defaultValue": "[subscription().tenantId]",
    "metadata": {
    "description": "Tenant Id of the subscription. Get using Get-AzureRmSubscription cmdlet or Get Subscription API"
    }
    },

    "objectId": {
    "type": "array",
    "defaultValue": [
    "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
    ],
    "metadata": {
    "description": "Object Id of the AD user. Get using Get-AzureRmADUser or Get-AzureRmADServicePrincipal cmdlets"
    }
    },

    "secretsPermissions": {
    "type": "array",
    "defaultValue": [
    "list"
    ],
    "metadata": {
    "description": "Permissions to secrets in the vault. Valid values are: all, get, set, list, and delete."
    }
    }

    },

    "variables": {
    "objectIdCount": "[length(parameters('objectId'))]"
    },

    "resources": [
    {

    "type": "Microsoft.KeyVault/vaults/accessPolicies",
    "name": "TestKeyVault/add",
    "apiVersion": "2018-02-14",
    "properties": {
    "accessPolicies": [{
    "tenantId": "[parameters('tenantId')]",
    "objectId": "[parameters('objectId')[copyIndex('objectIdCopy')]]",
    "permissions": {
    "secrets": "[parameters('secretsPermissions')]"
    },
    "copy": {
    "name": "objectIdCopy",
    "count": 2
    }


    }]
    }

    }
    ]

    }


    Worth noting that whilst I've replaced the objectIds in this SO version with X's and Y's, the code works in the real version if I replace "objectId": "[parameters('objectId')[copyIndex('objectIdCopy')]]" with "objectId": "[parameters('objectId')[0]]" (in other words, if I just hardcode the array index it works, but if I try to use copyIndex it does not).



    I've had various error messages with the different variants of this template that I've tried, but with this latest iteration the error message I get when attempting to deploy the template through PowerShell can basically be summarised as "The template function 'copyIndex' is not expected at this location".



    Talking of the PowerShell I've been using to test it, the following is a simplified version:



    Clear-Host

    $deploymentResourceGroupName = 'TestRG'

    $templatePath = 'test_template.json'

    $templateParameterObject = @{}
    $templateParameterObject += @{'keyVaultName' = 'TestKeyVault'}

    New-AzureRmResourceGroupDeployment -ResourceGroupName $deploymentResourceGroupName -TemplateFile $templatePath -TemplateParameterObject $templateParameterObject


    I realise this is a long question, but I'm hoping I've provided sufficient information to help with debugging this.



    Any suggestions what I should change to get the copy functionality working?










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I've been working on an issue I'm having with ARM templates for over a day now, and seem to be stuck, so asking on SO in case anyone can help.



      To describe the issue, I've got an existing Azure Key Vault setup, and wish to add a number of access policies to this resource group. For reference purposes, the following is the ARM template reference for adding Key Vault Access Policies:



      https://docs.microsoft.com/en-gb/azure/templates/Microsoft.KeyVault/2018-02-14/vaults/accessPolicies



      I have a number of users I wish to assign the same permissions to, and this list of users is unlikely to change frequently, so I wish to hardcode an array of objectIds referring to these users within the template itself, and then use the "copy" functionality to create multiple access policy . Essentially I want the end result to be close to this, where the only value that changes between access policies is the objectID identifying the user:



      {
      "name": "TestKeyVault/add",
      "type": "Microsoft.KeyVault/vaults/accessPolicies",
      "apiVersion": "2018-02-14",
      "properties": {
      "accessPolicies": [

      {
      "tenantId": "tenantIDStringGoesHere",
      "objectId": "guidForUser1GoesHere",
      "permissions": {
      "keys": ["List"],
      "secrets": ["List"],
      "certificates": ["List"]
      }
      },

      {
      "tenantId": "tenantIDStringGoesHere",
      "objectId": "guidForUser2GoesHere",
      "permissions": {
      "keys": ["List"],
      "secrets": ["List"],
      "certificates": ["List"]
      }
      }

      ]
      }
      }


      The reason I want to sort this out with a loop rather than duplicating the access policies by hand is that I believe it'll make maintenance easier, as personnel changes can be handled by adding or removing values from an array rather than having to duplicate or remove larger portions of text.



      I've tried to understand the "copy" syntax outlined here, but I haven't found the right combination that works for my use case:



      https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple



      The closest I've got is the following:



      {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {

      "keyVaultName": {
      "type": "string",
      "metadata": {
      "description": "Name of the Vault"
      }
      },

      "tenantId": {
      "type": "string",
      "defaultValue": "[subscription().tenantId]",
      "metadata": {
      "description": "Tenant Id of the subscription. Get using Get-AzureRmSubscription cmdlet or Get Subscription API"
      }
      },

      "objectId": {
      "type": "array",
      "defaultValue": [
      "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
      ],
      "metadata": {
      "description": "Object Id of the AD user. Get using Get-AzureRmADUser or Get-AzureRmADServicePrincipal cmdlets"
      }
      },

      "secretsPermissions": {
      "type": "array",
      "defaultValue": [
      "list"
      ],
      "metadata": {
      "description": "Permissions to secrets in the vault. Valid values are: all, get, set, list, and delete."
      }
      }

      },

      "variables": {
      "objectIdCount": "[length(parameters('objectId'))]"
      },

      "resources": [
      {

      "type": "Microsoft.KeyVault/vaults/accessPolicies",
      "name": "TestKeyVault/add",
      "apiVersion": "2018-02-14",
      "properties": {
      "accessPolicies": [{
      "tenantId": "[parameters('tenantId')]",
      "objectId": "[parameters('objectId')[copyIndex('objectIdCopy')]]",
      "permissions": {
      "secrets": "[parameters('secretsPermissions')]"
      },
      "copy": {
      "name": "objectIdCopy",
      "count": 2
      }


      }]
      }

      }
      ]

      }


      Worth noting that whilst I've replaced the objectIds in this SO version with X's and Y's, the code works in the real version if I replace "objectId": "[parameters('objectId')[copyIndex('objectIdCopy')]]" with "objectId": "[parameters('objectId')[0]]" (in other words, if I just hardcode the array index it works, but if I try to use copyIndex it does not).



      I've had various error messages with the different variants of this template that I've tried, but with this latest iteration the error message I get when attempting to deploy the template through PowerShell can basically be summarised as "The template function 'copyIndex' is not expected at this location".



      Talking of the PowerShell I've been using to test it, the following is a simplified version:



      Clear-Host

      $deploymentResourceGroupName = 'TestRG'

      $templatePath = 'test_template.json'

      $templateParameterObject = @{}
      $templateParameterObject += @{'keyVaultName' = 'TestKeyVault'}

      New-AzureRmResourceGroupDeployment -ResourceGroupName $deploymentResourceGroupName -TemplateFile $templatePath -TemplateParameterObject $templateParameterObject


      I realise this is a long question, but I'm hoping I've provided sufficient information to help with debugging this.



      Any suggestions what I should change to get the copy functionality working?










      share|improve this question













      I've been working on an issue I'm having with ARM templates for over a day now, and seem to be stuck, so asking on SO in case anyone can help.



      To describe the issue, I've got an existing Azure Key Vault setup, and wish to add a number of access policies to this resource group. For reference purposes, the following is the ARM template reference for adding Key Vault Access Policies:



      https://docs.microsoft.com/en-gb/azure/templates/Microsoft.KeyVault/2018-02-14/vaults/accessPolicies



      I have a number of users I wish to assign the same permissions to, and this list of users is unlikely to change frequently, so I wish to hardcode an array of objectIds referring to these users within the template itself, and then use the "copy" functionality to create multiple access policy . Essentially I want the end result to be close to this, where the only value that changes between access policies is the objectID identifying the user:



      {
      "name": "TestKeyVault/add",
      "type": "Microsoft.KeyVault/vaults/accessPolicies",
      "apiVersion": "2018-02-14",
      "properties": {
      "accessPolicies": [

      {
      "tenantId": "tenantIDStringGoesHere",
      "objectId": "guidForUser1GoesHere",
      "permissions": {
      "keys": ["List"],
      "secrets": ["List"],
      "certificates": ["List"]
      }
      },

      {
      "tenantId": "tenantIDStringGoesHere",
      "objectId": "guidForUser2GoesHere",
      "permissions": {
      "keys": ["List"],
      "secrets": ["List"],
      "certificates": ["List"]
      }
      }

      ]
      }
      }


      The reason I want to sort this out with a loop rather than duplicating the access policies by hand is that I believe it'll make maintenance easier, as personnel changes can be handled by adding or removing values from an array rather than having to duplicate or remove larger portions of text.



      I've tried to understand the "copy" syntax outlined here, but I haven't found the right combination that works for my use case:



      https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple



      The closest I've got is the following:



      {
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {

      "keyVaultName": {
      "type": "string",
      "metadata": {
      "description": "Name of the Vault"
      }
      },

      "tenantId": {
      "type": "string",
      "defaultValue": "[subscription().tenantId]",
      "metadata": {
      "description": "Tenant Id of the subscription. Get using Get-AzureRmSubscription cmdlet or Get Subscription API"
      }
      },

      "objectId": {
      "type": "array",
      "defaultValue": [
      "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy"
      ],
      "metadata": {
      "description": "Object Id of the AD user. Get using Get-AzureRmADUser or Get-AzureRmADServicePrincipal cmdlets"
      }
      },

      "secretsPermissions": {
      "type": "array",
      "defaultValue": [
      "list"
      ],
      "metadata": {
      "description": "Permissions to secrets in the vault. Valid values are: all, get, set, list, and delete."
      }
      }

      },

      "variables": {
      "objectIdCount": "[length(parameters('objectId'))]"
      },

      "resources": [
      {

      "type": "Microsoft.KeyVault/vaults/accessPolicies",
      "name": "TestKeyVault/add",
      "apiVersion": "2018-02-14",
      "properties": {
      "accessPolicies": [{
      "tenantId": "[parameters('tenantId')]",
      "objectId": "[parameters('objectId')[copyIndex('objectIdCopy')]]",
      "permissions": {
      "secrets": "[parameters('secretsPermissions')]"
      },
      "copy": {
      "name": "objectIdCopy",
      "count": 2
      }


      }]
      }

      }
      ]

      }


      Worth noting that whilst I've replaced the objectIds in this SO version with X's and Y's, the code works in the real version if I replace "objectId": "[parameters('objectId')[copyIndex('objectIdCopy')]]" with "objectId": "[parameters('objectId')[0]]" (in other words, if I just hardcode the array index it works, but if I try to use copyIndex it does not).



      I've had various error messages with the different variants of this template that I've tried, but with this latest iteration the error message I get when attempting to deploy the template through PowerShell can basically be summarised as "The template function 'copyIndex' is not expected at this location".



      Talking of the PowerShell I've been using to test it, the following is a simplified version:



      Clear-Host

      $deploymentResourceGroupName = 'TestRG'

      $templatePath = 'test_template.json'

      $templateParameterObject = @{}
      $templateParameterObject += @{'keyVaultName' = 'TestKeyVault'}

      New-AzureRmResourceGroupDeployment -ResourceGroupName $deploymentResourceGroupName -TemplateFile $templatePath -TemplateParameterObject $templateParameterObject


      I realise this is a long question, but I'm hoping I've provided sufficient information to help with debugging this.



      Any suggestions what I should change to get the copy functionality working?







      azure powershell arm-template azure-resource-group






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 at 16:12









      ZenoArrow

      5019




      5019
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          This is more or less what you want (if I understand you properly):



          {
          "type": "Microsoft.KeyVault/vaults/accessPolicies",
          "name": "TestKeyVault/add",
          "apiVersion": "2018-02-14",
          "properties": {
          "copy": [
          {
          "name": "accessPolicies",
          "count": "[length(parameters('objectId'))]",
          "input": {
          "tenantId": "[parameters('tenantId')]",
          "objectId": "[parameters('objectId')[copyIndex('accessPolicies')]]",
          "permissions": {
          "secrets": "[parameters('secretsPermissions')]"
          }
          }
          }
          ]
          }
          }


          Reading: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#property-iteration






          share|improve this answer

















          • 2




            Thank you! Your suggestion worked, I missed that the "name" value needed to be the value of the property to loop through. Thank you for adding the direct link to the relevant documentation as well.
            – ZenoArrow
            Nov 15 at 17:35











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323560%2flooping-through-values-in-arm-templates%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          1
          down vote



          accepted










          This is more or less what you want (if I understand you properly):



          {
          "type": "Microsoft.KeyVault/vaults/accessPolicies",
          "name": "TestKeyVault/add",
          "apiVersion": "2018-02-14",
          "properties": {
          "copy": [
          {
          "name": "accessPolicies",
          "count": "[length(parameters('objectId'))]",
          "input": {
          "tenantId": "[parameters('tenantId')]",
          "objectId": "[parameters('objectId')[copyIndex('accessPolicies')]]",
          "permissions": {
          "secrets": "[parameters('secretsPermissions')]"
          }
          }
          }
          ]
          }
          }


          Reading: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#property-iteration






          share|improve this answer

















          • 2




            Thank you! Your suggestion worked, I missed that the "name" value needed to be the value of the property to loop through. Thank you for adding the direct link to the relevant documentation as well.
            – ZenoArrow
            Nov 15 at 17:35















          up vote
          1
          down vote



          accepted










          This is more or less what you want (if I understand you properly):



          {
          "type": "Microsoft.KeyVault/vaults/accessPolicies",
          "name": "TestKeyVault/add",
          "apiVersion": "2018-02-14",
          "properties": {
          "copy": [
          {
          "name": "accessPolicies",
          "count": "[length(parameters('objectId'))]",
          "input": {
          "tenantId": "[parameters('tenantId')]",
          "objectId": "[parameters('objectId')[copyIndex('accessPolicies')]]",
          "permissions": {
          "secrets": "[parameters('secretsPermissions')]"
          }
          }
          }
          ]
          }
          }


          Reading: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#property-iteration






          share|improve this answer

















          • 2




            Thank you! Your suggestion worked, I missed that the "name" value needed to be the value of the property to loop through. Thank you for adding the direct link to the relevant documentation as well.
            – ZenoArrow
            Nov 15 at 17:35













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          This is more or less what you want (if I understand you properly):



          {
          "type": "Microsoft.KeyVault/vaults/accessPolicies",
          "name": "TestKeyVault/add",
          "apiVersion": "2018-02-14",
          "properties": {
          "copy": [
          {
          "name": "accessPolicies",
          "count": "[length(parameters('objectId'))]",
          "input": {
          "tenantId": "[parameters('tenantId')]",
          "objectId": "[parameters('objectId')[copyIndex('accessPolicies')]]",
          "permissions": {
          "secrets": "[parameters('secretsPermissions')]"
          }
          }
          }
          ]
          }
          }


          Reading: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#property-iteration






          share|improve this answer












          This is more or less what you want (if I understand you properly):



          {
          "type": "Microsoft.KeyVault/vaults/accessPolicies",
          "name": "TestKeyVault/add",
          "apiVersion": "2018-02-14",
          "properties": {
          "copy": [
          {
          "name": "accessPolicies",
          "count": "[length(parameters('objectId'))]",
          "input": {
          "tenantId": "[parameters('tenantId')]",
          "objectId": "[parameters('objectId')[copyIndex('accessPolicies')]]",
          "permissions": {
          "secrets": "[parameters('secretsPermissions')]"
          }
          }
          }
          ]
          }
          }


          Reading: https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple#property-iteration







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 at 16:18









          4c74356b41

          23.5k32050




          23.5k32050








          • 2




            Thank you! Your suggestion worked, I missed that the "name" value needed to be the value of the property to loop through. Thank you for adding the direct link to the relevant documentation as well.
            – ZenoArrow
            Nov 15 at 17:35














          • 2




            Thank you! Your suggestion worked, I missed that the "name" value needed to be the value of the property to loop through. Thank you for adding the direct link to the relevant documentation as well.
            – ZenoArrow
            Nov 15 at 17:35








          2




          2




          Thank you! Your suggestion worked, I missed that the "name" value needed to be the value of the property to loop through. Thank you for adding the direct link to the relevant documentation as well.
          – ZenoArrow
          Nov 15 at 17:35




          Thank you! Your suggestion worked, I missed that the "name" value needed to be the value of the property to loop through. Thank you for adding the direct link to the relevant documentation as well.
          – ZenoArrow
          Nov 15 at 17:35


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53323560%2flooping-through-values-in-arm-templates%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          mysqli_query(): Empty query in /home/lucindabrummitt/public_html/blog/wp-includes/wp-db.php on line 1924

          How to change which sound is reproduced for terminal bell?

          Can I use Tabulator js library in my java Spring + Thymeleaf project?