title: ARM template for Event Grid API Connection with managed identity
body: <p>When creating a new Event Grid connection from a Logic App, one can select from the following 3 authentication methods for the connection:</p>
  <ol>
  <li>Sign in</li>
  <li>Service principal</li>
  <li>Managed identity</li>
  </ol>
  <p><strong>#1 Sign in</strong> requires a user to sign in / authenticate interactively.</p>
  <p><strong>#2 Service principal</strong> requires <em>Tenant</em>, <em>Client ID</em>, and <em>Client Secret</em> values to be provided.</p>
  <p>It is clear how an ARM template for such an API connection would need to be amended: the <a href="https://stackoverflow.com/a/54892566/624368"><code>parameterValues</code></a> need to be added as follows.</p>
  <pre><code>&quot;parameterValues&quot;: {
    &quot;token:clientId&quot;: &quot;[parameters('ConnectionClientId')]&quot;,
    &quot;token:clientSecret&quot;: &quot;[parameters('ConnectionClientSecret')]&quot;,
    &quot;token:TenantId&quot;: &quot;[parameters('ConnectionTenantId')]&quot;,
    &quot;token:resourceUri&quot;: &quot;https://management.core.windows.net/&quot;,
    &quot;token:grantType&quot;: &quot;client_credentials&quot;
  }
  </code></pre>
  <p><strong>#3 Managed identity</strong> requires only the managed identity to be selected. While it is clear how to create such an API connection interactively, I couldn't find any information on the ARM template format for such an authentication method.</p>
  <p>So the question is - how exactly should an ARM template for Event Grid connection with a (<strong>update</strong>: <em>user assigned</em>) managed identity look like? So that the created API connection looks as follows:</p>
  <p><a href="https://i.stack.imgur.com/aSL5q.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aSL5q.png" alt="API Connection with managed identity" /></a></p>
  <p><strong>Update</strong>: I need to use a <em>user assigned</em> managed identity in my Logic App. An answer has been provided below that works for <em>system assigned</em> managed identities, but not for <em>user assigned</em> ones. If someone can advise an ARM template for an API connection that uses a <em>user assigned</em> managed identity, that will be appreciated.</p>