Skip to content

Commit

Permalink
Dev/saars/dev f5 env (#186)
Browse files Browse the repository at this point in the history
* Add a webapi for F5 into debugging

* Add a workspace

* Fix a small thing in MultipleKeys example

* Add tasks to build examples

* Remove launch.json for product code

* Update F5 WebApi project
  • Loading branch information
xiaomi7732 authored Jun 7, 2019
1 parent 3a2f55f commit 36e31d3
Show file tree
Hide file tree
Showing 19 changed files with 374 additions and 90 deletions.
55 changes: 0 additions & 55 deletions .vscode/tasks.json

This file was deleted.

24 changes: 24 additions & 0 deletions dev/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Launch - F5 WebApi",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build F5 WebApi",
"program": "${workspaceFolder}/F5WebApi/bin/Debug/netcoreapp2.2/F5WebApi.dll",
"args": [],
"cwd": "${workspaceFolder}/F5WebApi",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
]
}
20 changes: 20 additions & 0 deletions dev/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build F5 WebApi",
"command": "dotnet build",
"type": "shell",
"group": "build",
"presentation": {
"reveal": "always"
},
"options": {
"cwd": "${workspaceFolder}/F5WebApi"
},
"problemMatcher": "$msCompile"
}
]
}
45 changes: 45 additions & 0 deletions dev/F5WebApi/Controllers/ValuesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;

namespace F5WebApi.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class ValuesController : ControllerBase
{
// GET api/values
[HttpGet]
public ActionResult<IEnumerable<string>> Get()
{
return new string[] { "value1", "value2" };
}

// 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)
{
}
}
}
17 changes: 17 additions & 0 deletions dev/F5WebApi/F5WebApi.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.7.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\ApplicationInsights.Kubernetes\ApplicationInsights.Kubernetes.csproj" />
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions dev/F5WebApi/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;

namespace F5WebApi
{
public class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

public static IWebHostBuilder CreateHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
}
}
30 changes: 30 additions & 0 deletions dev/F5WebApi/Properties/launchSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:31345",
"sslPort": 44371
}
},
"profiles": {
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "api/values",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"F5WebApi": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "api/values",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
59 changes: 59 additions & 0 deletions dev/F5WebApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using System.Diagnostics;
using Microsoft.ApplicationInsights.Kubernetes.Debugging;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace F5WebApi
{
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)
{
// To use this project for F5 debugging, follow these steps:

// Output the diagnostic source logs to the console.
var observer = new ApplicationInsightsKubernetesDiagnosticObserver(DiagnosticLogLevel.Trace);
ApplicationInsightsKubernetesDiagnosticSource.Instance.Observable.SubscribeWithAdapter(observer);

// Step 1. Set iKey in the parameter below.
services.AddApplicationInsightsTelemetry("your-instrumentation-key");

// Step 2. Call proper overloads of AddApplicationInsightsKubernetesEnricher.
services.AddApplicationInsightsKubernetesEnricher(applyOptions: null,
kubernetesServiceCollectionBuilder: KubernetesDebuggingServiceCollectionBuilderFactory.Instance.Create(),
detectKubernetes: () => true);
// Step 3. Set a break point and press F5.
// ~

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
}

// 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();
}
else
{
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
app.UseHsts();
}

app.UseHttpsRedirection();
app.UseMvc();
}
}
}
9 changes: 9 additions & 0 deletions dev/F5WebApi/appsettings.Development.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
}
}
9 changes: 9 additions & 0 deletions dev/F5WebApi/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
7 changes: 3 additions & 4 deletions .vscode/launch.json → examples/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/tests/UnitTests/bin/Debug/netcoreapp2.0/Microsoft.ApplicationInsights.Kubernetes.UnitTests.dll",
"program": "${workspaceFolder}/BasicConsoleAppILogger/bin/Debug/netcoreapp2.2/BasicConsoleAppILogger.dll",
"args": [],
"cwd": "${workspaceFolder}/tests/UnitTests",
"cwd": "${workspaceFolder}/BasicConsoleAppILogger",
// For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window
"console": "internalConsole",
"stopAtEntry": false,
"internalConsoleOptions": "openOnSessionStart"
"stopAtEntry": false
},
{
"name": ".NET Core Attach",
Expand Down
70 changes: 70 additions & 0 deletions examples/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Example - BasicConsoleApp",
"command": "dotnet",
"type": "shell",
"group": "build",
"problemMatcher": "$msCompile",
"args": [
"build"
],
"options": {
"cwd": "${workspaceFolder}/BasicConsoleApp/src/"
}
},
{
"label": "Build Example - BasicUsage_clr21_RBAC",
"command": "dotnet",
"type": "shell",
"group": "build",
"problemMatcher": "$msCompile",
"args": [
"build"
],
"options": {
"cwd": "${workspaceFolder}/BasicUsage_clr21_RBAC/app/"
}
},
{
"label": "Build Example - MultipleIKeys",
"command": "dotnet",
"type": "shell",
"group": "build",
"problemMatcher": "$msCompile",
"args": [
"build"
],
"options": {
"cwd": "${workspaceFolder}/MultipleIKeys/"
}
},
{
"label": "Build Example - ZeroUserCodeLightup",
"command": "dotnet",
"type": "shell",
"group": "build",
"problemMatcher": "$msCompile",
"args": [
"build"
],
"options": {
"cwd": "${workspaceFolder}/ZeroUserCodeLightup/"
}
},
{
"label": "Build Example - WindowsContainer",
"command": "dotnet",
"type": "shell",
"group": "build",
"problemMatcher": "$msCompile",
"args": [
"build"
],
"options": {
"cwd": "${workspaceFolder}/WindowsContainer/"
}
},
]
}
Loading

0 comments on commit 36e31d3

Please sign in to comment.