more samples running netcoreapp3.0

This commit is contained in:
Tim Hess 2019-10-31 14:58:40 -04:00
Родитель 66ab95607e
Коммит 61ceb98a4a
45 изменённых файлов: 468 добавлений и 286 удалений

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.1;</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461;</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
@ -14,11 +14,13 @@
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="$(AspNetCoreVersion)" />
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(AspNetCoreVersion)" />

Просмотреть файл

@ -10,6 +10,7 @@ namespace FortuneTellerService
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseCloudFoundryHosting(5000)

Просмотреть файл

@ -31,8 +31,11 @@ namespace FortuneTellerService
services.AddDiscoveryClient(Configuration);
// Add framework services.
#if NETCOREAPP3_0
services.AddControllers();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -40,7 +43,22 @@ namespace FortuneTellerService
{
app.UseStaticFiles();
app.UseMvc();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
app.UseDiscoveryClient();

Просмотреть файл

@ -1,29 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|netcoreapp2.1|AnyCPU'">
<DefineConstants>TRACE;DEBUG;NETCOREAPP2_1</DefineConstants>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="$(SteeltoeDiscoveryVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />
<PackageReference Include="Steeltoe.CircuitBreaker.HystrixCore" Version="$(SteeltoeCircuitBreakerVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(BUILD)' == ''">
<ItemGroup Condition="'$(BUILD)' == 'LOCAL'">
<PackageReference Include="Steeltoe.CircuitBreaker.Hystrix.MetricsStreamCore" Version="$(SteeltoeCircuitBreakerVersion)" />
<PackageReference Include="RabbitMQ.Client" Version="$(RabbitMQVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(BUILD)' == 'LOCAL'">
<ItemGroup Condition="'$(BUILD)' == ''">
<PackageReference Include="Steeltoe.CircuitBreaker.Hystrix.MetricsEventsCore" Version="$(SteeltoeCircuitBreakerVersion)" />
<PackageReference Include="System.Threading.ThreadPool" Version="4.3.0" />
</ItemGroup>

Просмотреть файл

@ -42,7 +42,11 @@ namespace Fortune_Teller_UI
services.AddHystrixCollapser<IFortuneServiceCollapser, FortuneServiceCollapser>("FortuneServiceCollapser", Configuration);
// Add framework services.
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
// Add Hystrix metrics stream to enable monitoring
services.AddHystrixMetricsStream(Configuration);
@ -66,7 +70,22 @@ namespace Fortune_Teller_UI
// Add Hystrix Metrics context to pipeline
app.UseHystrixRequestContext();
app.UseMvc();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
// Startup discovery client
app.UseDiscoveryClient();

101
CommonTasks.md Normal file
Просмотреть файл

@ -0,0 +1,101 @@
# Frequently Used Information
This page contains information on basic tasks that are used throughout the Steeltoe Samples. Use this page to quickly get your local development environment up and running.
## Spring Cloud Config Server
### Run SCCS with Docker
The Steeltoe team has built a docker image of a [basic Config server](https://github.com/SteeltoeOSS/Dockerfiles/tree/master/config-server) for an easy experience getting started
To start a config server backed by a folder on your local disk, start the docker image like this:
```bash
# Note: Ensure Docker is configured to share host drive/volume so the mount below will work correctly!
docker run --rm -ti -p 8888:8888 -v $PWD/steeltoe/config-repo:/config --name steeltoe-config steeltoeoss/configserver --spring.profiles.active=native
```
To start a config server backed by the spring cloud samples repo:
```bash
docker run --rm -ti -p 8888:8888 --name steeltoe-config steeltoeoss/configserver
```
### Run SCCS with Java
To run a Spring Cloud Config Server without Docker:
1. Install Java 8 JDK.
1. Install Maven 3.x.
1. Clone the Spring Cloud Config Server repository: `git clone https://github.com/spring-cloud/spring-cloud-config`
1. Change to the directory the server is located in: `cd spring-cloud-config/spring-cloud-config-server`
1. Start the server: `mvn spring-boot:run`
The default configuration of the Config Server uses [this github repo](https://github.com/spring-cloud-samples/config-repo) for its source of configuration data.
### Provision SCCS on Cloud Foundry
Use the [cf cli](https://github.com/cloudfoundry/cli) to create a Spring Cloud Config Server in a org/space, backed by a given git repo. Many of the Steeltoe samples use the `spring-cloud-samples` repo, but you may need to alter the parameter used.
1. `cf target -o myorg -s myspace`
1. Use the correct escaping for your shell:
1. bash: `cf create-service p-config-server standard myConfigServerInstanceName -c '{"git":{"uri": "https://github.com/spring-cloud-samples/config-repo"}}'`
1. CMD: `cf create-service p-config-server standard myConfigServerInstanceName -c "{\"git\":{\"uri\":\"https://github.com/spring-cloud-samples/config-repo\"}}"`
1. PowerShell: `cf create-service p-config-server standard myConfigServerInstanceName -c '{\"git\":{\"uri\":\"https://github.com/spring-cloud-samples/config-repo\"}}'`
1. Wait for service to be ready. (use `cf services` to check the status)
## Spring Cloud Eureka Server
### Run Eureka with Docker
The Steeltoe team has built a docker image of a [basic Eureka server](https://github.com/SteeltoeOSS/Dockerfiles/tree/master/eureka-server) for an easy experience getting started:
```bash
docker run --publish 8761:8761 steeltoeoss/eureka-server
```
### Run Eureka with Java
### Provision Eureka on Cloud Foundry
Use the [cf cli](https://github.com/cloudfoundry/cli) to create a Service Registry service in a org/space.
1. cf target -o myorg -s myspace
1. cf create-service p-service-registry standard myDiscoveryServiceInstanceName
1. Wait for service to be ready. (use `cf services` to check the status)
## Hystrix Dashboard
### Run Hystrix Dashboard with Docker
There are a few images available on Docker Hub that provide basic Hystrix Dashboard functionality. This example has been tested:
```bash
docker run --rm -ti -p 7979:7979 --name steeltoe-hystrix kennedyoliveira/hystrix-dashboard
```
Once this image is up and running, you should be able to browse to your [local dashboard](http://localhost:7979/hystrix-dashboard/) and provide the address of the Hystrix stream(s) you wish to monitor.
> NOTE: This image may be running on a separate network than your application. Remember to provide a stream address that is accessible from within the Docker network. This may require using the external IP address of your workstation or the name of the machine instead of 127.0.0.1 or localhost.
### Run Hystrix Dashboard with Java
To run a Hystrix Dashboard without Docker:
1. Install Java 8 JDK.
1. Install Maven 3.x.
1. Clone the Spring Cloud Samples Hystrix dashboard: `cd https://github.com/spring-cloud-samples/hystrix-dashboard`
1. Change to the hystrix dashboard directory: `cd hystix-dashboard`
1. Start the server `mvn spring-boot:run`
1. Open a browser window and connect to the dashboard: <http://localhost:7979>
1. In the first field, enter the endpoint that is exposing the hystrix metrics (eg: <http://localhost:5555/hystrix/hystrix.stream>)
1. Click the monitor button.
1. Interact with the application to trigger usage of the circuits. Observe the values changing in the Hystrix dashboard.
### Provision Hystrix Dashboard on Cloud Foundry
Use the [cf cli](https://github.com/cloudfoundry/cli) to create a Circuit Breaker service in a org/space.
1. cf target -o myorg -s development
1. cf create-service p-circuit-breaker-dashboard standard myHystrixServiceInstanceName
1. Wait for the service to become ready! (use `cf services` to check the status)

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,18 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461;</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />
</ItemGroup>
</Project>

Просмотреть файл

@ -30,7 +30,11 @@ namespace CloudFoundry
services.ConfigureCloudFoundryOptions(Configuration);
// Add framework services.
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -39,7 +43,6 @@ namespace CloudFoundry
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
@ -48,13 +51,22 @@ namespace CloudFoundry
app.UseStaticFiles();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
}
}
}

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,15 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461;</TargetFrameworks>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2" PrivateAssets="All" />
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="$(SteeltoeConfigVersion)" />
</ItemGroup>
</Project>
</Project>

Просмотреть файл

@ -1,12 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -24,15 +17,12 @@ namespace Placeholder
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.Configure<SampleOptions>(Configuration);
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -45,20 +35,26 @@ namespace Placeholder
else
{
app.UseExceptionHandler("/Home/Error");
// 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.UseStaticFiles();
app.UseCookiePolicy();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
}
}
}

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,14 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461;</TargetFrameworks>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Steeltoe.Extensions.Configuration.RandomValueBase" Version="$(SteeltoeConfigVersion)" />
</ItemGroup>

Просмотреть файл

@ -1,12 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpsPolicy;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
@ -24,15 +17,11 @@ namespace RandomValue
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -45,20 +34,26 @@ namespace RandomValue
else
{
app.UseExceptionHandler("/Home/Error");
// 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.UseStaticFiles();
app.UseCookiePolicy();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
}
}
}

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -4,74 +4,38 @@ ASP.NET Core sample app illustrating how to use [Config Server for Pivotal Cloud
## Pre-requisites
1. Installed Pivotal CloudFoundry 1.10+
1. Installed Spring Cloud Services 1.1+
1. .Net Core SDK 2.1.300
1. Installed Pivotal CloudFoundry
1. Installed Spring Cloud Services
1. .NET Core SDK 2.1.300+
## Setup Config Server
You must first create an instance of the Config Server service in a org/space.
1. cf target -o myorg -s development
1. cd src/AspDotNetCore/SimpleCloudFoundry
1. cf create-service p-config-server standard myConfigServer -c ./config-server.json
1. Wait for service to become ready (i.e. cf services )
Refer to [common tasks](/CommonTasks.md#Spring-Cloud-Config-Server) for detailed instructions on creating a Spring Cloud Config Server instance in Cloud Foundry. This sample expects the config server to be backed by the `spring-cloud-samples` repo.
## Publish App & Push
1. cf target -o myorg -s development
1. cd src/AspDotNetCore/SimpleCloudFoundry
1. dotnet restore --configfile nuget.config
1. Publish app to a directory selecting the framework and runtime you want to run on. (e.g. `dotnet publish -f netcoreapp2.1 -r ubuntu.16.04-x64`)
1. Push the app using the appropriate manifest. (e.g. `cf push -f manifest.yml -p bin/Debug/netcoreapp2.1/ubuntu.16.04-x64/publish` or `cf push -f manifest-windows.yml -p bin/Debug/netcoreapp2.1/win10-x64/publish`)
> Note: If you are using self-signed certificates it is possible that you might run into SSL certificate validation issues when pushing this app. The simplest way to fix this:
1. Disable certificate validation for the Spring Cloud Config Client. You can do this by editing `appsettings.json` and add `spring:cloud:config:validateCertificates=false`.
1. `cf target -o myorg -s development`
1. `cd src/AspDotNetCore/SimpleCloudFoundry`
1. `dotnet restore`
1. Publish app to a directory selecting the framework and runtime you want to run on:
- `dotnet publish -f netcoreapp2.1 -r ubuntu.18.04-x64`
1. Push the app using the appropriate manifest:
- `cf push -f manifest.yml -p bin/Debug/netcoreapp2.1/ubuntu.18.04-x64/publish`
- `cf push -f manifest-windows.yml -p bin/Debug/netcoreapp2.1/win10-x64/publish`
## What to expect
The cf push will create an app in the space by the name `foo` and will bind the `myConfigServer` service instance to the app. You can hit the app @ `https://foo.x.y.z/`.
The `cf push` will create an app in the space by the name `foo` and will bind the `myConfigServer` service instance to the app. You can hit the app @ `https://foo.x.y.z/`.
The Config Servers Git repository has been set to: `https://github.com/spring-cloud-samples/config-repo`
The Config Server should be backed by this Git repository: `https://github.com/spring-cloud-samples/config-repo`
Use the menus at the top of the app to see various output:
* `CloudFoundry Settings` - should show `VCAP_APPLICATION` and `VCAP_SERVICES` configuration data.
* `Config Server Settings` - should show the settings used by the client when communicating to the config server. These have been picked up from the service binding.
* `Config Server Data` - this is the configuration data returned from the Config Servers Git repository. It will be some of the data from `foo.properties`, `foo-development.properties` and `application.yml` found in the Git repository.
* `Reload` - will cause a reload of the configuration data from the server.
## Observe Logs
To see the logs as you startup and use the app: `cf logs foo`
On a Linux cell, you should see something like this during startup:
```text
2016-06-01T09:14:14.38-0600 [CELL/0] OUT Creating container
2016-06-01T09:14:15.93-0600 [CELL/0] OUT Successfully created container
2016-06-01T09:14:17.14-0600 [CELL/0] OUT Starting health monitoring of container
2016-06-01T09:14:18.01-0600 [APP/0] OUT info: Steeltoe.Extensions.Configuration.ConfigServer.ConfigServerConfigurationProvider[0]
2016-06-01T09:14:18.01-0600 [APP/0] OUT Fetching config from server at: https://config-92e894b5-17e2-4b94-941e-a544c6488de7.apps.testcloud.com
2016-06-01T09:14:19.59-0600 [APP/0] OUT info: Steeltoe.Extensions.Configuration.ConfigServer.ConfigServerConfigurationProvider[0]
2016-06-01T09:14:19.59-0600 [APP/0] OUT Located environment: foo, development, master,
2016-06-01T09:14:19.59-0600 [APP/0] OUT info: Steeltoe.Extensions.Configuration.ConfigServer.ConfigServerConfigurationProvider[0]
2016-06-01T09:14:19.59-0600 [APP/0] OUT Fetching config from server at: https://config-92e894b5-17e2-4b94-941e-a544c6488de7.apps.testcloud.com
2016-06-01T09:14:20.46-0600 [APP/0] OUT info: Steeltoe.Extensions.Configuration.ConfigServer.ConfigServerConfigurationProvider[0]
2016-06-01T09:14:20.46-0600 [APP/0] OUT Located environment: foo, development, master,
2016-06-01T09:14:20.93-0600 [APP/0] OUT dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[3]
2016-06-01T09:14:20.93-0600 [APP/0] OUT Hosting starting
2016-06-01T09:14:21.04-0600 [APP/0] OUT dbug: Microsoft.AspNetCore.Hosting.Internal.WebHost[4]
2016-06-01T09:14:21.04-0600 [APP/0] OUT Hosting started
2016-06-01T09:14:21.04-0600 [APP/0] OUT Hosting environment: development
2016-06-01T09:14:21.04-0600 [APP/0] OUT Content root path: /home/vcap/app
2016-06-01T09:14:21.04-0600 [APP/0] OUT Now listening on: http://*:8080
2016-06-01T09:14:21.04-0600 [APP/0] OUT Application started. Press Ctrl+C to shut down.
2016-06-01T09:14:21.41-0600 [CELL/0] OUT Container became healthy
```
- `CloudFoundry Settings` - should show `VCAP_APPLICATION` and `VCAP_SERVICES` configuration data.
- `Config Server Settings` - should show the settings used by the client when communicating to the config server. These have been picked up from the service binding.
- `Config Server Data` - this is the configuration data returned from the Config Servers Git repository. It will be some of the data from `foo.properties`, `foo-development.properties` and `application.yml` found in the Git repository.
- `Reload` - will cause a reload of the configuration data from the server.
---
### See the Official [Steeltoe Configuration Documentation](https://steeltoe.io/docs/steeltoe-configuration) for a more in-depth walkthrough of the samples and more detailed information
### See the [App Configuration](https://steeltoe.io/app-configuration) area of the Steeltoe site for a more in-depth walkthrough of the samples and more detailed information

Просмотреть файл

@ -1,15 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461;</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.ConfigServerCore" Version="$(SteeltoeConfigVersion)" />
</ItemGroup>

Просмотреть файл

@ -31,11 +31,14 @@ namespace SimpleCloudFoundry
// Optional: Adds IConfiguration and IConfigurationRoot to service container
services.AddConfiguration(Configuration);
// Add framework services.
services.AddMvc();
// Adds the configuration data POCO configured with data returned from the Spring Cloud Config Server
services.Configure<ConfigServerData>(Configuration);
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -52,12 +55,22 @@ namespace SimpleCloudFoundry
app.UseStaticFiles();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
}
}
}

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
@ -14,16 +14,18 @@
</None>
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel.Https" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="$(SteeltoeDiscoveryVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="$(SteeltoeConfigVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.PlaceholderCore" Version="$(SteeltoeConfigVersion)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -31,8 +31,11 @@ namespace FortuneTellerService
services.AddDiscoveryClient(Configuration);
// Add framework services.
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -41,7 +44,22 @@ namespace FortuneTellerService
app.UseStaticFiles();
app.UseMvc();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
app.UseDiscoveryClient();

Просмотреть файл

@ -1,13 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />

Просмотреть файл

@ -34,7 +34,11 @@ namespace Fortune_Teller_UI
.AddTypedClient<IFortuneService, FortuneService>();
// Add framework services.
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -51,7 +55,22 @@ namespace Fortune_Teller_UI
app.UseStaticFiles();
app.UseMvc();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
// Startup the background thread
app.UseDiscoveryClient();

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,23 +1,26 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.2</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461;</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<!-- GitInfo provides $(Git*) properties used below -->
<PackageReference Include="GitInfo" Version="2.0.15">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.2.0" />
<PackageReference Include="Steeltoe.CloudFoundry.ConnectorCore" Version="$(SteeltoeConnectorVersion)" />
<PackageReference Include="Steeltoe.CloudFoundry.Connector.EFCore" Version="$(SteeltoeConnectorVersion)" />
<PackageReference Include="Steeltoe.Extensions.Logging.SerilogDynamicLogger" Version="2.3.0-rc2" />
<PackageReference Include="Steeltoe.Extensions.Logging.SerilogDynamicLogger" Version="$(SteeltoeLoggingVersion)" />
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="$(SteeltoeManagementVersion)" />
<PackageReference Include="Steeltoe.Management.ExporterCore" Version="$(SteeltoeManagementVersion)" />
<PackageReference Include="Steeltoe.Management.TaskCore" Version="$(SteeltoeManagementVersion)" />

Просмотреть файл

@ -49,7 +49,11 @@ namespace CloudFoundry
// services.AddMetricsForwarderExporter(Configuration);
// Add framework services.
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -73,14 +77,22 @@ namespace CloudFoundry
// Add metrics collection to the app
// Remove comment below to enable
// app.UseMetricsActuator();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
// Start up the metrics forwarder service added above
// Remove comment below to enable
// app.UseMetricsExporter();

Просмотреть файл

@ -1,10 +1,15 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2002
# Visual Studio Version 16
VisualStudioVersion = 16.0.29324.140
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CloudFoundry", "CloudFoundry\CloudFoundry.csproj", "{B4B8FE2B-CB42-4C1E-851C-FCDF81ECA00F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7AE4863D-B020-45B3-B8F7-DCFD8B964479}"
ProjectSection(SolutionItems) = preProject
..\..\..\config\versions.props = ..\..\..\config\versions.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

Просмотреть файл

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="SteeltoeMaster" value="https://www.myget.org/F/steeltoemaster/api/v3/index.json" />
<add key="SteeltoeDev" value="https://www.myget.org/F/steeltoedev/api/v3/index.json" />
<add key="NuGet" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

Просмотреть файл

@ -1,23 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Content Remove="appsettings.Development.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<None Include="appsettings.Development.json" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />
<PackageReference Include="Steeltoe.Security.Authentication.CloudFoundryCore" Version="$(SteeltoeSecurityVersion)" />

Просмотреть файл

@ -1,11 +1,5 @@
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.AspNetCore.Builder;
using Microsoft.AspNetCore;
using Steeltoe.Extensions.Configuration.CloudFoundry;
namespace CloudFoundryJwtAuthentication
@ -16,14 +10,12 @@ namespace CloudFoundryJwtAuthentication
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseCloudFoundryHosting()
.UseCloudFoundryHosting(63807)
.AddCloudFoundry()
.UseStartup<Startup>()
.Build();
}
}

