UseLibuv option gone after changing Microsoft.aspnetcore.all to Microsoft.NETCore.App in .net core 2.1.6 - asp.net-core-2.0

I am using asp.net core 2.1.6
I have just changed my Microsoft.aspnetcore.all to Microsoft.NETCore.App as publishing the web api project is making too much size.
In my code i were using use UseLibuv(o => o.ThreadCount = 1000) to set minmum thread count
public static IWebHostBuilder BuildWebHost(string[] args) => WebHost.CreateDefaultBuilder(args)
.UseStartup<StartupShutdownHandler>()
//.UseLibuv(o => o.ThreadCount = 1000)
;
Now this option is not coming. How can i set min threads now like old one
It is bit related to
Is Kestrel using a single thread for processing requests like Node.js?

For UseLibuv, it's under Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv package, you could try to install Microsoft.AspNetCore.Server.Kestrel.Transport.Libuv from nuget.

Related

Async Web Api does not release the thread to another request

The code below does not release IIS threads for new requests, why?
public async Task<string> Get()
{
await Task.Delay(15000);
}
I'm using Windows 10, .Net Framework 4.7, no changes to the Default AppPool (single IIS worker process) on an i7:
Using performance counters, I can see that 6 out of my 16 parallel CURL requests get queued, while my CPU is free (20% usage).

The binding type 'serviceBusTrigger' is not registered error in azure functions c# with core tools 2

I open a fresh new azure functions project, my packages are:
Microsoft.Azure.WebJobs 3.0.0-beta4
Microsoft.Azure.WebJobs.ServiceBus 3.0.0-beta4
Microsoft.NET.Sdk.Functions 1.0.7
NETStandardLibrary 2.0.1
I use servicebustrigger and my function code is basic:
public static class Function1
{
[FunctionName("OrderPusherFunction")]
public static Task Run([ServiceBusTrigger("orders","orderpusher", Connection ="ServiceBus")]
string myQueueItem, TraceWriter log)
{
log.Info($"C# Queue trigger function processed: {myQueueItem}");
return Task.CompletedTask;
}
}
I also have:
Azure Functions Core Tools (2.0.1-beta.22) and Function Runtime Version: 2.0.11415.0
When i run, i get "The binding type 'serviceBusTrigger' is not registered" error, and the function does not get triggered. Anyone has an idea? This looks to me as a basic setup..
Basically, in v2 ServiceBus trigger was moved out of the default installation into Extensibility model. You need to register Service Bus binding as an extension as per Binding Extensions Management.
Unfortunately, this is all work-in-progress, as there is a number of issues for Service Bus binding:
Migrate ServiceBus Extension to .NET Core - "Done", but see the comments for which problems still exist
Build failure after installing ExtensionsMetadatGenerator into empty v2 app prevents VS tooling from registering the extension properly
Extensions.json is not updated when "extension install" CLI command executed for service bus extension for CLI issue
My advice would be to stick to v1 for now.

Unable to configure Live Stream in Application Insights for ASP Core application

I have configured Application Insights in my application and I am receiving telemetry. However, when I click the Live Metrics Stream page I am getting: "Not available: your app is offline or using an older SDK".
How do I get Live Stream to appear?
It is possible to activate it in code, even though it's not yet supported officially. In Startup.cs add following code:
TelemetryConfiguration configuration = TelemetryConfiguration.Active;
configuration.InstrumentationKey = "e73ee2c9-776t-er45-4244-b2139c6dc724";
QuickPulseTelemetryProcessor processor = null;
configuration.TelemetryProcessorChainBuilder
.Use((next) =>
{
processor = new QuickPulseTelemetryProcessor(next);
return processor;
})
.Build();
var QuickPulse = new QuickPulseTelemetryModule();
QuickPulse.Initialize(configuration);
QuickPulse.RegisterTelemetryProcessor(processor);
Add Nuget packages:
Microsoft.ApplicationInsights.PerfCounterCollector
Microsoft.ApplicationInsights.DependencyCollector
Based on the following post.
Live Metrics isn't yet supported from the ASP.Net Core packages.
https://github.com/Microsoft/ApplicationInsights-aspnetcore/issues/216
though given this PR it looks like it might be close?
https://github.com/Microsoft/ApplicationInsights-aspnetcore/pull/518

