It'a basic sample of CoreWCF service with .NET 7.The service and host initialization code looks like the following:
using System.Net;
var builder = WebApplication.CreateBuilder(args);
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
builder.Services.AddTransient<Service>();
builder.Services.AddServiceModelServices();
builder.Services.AddServiceModelMetadata();
builder.Services.AddSingleton<IServiceBehavior, UseRequestHeadersForMetadataAddressBehavior>();
var app = builder.Build();
app.UseHttpsRedirection();
app.MapGet("/", () => "Your service");
app.UseServiceModel(serviceBuilder =>
{
serviceBuilder.AddService<Service>();
serviceBuilder.AddServiceEndpoint<Service, IService>(new BasicHttpBinding(BasicHttpSecurityMode.Transport), "/SomeService.svc");
var serviceMetadataBehavior = app.Services.GetRequiredService<ServiceMetadataBehavior>();
serviceMetadataBehavior.HttpsGetEnabled = true;
}
app.Run();
localhost runs both http and https as expected perfectly. After deployment to AppService linux service plan Diagnostics Application log Reports: Unhandled exception. System.InvalidOperationException: Could not find a base address that matches scheme https for the endpoint with binding BasicHttpBinding. Registered base address schemes are [http].
I tried 'HTTPS Only' On/Off. with the same result. I tried to remove 'BasicHttpSecurityMode.Transport' and HTTPS Only 'Off'. The service responds via http as expected. What did i miss in https configuraton? It does not work under linux AppService with i target. I have solution for Windows plan but really need cheaper linux solution. I expect correct configuration in code or Azure AppService settings. Thank you!
SOLVED: For the App Service Linux environment single unsecure port 8080 port aviable by default. I changed binding to the http and force HTTPS on Azure Portal. The Azure infrastucture do the job for us. Now the service available for the clients via https bind.
The difference between Windows and Linux is the following: On App Service windows is are working on an IIS instance which has almost no difference as we do on local IIS installation. Thus we can bind http and https endpoints as we are usually do. A Load Balancer is 'smart' enought and cant route traffic to the correct endpoint. For Linux App Service a Load Balancer re-routes traffic https on a single http port. This is simple explanation. Correct me if I wrong.