Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add WebApplicationBuilder Extensions, improve .NET 6 compatibility #824

Merged
merged 22 commits into from
Feb 9, 2022

Conversation

TimHess
Copy link
Member

@TimHess TimHess commented Jan 24, 2022

@TimHess TimHess added Type/enhancement New feature or request ReleaseLine/3.x Identified as a feature/fix for the 3.x release line labels Jan 24, 2022
@TimHess TimHess added this to the 3.2.0 milestone Jan 24, 2022
@TimHess TimHess self-assigned this Jan 24, 2022
@TimHess TimHess requested a review from macsux January 24, 2022 21:19
@TimHess
Copy link
Member Author

TimHess commented Jan 24, 2022

/azp run Steeltoe.All

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@TimHess TimHess marked this pull request as ready for review January 28, 2022 21:37
@SteeltoeOSS SteeltoeOSS deleted a comment from azure-pipelines bot Jan 28, 2022
@SteeltoeOSS SteeltoeOSS deleted a comment from azure-pipelines bot Jan 28, 2022
@lvendramini
Copy link

Is .Net 6 supported? How do we add steeltoe to .net 6 program.cs?

@TimHess
Copy link
Member Author

TimHess commented Jan 31, 2022

Is .Net 6 supported? How do we add steeltoe to .net 6 program.cs?

Thanks for the question... This PR primarily adds extensions to use with the new WebApplicationBuilder, otherwise HostBuilder and WebHostBuilder can both still be used in .NET 6. Additionally, it is possible to use most of the other pre-existing Steeltoe setup methods with WebApplication by using them on the .Configuration or .Services properties of the builder, eg:

builder.Configuration.AddConfigServer();
builder.Logging.AddDynamicConsole();
builder.Services.AddAllActuators(builder.Configuration);
builder.Services.ActivateActuatorEndpoints();

I believe the only known issue with Steeltoe on .NET 6 (which is addressed in this PR) is that there is potential for recursion with the placeholder config provider.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lvendramini
Copy link

Is .Net 6 supported? How do we add steeltoe to .net 6 program.cs?

Thanks for the question... This PR primarily adds extensions to use with the new WebApplicationBuilder, otherwise HostBuilder and WebHostBuilder can both still be used in .NET 6. Additionally, it is possible to use most of the other pre-existing Steeltoe setup methods with WebApplication by using them on the .Configuration or .Services properties of the builder, eg:

builder.Configuration.AddConfigServer();
builder.Logging.AddDynamicConsole();
builder.Services.AddAllActuators(builder.Configuration);
builder.Services.ActivateActuatorEndpoints();

I believe the only known issue with Steeltoe on .NET 6 (which is addressed in this PR) is that there is potential for recursion with the placeholder config provider.

In our Program.cs we have
using Steeltoe.Extensions.Configuration.CloudFoundry;

var builder = WebApplication.CreateBuilder(args);

builder.Configuration.AddConfigServer();
builder.Logging.AddDynamicConsole();
builder.Services.AddAllActuators(builder.Configuration);
builder.Services.ActivateActuatorEndpoints();

But none of the bolded entries are know. What else do we need? Thanks!

@TimHess
Copy link
Member Author

TimHess commented Jan 31, 2022

Is .Net 6 supported? How do we add steeltoe to .net 6 program.cs?

Thanks for the question... This PR primarily adds extensions to use with the new WebApplicationBuilder, otherwise HostBuilder and WebHostBuilder can both still be used in .NET 6. Additionally, it is possible to use most of the other pre-existing Steeltoe setup methods with WebApplication by using them on the .Configuration or .Services properties of the builder, eg:

builder.Configuration.AddConfigServer();
builder.Logging.AddDynamicConsole();
builder.Services.AddAllActuators(builder.Configuration);
builder.Services.ActivateActuatorEndpoints();

I believe the only known issue with Steeltoe on .NET 6 (which is addressed in this PR) is that there is potential for recursion with the placeholder config provider.

In our Program.cs we have using Steeltoe.Extensions.Configuration.CloudFoundry;

var builder = WebApplication.CreateBuilder(args);

builder.Configuration.AddConfigServer(); builder.Logging.AddDynamicConsole(); builder.Services.AddAllActuators(builder.Configuration); builder.Services.ActivateActuatorEndpoints();

But none of the bolded entries are know. What else do we need? Thanks!

Assuming you've already got the nuget references (EndpointCore and ConfigServerBase or Core for these, other components would be different), adding these usings should work. Visual Studio should be able to find them via CTRL + . suggestions too

using Steeltoe.Extensions.Configuration.ConfigServer;
using Steeltoe.Extensions.Logging;
using Steeltoe.Management.Endpoint;

@lvendramini
Copy link

Is .Net 6 supported? How do we add steeltoe to .net 6 program.cs?