Method not found: 'IntPtr System.Fabric.SecurityCredentialExtension.ToNative

I am trying to consume Stateful Service Fabric in my ASP.Net Core by following the example in the following demo:
https://learn.microsoft.com/en-us/azure/service-fabric/service-fabric-add-a-web-frontend
Unfortunately, when I run the code, I am ending up with the following error:
Method not found: 'IntPtr
System.Fabric.SecurityCredentialExtension.ToNative(System.Fabric.SecurityCredentials,
System.Fabric.Interop.PinCollection)'.
[HttpGet]
public async Task<IEnumerable<string>> Get()
{
ICounter counter =
ServiceProxy.Create<ICounter>(new Uri("fabric:/MyApplication/MyStatefulService"), new ServicePartitionKey(0));
long count = await counter.GetCountAsync(); //this where it is erroring
return new string[] { count.ToString() };
}
I wonder if there is any solution to this issue. I am running the service cluster on my local machine.
thanks.
I just ran into the same problem. The fix was to upgrade all the nuget packages for the ASP.NET Core project to the latest versions. Then it just worked. For some reason when you create a new ASP.NET Core service it does not have the latest versions by default. You need to update them.

Why does this NServiceBus message handler throw System.MethodAccessException on call to Task.CompletedTask?

After looking through the documentation and trying to find other examples of developers getting this error, I am a bit stuck. We are working with NServiceBus 6 and are occasionally getting a System.MethodAccessException in our message handlers on the call to return Task.CompletedTask. It seems to only occur when the handler is deployed in an Azure Worker Role (as opposed to running in the emulator). We are using the Azure Service Bus transport.
public Task Handle(UpdatePatientAccommodationCode message, IMessageHandlerContext context)
{
Console.WriteLine($"Handling [{message.GetType()}]");
var patientVisit = LoadByExternalPatientId(message.ClientId, message.ExternalPatientId);
var mappedEvent = patientVisit.HandleCommand(message);
if (patientVisit.IsEventAdded)
PatientVisitEventStore.Save(patientVisit);
return mappedEvent == null ? Task.CompletedTask : context.Publish(mappedEvent);
}
The actual exception looks like this:
System.MethodAccessException: Attempt by method 'XXX.Handlers.PatientVisitHandler.Handle(XXX.UpdatePatientAccommodationCode, NServiceBus.IMessageHandlerContext)' to access method 'System.Threading.Tasks.Task.get_CompletedTask()' failed.
at XXX.Handlers.PatientVisitHandler.Handle(UpdatePatientAccomm odationCode message, IMessageHandlerContext context) in PatientVisitHandler.cs: line 314
at NServiceBus.InvokeHandlerTerminator.Terminate(IInvokeHandlerContext context) in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\Incoming\Invok eHandlerTerminator.cs: line 24
at NServiceBus.LoadHandlersConnector.<Invoke>d__1.MoveNext() in C:\BuildAgent\work\3206e2123f54fce4\src\NServiceBus.Core\Pipeline\Incoming\LoadH andlersConnector.cs: line 40
I suspect your code locally has .NET framework 4.6.x which supports Task.CompletedTask. When you deploy to CS and use OS family less than version 5 won't have support for 4.6.x You either will need to use a startup task to install 4.6.x or migrate to OS Family 5 (Server 2016).
That is strange. Judging by the reference sources of Task.CompletedTask I can't come up with a scenario where this could happen. The task that is statically cached is initialized with RAN_TO_COMPLETION and DO_NOT_DISPOSE. Based on that I would suggest you determine whether you are using the .NET Framework version 4.6 or higher. If you do and you still see the exception try to replace Task.CompletedTask with
static class TaskEx
{
public static readonly Task CompletedTask = Task.FromResult(0);
}

Resources