title: 403 when connecting to Azure App Configuration using a Managed Identity
body: <p>I am trying to connect from a net framework app to Azure App Configuration using a Managed Identity but have permission issues.</p>
  
  <p>How I connect</p>
  
  <pre><code>options.Connect(new Uri("https://myconfigstore.azconfig.io"), new ManagedIdentityCredential(clientId));
  </code></pre>
  
  <p>I have tried all the various clientId, objectids and applicationId guids I can find using the portal but are always getting a bad request no matter when guid I call it with</p>
  
  <pre><code>Azure.Identity.CredentialUnavailableException: 'ManagedIdentityCredential authentication unavailable, 
  the requested identity has not been assigned to this resource.
  Status: 400 (Bad Request)
  </code></pre>
  
  <p>If I create ManagedIdentityCredential without specifying an clientId I get this error </p>
  
  <pre><code>Azure.RequestFailedException: 'Service request failed.
  Status: 403 (Forbidden)
  </code></pre>
  
  <p>I have granted my manage identity Azure App Configuration Data permission</p>
  
  <p><a href="https://i.stack.imgur.com/ZEStv.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZEStv.png" alt="enter image description here"></a></p>
  
  <p>Is this the clientId I should be using?</p>
  
  <p><a href="https://i.stack.imgur.com/pYCxU.png" rel="noreferrer"><img src="https://i.stack.imgur.com/pYCxU.png" alt="enter image description here"></a></p>
  
  <p>Update:</p>
  
  <p>I have just tried to use the Id of my active directory (AAD --> Properties) and i get a </p>
  
  <pre><code>Azure.RequestFailedException: 'Service request failed.
  Status: 403 (Forbidden)
  </code></pre>
  
  <p>That can only mean that I am using the wrong id because otherwise it should have returned 400 (Bad Request) like in the other error I see.</p>
  
  <p>Full code</p>
  
  <pre><code>private static async Task Main()
      {
          var builder = new ConfigurationBuilder();
  
          const string clientId = "e589d9f1-xxxx-xxxx-xxxx-6bc940d50ab7";
  
          builder.AddAzureAppConfiguration(options =&gt;
          {
              options.Connect(new Uri("https://myconfigstore.azconfig.io"), new ManagedIdentityCredential(clientId));
          });
  
          _configuration = builder.Build();
  
          Console.WriteLine("Number of keys: " + _configuration.GetChildren().Count());
  
          Console.WriteLine("Demo: " + _configuration["Demo"]);
      }
  </code></pre>