title: Obtaining Application Insights Instrumentation Key programmatically
body: <p>I am trying to obtain the <strong>instrumentation key</strong> and <strong>api key</strong> required to configure Application Insights in my application programmatically.</p>
  
  <p>I am doing this because I have a number of applications each with separate instances of Application Insights which need to be configured independently. </p>
  
  <p>I have attempted to use <code>Microsoft.Azure.Management.ResourceManager</code> to obtain the resource on Azure but I cannot see a way to get or set the required information.</p>
  
  <p>This is what I have so far</p>
  
  <pre><code>ServiceClientCredentials credentials = await AuthenticationManagement.GetToken();
  
  using (var resourceClient = new ResourceManagementClient(credentials))
  {
      resourceClient.SubscriptionId = AuthenticationManagement.SubscriptionId;
  
      foreach (var item in resourceClient.Resources.List(new ODataQuery&lt;GenericResourceFilter&gt;(o =&gt; o.ResourceType == "microsoft.insights/components")
      {
          Expand = "$expand=Properties"
      }))
      {
          Console.WriteLine(item.Properties); //Still empty?
      }
  
  }
  </code></pre>
  
  <p>I've gotten stuck at this point because I see no obvious method for updating or retrieving the values I need from the API.</p>
  
  <p>So could anyone provide any guidance on how I might be able to retrieve this information using the <code>ResourceManagementClient</code>?</p>