Информация о приложении: невозможно извлечь идентификатор приложения с помощью инструментария - PullRequest
0 голосов
/ 12 ноября 2018

в моем основном проекте .NET я пытаюсь извлечь свой AppId, используя ключ интрументации, из своих идей о приложении: TelemetryConfiguration.Active.InstrumentationKey = _configuration ["ApplicationInsights: InstrumentationKey"];

            TelemetryConfiguration.Active.ApplicationIdProvider = new ApplicationInsightsApplicationIdProvider()
            {
                ProfileQueryEndpoint = "https://dc.services.visualstudio.com/api/profiles/{0}/appId"
            };
            bool isSuccessRetrieve = TelemetryConfiguration.Active.ApplicationIdProvider.TryGetApplicationId(_configuration["ApplicationInsights:InstrumentationKey"], out string applicationId);

Однако результат всегда ложен, а appID равен нулю, как будто понимание моего приложения не существует.

Есть ли какие-то конфигурации, которые я пропустил? кто-нибудь знает почему?

1 Ответ

0 голосов
/ 13 ноября 2018

Мне удалось сделать это вручную:

private bool TryGetApplicationId(string intrumentationKey, out string appId)
        {
            RestClient restClient = new RestClient("https://dc.services.visualstudio.com");
            RestRequest request = new RestRequest(string.Format("api/profiles/{0}/appId", intrumentationKey), Method.GET);
            RestResponse response = (RestResponse) restClient.Execute(request);
            appId = response.Content;
            return response.IsSuccessful;
        }
...