Unable to post data via ElasticLowLevelClient


I'm attempting to add data into our Elastic cloud instance following the examples within the post Exporting Azure Log data to the ELK stack with Azure Functions and Event Hubs

However despite my best efforts I receive a 404 error when posting data. I've attempted the following:

  1. Using an API Key via both basic and ApiKey authentication
  2. Retrieving a document from an existing index.

All of which result in a 404 error, does anyone have any suggestions of what I'm missing?

For completeness I've included the code below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Elasticsearch.Net;

namespace ElasticLink
    class Program
        static async Task Main(string[] args)
            var exceptions = new List<Exception>();

            var elasticsearchIndex = "winlogbeat-7.9.2-2020.12.18-000001";
            var elasticsearchAddress = "https://xxxx.eastus2.azure.elastic-cloud.com:9243";
            var settings = new ConnectionConfiguration(new Uri(elasticsearchAddress));

            string apibase64 = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes("/"));

            //settings.ApiKeyAuthentication(new ApiKeyAuthenticationCredentials(apibase64));
           // settings.ApiKeyAuthentication("/");
            //settings.BasicAuthentication("elastic", "/");
            var client = new ElasticLowLevelClient(settings);
            var foo = client.Get<StringResponse>("winlogbeat-7.9.2-2020.12.18-000001", "\tMMMcgHkBHhgQL_FRFr39");

                //string messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count);

                string messageBody = "Hello";
                // you probably wouldn't want this log message in a production instance, but we'll keep it here for our testing purposes
                //log.LogInformation($"Raw Data From Function: {messageBody}");
                var response = client.Index<StringResponse>(elasticsearchIndex, PostData.String(messageBody));
                if (!response.Success)
                    throw response.ApiCall.OriginalException;

                await Task.Yield();
            catch (Exception e)
                // We need to keep processing the rest of the batch - capture this exception and continue.
                // Also, consider capturing details of the message that failed processing so it can be processed again later.
            // Once processing of the batch is complete, if any messages in the batch failed processing throw an exception so that there is a record of the failure.

            if (exceptions.Count > 1)
                throw new AggregateException(exceptions);

            if (exceptions.Count == 1)
                throw exceptions.Single();



This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.