コード例 #1
0
 public Task <KustoResult> GetKustoAuditLog(KustoQueryBody kustoQueryBody)
 {
     return(Task.FromResult(new KustoResult
     {
         Columns = new List <KustoResultColumn>
         {
             new KustoResultColumn
             {
                 ColumnName = "Message"
             }
         },
         Rows = new List <List <string> >
         {
             new List <string>
             {
                 "Audit Logs are not available when running in Local mode"
             }
         }
     }));
 }
コード例 #2
0
        public async Task <KustoResult> GetKustoAuditLog(KustoQueryBody kustoQueryBody)
        {
            var token = await this.options.ClientOptions.GetAppTokenAsync(this.options.KustoQueryOptions.ResourceUrl);

            var resultString = await KustoHttpRequest("Kusto", new Uri(this.options.KustoQueryOptions.BaseUrl), token, kustoQueryBody);

            if (string.IsNullOrEmpty(resultString))
            {
                return(null);
            }

            var result        = JArray.Parse(resultString);
            var primaryResult = result.FirstOrDefault(
                table => table["TableName"] != null && table["TableName"].ToString() == "PrimaryResult");
            var kustoResult = primaryResult != null
                ? new KustoResult
            {
                Columns = primaryResult["Columns"].ToObject <IEnumerable <KustoResultColumn> >(),
                Rows    = primaryResult["Rows"].ToObject <IEnumerable <IEnumerable <string> > >()
            }
                : null;

            return(kustoResult);
        }
コード例 #3
0
 public Task <KustoResult> KustoQuery([FromBody] KustoQueryBody kustoQueryBody)
 {
     return(this.azureKustoService.GetKustoAuditLog(kustoQueryBody));
 }
コード例 #4
0
        private static async Task <string> KustoHttpRequest(string serverName, Uri uri, string token, KustoQueryBody body)
        {
            HttpResponseMessage result;
            string resultString;

            var httpClient = new HttpClient();

            httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            result = await httpClient.PostAsync(uri, new StringContent(JsonConvert.SerializeObject(body), Encoding.UTF8, "application/json"));

            resultString = await result.Content.ReadAsStringAsync();

            result.EnsureSuccessStatusCode();

            return(resultString);
        }