Setup db automation
This commit is contained in:
parent
1540f9f655
commit
72544d62e2
12 changed files with 473 additions and 337 deletions
|
|
@ -1,47 +1,33 @@
|
|||
using Microsoft.ApplicationInsights;
|
||||
using Microsoft.ApplicationInsights.Channel;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel;
|
||||
using Autofac;
|
||||
|
||||
namespace SetupInfrastructure
|
||||
{
|
||||
/// <summary>
|
||||
/// SETUP APPLICATION USER NAMED sathumper
|
||||
///
|
||||
/// This should be handled on the Postgresql db server with a superadmin or similar.
|
||||
///
|
||||
/// Execute SQL CreateRole.txt
|
||||
///
|
||||
/// After that is executed it is time for running this main program
|
||||
/// Remember to use the newly created sathumper
|
||||
/// "ConnectionStrings": {
|
||||
/// "ptdb": "Host=192.168.1.57;Port=5432;Database=ptdb01;User Id=sathumper;Password=<secret>;"
|
||||
/// </summary>
|
||||
internal class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
/// <summary>
|
||||
/// SETUP APPLICATION USER NAMED sathumper
|
||||
///
|
||||
/// This should be handled on the Postgresql db server with a superadmin or similar.
|
||||
///
|
||||
/// Execute SQL CreateRole.txt
|
||||
///
|
||||
/// After that is executed it is time for running this main program
|
||||
/// Remember to use the newly created sathumper
|
||||
/// "ConnectionStrings": {
|
||||
/// "ptdb": "Host=192.168.1.57;Port=5432;Database=ptdb01;User Id=sathumper;Password=<secret>;"
|
||||
/// </summary>
|
||||
internal class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
var container = new Startup().ConfigureContainer();
|
||||
|
||||
var telemetryChannel = new ServerTelemetryChannel();
|
||||
var configuration = Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.CreateDefault();
|
||||
configuration.ConnectionString = "InstrumentationKey=2d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/";
|
||||
configuration.TelemetryChannel = telemetryChannel;
|
||||
|
||||
container.Resolve
|
||||
|
||||
|
||||
|
||||
|
||||
telemetryChannel.Initialize(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
var log = new TelemetryClient(configuration);
|
||||
log.TrackTrace("Console log med kanal 2");
|
||||
|
||||
log.Flush();
|
||||
|
||||
Console.WriteLine("Hello, World!");
|
||||
await Task.Delay(5000);
|
||||
|
||||
Console.Read();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
39
SetupInfrastructure/Startup.cs
Normal file
39
SetupInfrastructure/Startup.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using Autofac;
|
||||
using Core.Configurations;
|
||||
using Core.Configurations.JsonConfigProvider;
|
||||
|
||||
|
||||
namespace SetupInfrastructure
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public virtual IConfigurationRoot Configuration()
|
||||
{
|
||||
var configuration = new ConfigurationBuilder()
|
||||
.AddJsonFile("appconfiguration.dev.json")
|
||||
.Build();
|
||||
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public IContainer ConfigureContainer()
|
||||
{
|
||||
var builder = new ContainerBuilder();
|
||||
var configuration = Configuration();
|
||||
|
||||
|
||||
builder.RegisterModule(new Core.ModuleRegistry.DbPostgreSqlModule
|
||||
{
|
||||
ConnectionString = configuration.GetConnectionString("DefaultConnection")
|
||||
});
|
||||
|
||||
builder.RegisterModule(new Core.ModuleRegistry.TelemetryModule
|
||||
{
|
||||
TelemetryConfig = configuration.GetSection("ApplicationInsights").ToObject<Core.ModuleRegistry.TelemetryConfig>()
|
||||
});
|
||||
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"AllowedHosts": "*",
|
||||
"ConnectionStrings": {
|
||||
"ptdb": "Host=192.168.1.57;Port=5432;Database=ptdb01;User Id=sathumper;Password=3911;"
|
||||
"DefaultConnection": "Host=192.168.1.57;Port=5432;Database=ptdb01;User Id=sathumper;Password=3911;"
|
||||
},
|
||||
"ApplicationInsights": {
|
||||
"ConnectionString": "InstrumentationKey=6d2e76ee-5343-4691-a5e3-81add43cb584;IngestionEndpoint=https://northeurope-0.in.applicationinsights.azure.com/"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue