-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
application-insights/DotNetCoreAITester/DotNetCoreAITester.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio 15 | ||
VisualStudioVersion = 15.0.27825.0 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCoreAITester", "DotNetCoreAITester\DotNetCoreAITester.csproj", "{ADF6B7F1-8620-42BA-B946-C696C7A63D94}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{ADF6B7F1-8620-42BA-B946-C696C7A63D94}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{ADF6B7F1-8620-42BA-B946-C696C7A63D94}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{ADF6B7F1-8620-42BA-B946-C696C7A63D94}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{ADF6B7F1-8620-42BA-B946-C696C7A63D94}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {0B5B65FA-6A3C-4740-9396-0ED66C8CCB3B} | ||
EndGlobalSection | ||
EndGlobal |
7 changes: 7 additions & 0 deletions
7
...AITester/DotNetCoreAITester/Connected Services/Application Insights/ConnectedService.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"ProviderId": "Microsoft.ApplicationInsights.ConnectedService.ConnectedServiceProvider", | ||
"Version": "8.13.10511.1", | ||
"GettingStartedDocument": { | ||
"Uri": "https://go.microsoft.com/fwlink/?LinkID=798432" | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
application-insights/DotNetCoreAITester/DotNetCoreAITester/Controllers/ValuesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.ApplicationInsights; | ||
using Microsoft.ApplicationInsights.DataContracts; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace DotNetCoreAITester.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
[ApiController] | ||
public class ValuesController : ControllerBase | ||
{ | ||
|
||
static Random random = new Random(); | ||
|
||
// GET api/values | ||
[HttpGet] | ||
public ActionResult<IEnumerable<string>> Get() | ||
{ | ||
return new string[] { "value1", "value2" }; | ||
} | ||
|
||
|
||
[HttpGet] | ||
[Route("metric")] | ||
/// <summary> | ||
/// Creates custom event | ||
/// </summary> | ||
/// <param name="message"></param> | ||
/// <returns></returns> | ||
public IActionResult Metric(string name = null, double? value = null) | ||
{ | ||
name = name ?? "customMetric"; | ||
if (!value.HasValue) | ||
value = random.NextDouble(); | ||
|
||
var telemetry = new TelemetryClient(); | ||
telemetry.TrackMetric(new MetricTelemetry(name, value.Value)); | ||
|
||
return Content($"Metric {name} created with value {value}"); | ||
} | ||
|
||
[HttpGet] | ||
[Route("event")] | ||
/// <summary> | ||
/// Creates custom event | ||
/// </summary> | ||
/// <param name="message"></param> | ||
/// <returns></returns> | ||
public IActionResult Event(string name = null) | ||
{ | ||
name = name ?? "customEvent"; | ||
var telemetry = new TelemetryClient(); | ||
telemetry.TrackEvent(name); | ||
|
||
return Content($"Event {name} created"); | ||
} | ||
|
||
|
||
[HttpGet] | ||
[Route("error")] | ||
/// <summary> | ||
/// Throws an error | ||
/// </summary> | ||
/// <param name="message"></param> | ||
/// <returns></returns> | ||
public IActionResult Error(string message = null) | ||
{ | ||
message = message ?? "Bug in the system"; | ||
|
||
throw new Exception(message); | ||
} | ||
|
||
// GET api/values/5 | ||
[HttpGet("{id}")] | ||
public ActionResult<string> Get(int id) | ||
{ | ||
return "value"; | ||
} | ||
|
||
// POST api/values | ||
[HttpPost] | ||
public void Post([FromBody] string value) | ||
{ | ||
} | ||
|
||
// PUT api/values/5 | ||
[HttpPut("{id}")] | ||
public void Put(int id, [FromBody] string value) | ||
{ | ||
} | ||
|
||
// DELETE api/values/5 | ||
[HttpDelete("{id}")] | ||
public void Delete(int id) | ||
{ | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
application-insights/DotNetCoreAITester/DotNetCoreAITester/DotNetCoreAITester.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<ApplicationInsightsResourceId>/subscriptions/7a7761b9-7410-475e-a136-2ec8b8869af6/resourcegroups/default-weu/providers/microsoft.insights/components/fbrdefaultai</ApplicationInsightsResourceId> | ||
<ApplicationInsightsAnnotationResourceId>/subscriptions/7a7761b9-7410-475e-a136-2ec8b8869af6/resourcegroups/default-weu/providers/microsoft.insights/components/fbrdefaultai</ApplicationInsightsAnnotationResourceId> | ||
<UserSecretsId>11ef131f-98fd-4c78-bed1-15fa5843d69a</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="wwwroot\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.3.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.App" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<WCFMetadata Include="Connected Services" /> | ||
</ItemGroup> | ||
|
||
</Project> |
25 changes: 25 additions & 0 deletions
25
application-insights/DotNetCoreAITester/DotNetCoreAITester/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace DotNetCoreAITester | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateWebHostBuilder(args).Build().Run(); | ||
} | ||
|
||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | ||
WebHost.CreateDefaultBuilder(args) | ||
.UseApplicationInsights() | ||
.UseStartup<Startup>(); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
application-insights/DotNetCoreAITester/DotNetCoreAITester/Startup.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace DotNetCoreAITester | ||
{ | ||
public class Startup | ||
{ | ||
public Startup(IConfiguration configuration) | ||
{ | ||
Configuration = configuration; | ||
} | ||
|
||
public IConfiguration Configuration { get; } | ||
|
||
// This method gets called by the runtime. Use this method to add services to the container. | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); | ||
} | ||
|
||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. | ||
public void Configure(IApplicationBuilder app, IHostingEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.UseMvc(); | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
application-insights/DotNetCoreAITester/DotNetCoreAITester/appsettings.Development.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Debug", | ||
"System": "Information", | ||
"Microsoft": "Information" | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
application-insights/DotNetCoreAITester/DotNetCoreAITester/appsettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Logging": { | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
}, | ||
"AllowedHosts": "*", | ||
"ApplicationInsights": { | ||
"InstrumentationKey": "<set-your-application-insights-key>" | ||
} | ||
} |