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