diff --git a/examples/WireMock.Net.WebApplication/Connected Services/Application Insights/ConnectedService.json b/examples/WireMock.Net.WebApplication/Connected Services/Application Insights/ConnectedService.json new file mode 100644 index 00000000..63258d4d --- /dev/null +++ b/examples/WireMock.Net.WebApplication/Connected Services/Application Insights/ConnectedService.json @@ -0,0 +1,7 @@ +{ + "ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider", + "Version": "8.14.20131.1", + "GettingStartedDocument": { + "Uri": "https://go.microsoft.com/fwlink/?LinkID=798432" + } +} \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/Program.cs b/examples/WireMock.Net.WebApplication/Program.cs index 582494f7..70ce9901 100644 --- a/examples/WireMock.Net.WebApplication/Program.cs +++ b/examples/WireMock.Net.WebApplication/Program.cs @@ -1,7 +1,7 @@ -using System; -using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; +using System; using WireMock.Settings; namespace WireMock.Net.WebApplication @@ -21,7 +21,7 @@ namespace WireMock.Net.WebApplication serviceProvider.GetService().Run(); } - private static void ConfigureServices(IServiceCollection serviceCollection) + private static void ConfigureServices(IServiceCollection services) { // Build configuration var configuration = new ConfigurationBuilder() @@ -30,28 +30,30 @@ namespace WireMock.Net.WebApplication .AddEnvironmentVariables() // <-- this is needed to to override settings via the Azure Portal App Settings .Build(); - // Add LoggerFactory + // Add LoggerFactory and Logger var factory = new LoggerFactory(); - serviceCollection.AddSingleton(factory + services.AddSingleton(factory .AddConsole(configuration.GetSection("Logging")) .AddDebug() .AddAzureWebAppDiagnostics() ); + services.AddSingleton(factory.CreateLogger("WireMock.Net Logger")); - serviceCollection.AddSingleton(factory.CreateLogger("WireMock.Net Logger")); + // Add ApplicationInsights + services.AddApplicationInsightsTelemetry(); // Add access to generic IConfigurationRoot - serviceCollection.AddSingleton(configuration); + services.AddSingleton(configuration); // Add access to IFluentMockServerSettings var settings = configuration.GetSection("FluentMockServerSettings").Get(); - serviceCollection.AddSingleton(settings); + services.AddSingleton(settings); // Add services - serviceCollection.AddTransient(); + services.AddTransient(); // Add app - serviceCollection.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/Properties/launchSettings.json b/examples/WireMock.Net.WebApplication/Properties/launchSettings.json index fd7a2608..faf53b0d 100644 --- a/examples/WireMock.Net.WebApplication/Properties/launchSettings.json +++ b/examples/WireMock.Net.WebApplication/Properties/launchSettings.json @@ -16,7 +16,8 @@ "commandName": "IISExpress", "launchUrl": "__admin/settings", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ApplicationInsights:InstrumentationKey": "..." } }, "WireMock.Net.WebApplication": { @@ -24,14 +25,16 @@ "launchBrowser": true, "launchUrl": "__admin/settings", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "Development" + "ASPNETCORE_ENVIRONMENT": "Development", + "ApplicationInsights:InstrumentationKey": "..." }, "applicationUrl": "http://localhost:56514/" }, "IIS": { "commandName": "IIS", "environmentVariables": { - "ASPNETCORE_ENVIRONMENT": "development" + "ASPNETCORE_ENVIRONMENT": "development", + "ApplicationInsights:InstrumentationKey": "..." } } } diff --git a/examples/WireMock.Net.WebApplication/WireMock.Net.WebApplication.NETCore2.csproj b/examples/WireMock.Net.WebApplication/WireMock.Net.WebApplication.NETCore2.csproj index ee3458bc..b64054b7 100644 --- a/examples/WireMock.Net.WebApplication/WireMock.Net.WebApplication.NETCore2.csproj +++ b/examples/WireMock.Net.WebApplication/WireMock.Net.WebApplication.NETCore2.csproj @@ -1,24 +1,19 @@  - netcoreapp2.0;netcoreapp2.1 - win10-x64 + netcoreapp2.1 + WireMock.Net.WebApplication.Program WireMock.Net.WebApplication WireMock.Net.WebApplication efcf4a18-fd7c-4622-825d-336d65290599 - - - - - - - + + @@ -32,4 +27,8 @@ + + + + \ No newline at end of file diff --git a/examples/WireMock.Net.WebApplication/WireMockService.cs b/examples/WireMock.Net.WebApplication/WireMockService.cs index 97dfb5d9..11fa1a4e 100644 --- a/examples/WireMock.Net.WebApplication/WireMockService.cs +++ b/examples/WireMock.Net.WebApplication/WireMockService.cs @@ -44,10 +44,10 @@ namespace WireMock.Net.WebApplication _logger.LogError(formatString, args); } - public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminrequest) + public void DebugRequestResponse(LogEntryModel logEntryModel, bool isAdminRequest) { string message = JsonConvert.SerializeObject(logEntryModel, Formatting.Indented); - _logger.LogDebug("Admin[{0}] {1}", isAdminrequest, message); + _logger.LogDebug("Admin[{0}] {1}", isAdminRequest, message); } } diff --git a/examples/WireMock.Net.WebApplication/appsettings.json b/examples/WireMock.Net.WebApplication/appsettings.json index dd16180e..4824a50f 100644 --- a/examples/WireMock.Net.WebApplication/appsettings.json +++ b/examples/WireMock.Net.WebApplication/appsettings.json @@ -1,4 +1,4 @@ -{ +{ "Logging": { "IncludeScopes": false, "Debug": { @@ -16,5 +16,8 @@ "AdminUsername": "a", "AdminPassword": "b", "StartAdminInterface": true + }, + "ApplicationInsights": { + "InstrumentationKey": "" } } \ No newline at end of file