protected void SetupDataClient(RestTestFramework.MockContext context)
        {
            var credentials = new ApiKeyClientCredentials("DEMO_KEY");
            var operationalInsightsDataClient = new OperationalInsightsDataClient(credentials, HttpMockServer.CreateInstance());

            _helper.SetupManagementClients(operationalInsightsDataClient);
        }
コード例 #2
0
        private static ApplicationInsightsDataClient CreateApplicationInsightsClient(string apiKey)
        {
            var clientCredentials = new ApiKeyClientCredentials(apiKey);
            var client            = new ApplicationInsightsDataClient(clientCredentials);

            return(client);
        }
コード例 #3
0
        private ApplicationInsightsDataClient CreateApplicationInsightsClient()
        {
            var clientCredentials = new ApiKeyClientCredentials(ApplicationInsightsConfig.ApiKey);
            var client            = new ApplicationInsightsDataClient(clientCredentials);

            return(client);
        }
コード例 #4
0
        protected ApplicationInsightsDataClient CreateApplicationInsightsClient()
        {
            var clientCredentials = new ApiKeyClientCredentials(Configuration.GetValue <string>("ApplicationInsights:ApiKey"));
            var client            = new ApplicationInsightsDataClient(clientCredentials);

            return(client);
        }
コード例 #5
0
        public static Task <IHttpResponse> WebhookAsync(
            [Resource] object appInsightsCallback,
            ContentTypeResponse <EventsExceptionResult[]> onResults)
        {
            return(AppSettings.ApplicationInsights.ApplicationId.ConfigurationString(
                       applicationId =>
            {
                return AppSettings.ApplicationInsights.ClientSecret.ConfigurationString(
                    async token =>
                {
                    // Authenticate with client secret (app key)
                    var clientCred = new ApiKeyClientCredentials(token);

                    // New up a client with credentials and AI application Id
                    var client = new ApplicationInsightsDataClient(clientCred);
                    client.AppId = applicationId;

                    var exceptionEvents = await client.GetExceptionEventsAsync(
                        timespan: TimeSpan.FromMinutes(240.0),
                        top: 10,
                        format: "application/json;odata.metadata=full");
                    var requestEvents = await client.GetRequestEventsAsync(
                        timespan: TimeSpan.FromMinutes(30.0));

                    return onResults(exceptionEvents.Value.ToArray());
                });
            }));
        }
コード例 #6
0
        private OperationalInsightsDataClient GetClient(MockContext ctx, string workspaceId = DefaultWorkspaceId, string apiKey = DefaultApiKey)
        {
            var credentials = new ApiKeyClientCredentials(apiKey);
            var client      = new OperationalInsightsDataClient(credentials, HttpMockServer.CreateInstance());

            client.WorkspaceId = workspaceId;

            return(client);
        }
コード例 #7
0
        protected ApplicationInsightsDataClient GetClient(MockContext ctx, string appId = DefaultAppId, string apiKey = DefaultApiKey)
        {
            var credentials = new ApiKeyClientCredentials(apiKey);
            var client      = new ApplicationInsightsDataClient(credentials, HttpMockServer.CreateInstance());

            client.BaseUri = new Uri("https://api.applicationinsights.io/v1");

            return(client);
        }
コード例 #8
0
        public static Task <HttpResponseMessage> GetAsync(
            [QueryParameter] string eventId)
        {
            return(AppSettings.ApplicationInsights.ApplicationId.ConfigurationString(
                       applicationId =>
            {
                return AppSettings.ApplicationInsights.ClientSecret.ConfigurationString(
                    async token =>
                {
                    // Authenticate with client secret (app key)
                    var clientCred = new ApiKeyClientCredentials(token);

                    // New up a client with credentials and AI application Id
                    var client = new ApplicationInsightsDataClient(clientCred);
                    client.AppId = applicationId;

                    var asdf = await client.GetRequestEventAsync(eventId);
                    //timespan: TimeSpan.FromMinutes(30.0),);
                    // asdf.Body.Value[0].Request.

                    return new HttpResponseMessage();
                });
            }));
        }