If you have a look at this repo (from Alistair Deneys), its main focus is collating data and sending it to the cortex engine for processing:
https://github.com/adeneys/cortex-processing-demo
However, if you look at the Application.cs file (called by console application). You will find some useful code, that shows how to make an authenticated connection to XConnect (using client certificate thumbprint):
private async Task<XConnectClient> CreateXConnectClient()
{
if (_xConnectClientConfiguration == null)
{
_xConnectClientConfiguration = await CreateXConnectClientConfiguration();
}
return new XConnectClient(_xConnectClientConfiguration);
}
private async Task<XConnectClientConfiguration> CreateXConnectClientConfiguration()
{
System.Console.WriteLine("Initializing xConnect configuration...");
var uri = new Uri(_config.GetValue<string>("xconnect:uri"));
var certificateSection = _config.GetSection("xconnect:certificate");
var handlerModifiers = new List<IHttpClientHandlerModifier>();
if (certificateSection.GetChildren().Any())
{
var certificateModifier = new CertificateHttpClientHandlerModifier(certificateSection);
handlerModifiers.Add(certificateModifier);
}
var xConnectConfigurationClient = new ConfigurationWebApiClient(new Uri(uri + "configuration"), null, handlerModifiers);
var xConnectCollectionClient = new CollectionWebApiClient(new Uri(uri + "odata"), null, handlerModifiers);
var xConnectSearchClient = new SearchWebApiClient(new Uri(uri + "odata"), null, handlerModifiers);
var xConnectClientConfig = new XConnectClientConfiguration(_xDbModel, xConnectCollectionClient, xConnectSearchClient, xConnectConfigurationClient);
await xConnectClientConfig.InitializeAsync();
System.Console.WriteLine("xConnect configuration has been initialized");
return xConnectClientConfig;
}