Просмотреть файл

@ -32,18 +32,36 @@ namespace CloudFoundryJwtAuthentication
options.AddPolicy("testgroup1", policy => policy.RequireClaim("scope", "testgroup1"));
});
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
app.UseAuthentication();
app.UseMvc();
#if NETCOREAPP3_0
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
}
}
}

Просмотреть файл

@ -1,19 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Content Remove="appsettings.Development.json" />
</ItemGroup>
<ItemGroup>
<None Include="appsettings.Development.json" />
</ItemGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />
<PackageReference Include="Steeltoe.Security.Authentication.CloudFoundryCore" Version="$(SteeltoeSecurityVersion)" />

Просмотреть файл

@ -1,23 +1,21 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Steeltoe.Extensions.Configuration.CloudFoundry;
namespace CloudFoundrySingleSignon
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseCloudFoundryHosting()
.AddCloudFoundry()
.UseStartup<Startup>()
.Build();
}
}

Просмотреть файл

@ -56,11 +56,15 @@ namespace CloudFoundrySingleSignon
// services.AddDistributedRedisCache(Configuration);
// services.AddSession();
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
@ -80,12 +84,23 @@ namespace CloudFoundrySingleSignon
app.UseAuthentication();
#if NETCOREAPP3_0
app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
}
}
}