Thanks for the question... This PR primarily adds extensions to use with the new WebApplicationBuilder, otherwise HostBuilder and WebHostBuilder can both still be used in .NET 6. Additionally, it is possible to use most of the other pre-existing Steeltoe setup methods with WebApplication by using them on the .Configuration or .Services properties of the builder, eg:

builder.Configuration.AddConfigServer();
builder.Logging.AddDynamicConsole();
builder.Services.AddAllActuators(builder.Configuration);
builder.Services.ActivateActuatorEndpoints();

I believe the only known issue with Steeltoe on .NET 6 (which is addressed in this PR) is that there is potential for recursion with the placeholder config provider.

In our Program.cs we have using Steeltoe.Extensions.Configuration.CloudFoundry;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddConfigServer(); builder.Logging.AddDynamicConsole(); builder.Services.AddAllActuators(builder.Configuration); builder.Services.ActivateActuatorEndpoints();
But none of the bolded entries are know. What else do we need? Thanks!

Assuming you've already got the nuget references (EndpointCore and ConfigServerBase or Core for these, other components would be different), adding these usings should work. Visual Studio should be able to find them via CTRL + . suggestions too

using Steeltoe.Extensions.Configuration.ConfigServer;
using Steeltoe.Extensions.Logging;
using Steeltoe.Management.Endpoint;

Thanks that worked. Will that allow us to host our service in Pivotal Cloud Foundry? So far it does not work... Before .net 6 we had in the startup
public static IWebHost CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseCloudFoundryHosting() .UseDefaultServiceProvider(options => options.ValidateScopes = false) .ConfigureAppConfiguration((builderContext, configBuilder) => { configBuilder.AddCloudFoundry(); }).Build();

Does the following allow the service to be containerized in PCF? Or are we missing something?
builder.Configuration.AddConfigServer();
builder.Logging.AddDynamicConsole();
builder.Services.AddAllActuators(builder.Configuration);
builder.Services.ActivateActuatorEndpoints();

@TimHess
Copy link
Member Author

TimHess commented Feb 2, 2022

Is .Net 6 supported? How do we add steeltoe to .net 6 program.cs?

Thanks for the question... This PR primarily adds extensions to use with the new WebApplicationBuilder, otherwise HostBuilder and WebHostBuilder can both still be used in .NET 6. Additionally, it is possible to use most of the other pre-existing Steeltoe setup methods with WebApplication by using them on the .Configuration or .Services properties of the builder, eg:

builder.Configuration.AddConfigServer();
builder.Logging.AddDynamicConsole();
builder.Services.AddAllActuators(builder.Configuration);
builder.Services.ActivateActuatorEndpoints();

I believe the only known issue with Steeltoe on .NET 6 (which is addressed in this PR) is that there is potential for recursion with the placeholder config provider.

In our Program.cs we have using Steeltoe.Extensions.Configuration.CloudFoundry;
var builder = WebApplication.CreateBuilder(args);
builder.Configuration.AddConfigServer(); builder.Logging.AddDynamicConsole(); builder.Services.AddAllActuators(builder.Configuration); builder.Services.ActivateActuatorEndpoints();
But none of the bolded entries are know. What else do we need? Thanks!

Assuming you've already got the nuget references (EndpointCore and ConfigServerBase or Core for these, other components would be different), adding these usings should work. Visual Studio should be able to find them via CTRL + . suggestions too

using Steeltoe.Extensions.Configuration.ConfigServer;
using Steeltoe.Extensions.Logging;
using Steeltoe.Management.Endpoint;

Thanks that worked. Will that allow us to host our service in Pivotal Cloud Foundry? So far it does not work... Before .net 6 we had in the startup public static IWebHost CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup<Startup>() .UseCloudFoundryHosting() .UseDefaultServiceProvider(options => options.ValidateScopes = false) .ConfigureAppConfiguration((builderContext, configBuilder) => { configBuilder.AddCloudFoundry(); }).Build();

Does the following allow the service to be containerized in PCF? Or are we missing something? builder.Configuration.AddConfigServer(); builder.Logging.AddDynamicConsole(); builder.Services.AddAllActuators(builder.Configuration); builder.Services.ActivateActuatorEndpoints();

Could you please open a separate issue, listing all of the Steeltoe components you're wanting to use and ideally a complete sample?

…onExtensions.cs

Co-authored-by: Hananiel Sarella <hsarella@vmware.com>
@TimHess TimHess requested a review from hananiel February 4, 2022 19:51
hananiel
hananiel previously approved these changes Feb 4, 2022
@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@sonarcloud
Copy link

sonarcloud bot commented Feb 7, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

79.3% 79.3% Coverage
0.1% 0.1% Duplication

@TimHess TimHess requested a review from hananiel February 7, 2022 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ReleaseLine/3.x Identified as a feature/fix for the 3.x release line Type/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants