title: How to convert an array into properties of one object in an ARM template?
body: <p>I am looking for a way to convert an array (e.g. of strings) into one object, where the properties are generated from the array values.</p>
  <p>Use case: I want to generate a <code>tags</code> object with links to resources, based on a list of resource names. I need to do this, to <a href="https://stackoverflow.com/questions/38578122/what-does-hidden-link-mean-in-azure-resource-manager-tags">link <code>App Service</code> resources to an <code>Application Insights</code> resource</a>.</p>
  <p>The list of resources could be supplied using a parameter:</p>
  <pre><code>&quot;parameters&quot;: {
    &quot;appServices&quot;: {
      &quot;type&quot;: &quot;array&quot;,
      &quot;metadata&quot;: {
        &quot;description&quot;: &quot;Names of app services to link this application insights resource to via hidden tags&quot;
      }
    }
  }
  </code></pre>
  <p>Sample input:</p>
  <pre><code>['appName1', 'appName2', 'appName3']
  </code></pre>
  <p>Sample output:</p>
  <pre><code>&quot;tags&quot;:
  {
    &quot;[concat('hidden-link:', resourceId('Microsoft.Web/sites/', 'appName1'))]&quot;: &quot;Resource&quot;,
    &quot;[concat('hidden-link:', resourceId('Microsoft.Web/sites/', 'appName2'))]&quot;: &quot;Resource&quot;,
    &quot;[concat('hidden-link:', resourceId('Microsoft.Web/sites/', 'appName3'))]&quot;: &quot;Resource&quot;
  }
  </code></pre>
  <p>I know you can use <a href="https://docs.microsoft.comen-us/azure/azure-resource-manager/templates/copy-variables" rel="nofollow noreferrer"><code>copy</code></a> to loop over arrays but that will create an <strong>array of objects</strong> and <strong>not a single object</strong> (which is required for tags), for example:</p>
  <pre><code>[
  {
    &quot;[concat('hidden-link:', resourceId('Microsoft.Web/sites/', 'appName1'))]&quot;: &quot;Resource&quot;
  },
  {
    &quot;[concat('hidden-link:', resourceId('Microsoft.Web/sites/', 'appName2'))]&quot;: &quot;Resource&quot;
  },
  {
    &quot;[concat('hidden-link:', resourceId('Microsoft.Web/sites/', 'appName3'))]&quot;: &quot;Resource&quot;
  }
  ]
  </code></pre>
  <p>It would be possible to use <a href="https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-object#union" rel="nofollow noreferrer"><code>union</code></a> to merge those objects again, but that function requires you to hardcode the objects you want to merge, so it <strong>does not work when you have an input with variable length</strong>.</p>
  <p>What I am looking for is a way to do this in a dynamic way.</p>