RavenDb 4 Part 2 - Client Configuration
Part 1 of this article can be found here
Architecture Diagram
Now we have our RavenDb servers set up lets create a web app from scratch that will communicate with the RavenDb cluster.
dotnet new webapp -o ravendemo
dotnet add package RavenDB.Client --version 4.1.5
dotnet add package Microsoft.AspNetCore.Hosting.WindowsServices
We need our web app to be able to run as a service so in Program.cs
replace CreateWebHostBuilder(args).Build().Run
with:
var host = CreateWebHostBuilder(args).Build();
var isService = args.Contains("--service");
if (isService)
{
var baseDirectory = new FileInfo(Assembly.GetEntryAssembly().Location).Directory.FullName;
Directory.SetCurrentDirectory(baseDirectory);
}
if (isService)
{
ServiceBase.Run(new WebHostService(host));
}
else
{
host.Run();
}
Lets now add some code to configure the RavenDb DocumentStore
singleton.
X509Certificate2 certificate = new X509Certificate2(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "client.pfx"));
store.Certificate = certificate;
store.Initialize();
using(var session = store.OpenSession())
{
session.Store(new Order { Name="order1"});
session.SaveChanges();
}
instead lets use // var x509 = new X509Store(StoreLocation.LocalMachine); // x509.Open(OpenFlags.ReadOnly); // var certificate = x509.Certificates.Find(X509FindType.FindBySubjectName, "*.mooo.com", true)[0];
Last revised: 27 May, 2019 05:39 AM History
No new comments are allowed on this post.
Comments
No comments yet. Be the first!