title: Determine client id of user-assigned managed identity at runtime?
body: <p>How do I determine the Client Id of a user-assigned managed identity to an app service or function running on Azure? It's possible to assign multiple user-assigned managed identities and I'd like to get a list of the ones assigned to my app at runtime.</p>
  <p>The goal of this is to avoid having to store the client id of the managed user identity in configuration for use in creating a <code>DefaultAzureCredential</code> for accessing KeyVault and other resources.</p>
  <p>Right now my code looks like the following:</p>
  <pre><code>string managedIdentityClientId = Environment.GetEnvironmentVariable(&quot;ManagedIdentityClientId&quot;, EnvironmentVariableTarget.Process);
  var options = new DefaultAzureCredentialOptions { ManagedIdentityClientId = managedIdentityClientId };
  var keyVaultCredentials = new DefaultAzureCredential(options);
  </code></pre>
  <p>I'd like to avoid storing the <code>ManagedIdentityClientId</code> in app settings and simply read it from the configured app service if possible.</p>