Просмотреть файл

@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2026
# Visual Studio Version 16
VisualStudioVersion = 16.0.29324.140
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CloudFoundryJwtAuthentication", "CloudFoundryJwtAuthentication\CloudFoundryJwtAuthentication.csproj", "{7C45D011-F900-42B9-A975-DF5239A32450}"
EndProject
@ -18,6 +18,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{4E1E
..\..\scripts\sso-setup.sh = ..\..\scripts\sso-setup.sh
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E89A1BB6-1F81-4C2A-9F4A-936EE33ACD8B}"
ProjectSection(SolutionItems) = preProject
..\..\..\config\versions.props = ..\..\..\config\versions.props
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

Просмотреть файл

@ -1,13 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
</ItemGroup>
<ItemGroup>
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />
<PackageReference Include="Steeltoe.Management.CloudFoundryCore" Version="$(SteeltoeManagementVersion)" />
<PackageReference Include="Steeltoe.Security.DataProtection.CredHubCore" Version="$(SteeltoeSecurityVersion)" />

Просмотреть файл

@ -1,5 +1,6 @@
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Steeltoe.Extensions.Configuration.CloudFoundry;
using Steeltoe.Extensions.Logging;
@ -61,10 +62,22 @@ namespace CredHubDemo
loggingBuilder.AddConfiguration(builderContext.Configuration.GetSection("Logging"));
loggingBuilder.AddDynamicConsole();
})
.UseCredHubInterpolation(new LoggerFactory().AddConsole())
.UseCredHubInterpolation(GetLoggerFactory())
.Build();
host.Run();
}
public static ILoggerFactory GetLoggerFactory()
{
IServiceCollection serviceCollection = new ServiceCollection();
serviceCollection.AddLogging(builder => builder.SetMinimumLevel(LogLevel.Trace));
serviceCollection.AddLogging(builder => builder.AddConsole((opts) =>
{
opts.DisableColors = true;
}));
serviceCollection.AddLogging(builder => builder.AddDebug());
return serviceCollection.BuildServiceProvider().GetService<ILoggerFactory>();
}
}
}

Просмотреть файл

@ -24,10 +24,14 @@ namespace CredHubDemo
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddCloudFoundryActuators(Configuration);
services.Configure<CredHubOptions>(Configuration.GetSection("CredHubClient"));
services.AddCredHubClient(Configuration, logFactory);
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -43,14 +47,24 @@ namespace CredHubDemo
}
app.UseStaticFiles();
app.UseCloudFoundryActuators();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseCloudFoundryActuators();
#endif
}
}
}

Просмотреть файл

@ -1,23 +1,21 @@

using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore;
using Steeltoe.Extensions.Configuration.CloudFoundry;
namespace RedisDataProtectionKeyStore
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseCloudFoundryHosting()
.AddCloudFoundry()
.UseStartup<Startup>()
.Build();
}
}

Просмотреть файл

@ -1,16 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\..\..\..\config\versions.props" />
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<TargetFrameworks>netcoreapp3.0;netcoreapp2.1;net461</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp3.0'">
<PackageReference Include="Microsoft.AspNetCore" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Caching.Redis" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.Session" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="2.2.0" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<PackageReference Include="Microsoft.Extensions.Caching.StackExchangeRedis" Version="$(AspNetCoreVersion)" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="$(AspNetCoreVersion)" />
<PackageReference Include="Steeltoe.CloudFoundry.ConnectorCore" Version="$(SteeltoeConnectorVersion)" />
<PackageReference Include="Steeltoe.Security.DataProtection.RedisCore" Version="$(SteeltoeSecurityVersion)" />
<PackageReference Include="Steeltoe.Extensions.Configuration.CloudFoundryCore" Version="$(SteeltoeConfigVersion)" />

Просмотреть файл

@ -36,11 +36,15 @@ namespace RedisDataProtectionKeyStore
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
// Add framework services.
#if NETCOREAPP3_0
services.AddControllersWithViews();
#else
services.AddMvc();
#endif
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseSession();
@ -55,12 +59,22 @@ namespace RedisDataProtectionKeyStore
app.UseStaticFiles();
#if NETCOREAPP3_0
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
});
#else
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
#endif
}
}
}