Roundup #40: Workers, NET 4.8, Require 4.7.2, AWS SDK, Developer Survey

Been out several weeks from posting a roundup, but it’s back!

Here are the things that caught my eye this week in .NET.  I’d love to hear what you found most interesting this week.  Let me know in the comments or on Twitter.

.NET Core Workers as Windows Services

In .NET Core 3.0 we are introducing a new type of application template called Worker Service. This template is intended to give you a starting point for writing long running services in .NET Core. In this walkthrough we will create a worker and run it as a Windows Service.

I think this is pretty great and seems really logical. There are so many use cases and the most obvious to me is long running process for something like processing jobs off a queue.

Link: https://devblogs.microsoft.com/aspnet/net-core-workers-as-windows-services/

Announcing the .NET Framework 4.8

We are thrilled to announce the release of the .NET Framework 4.8 today. It’s included in the Windows 10 May 2019 Update. .NET Framework 4.8 is also available on Windows 7+ and Windows Server 2008 R2+.

I realize there have been many posts about .NET Framework not being “dead” because it’s built into Windows, but “dead” to me clearly means something different. There is a lot of effort being put into being able to migrate to .NET Core. The future is .NET Core. Is the .NET Framework going anywhere? No, but don’t expect much else beyond 4.8 in my opinion.

Link: https://devblogs.microsoft.com/dotnet/announcing-the-net-framework-4-8/

Require .NET Framework 4.7.2

This shows how you can author a NuGet package that will provide an error message if the consumer is on .NET Framework 4.6.1 – 4.7.1.

Unfortunately, this is needed because NuGet will allow you to install a package on 4.6.1+ when netstandard2 is really only truly supported on 4.7.2. This is an unfortunate mistake and guidance early on that caused a pile of confusion.

Link: https://github.com/terrajobst/require-net472/

AWS SDK for .NET now targets .NET Standard 2.0

As .NET Core and .NET Standard have matured since their initial release, Microsoft has been encouraging the community to set the baseline for .NET Standard libraries to be 2.0. .NET Standard 2.0 improves how dependencies are resolved. Taking a dependency on library that does not target .NET Standard 2.0 potentially caused confusing build errors or required unnecessary .NET assemblies in project deployment packages.

Link: https://aws.amazon.com/de/blogs/developer/aws-sdk-for-net-now-targets-net-standard-2-0/

Stack Overflow Developer Survey Results 2019

Stack Overflow’s annual Developer Survey is the largest and most comprehensive survey of people who code around the world. Each year, we field a survey covering everything from developers’ favorite technologies to their job preferences. This year marks the ninth year we’ve published our annual Developer Survey results, and nearly 90,000 developers took the 20-minute survey earlier this year.

Link: https://insights.stackoverflow.com/survey/2019

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

Configuring AWS SDK in ASP.NET Core

Configuring AWS SDK in ASP.NET Core

If you’re using any AWS Services, you’re likely going to be using the AWS SDK via NuGet packages. You don’t need to configure anything to start using the SDK, but there are a few things that can make your life a lot easier. Follow along for a how-to on configuring AWS SDK in ASP.NET Core.

AWS CLI Named Profiles

The AWS Command Line Interface (CLI) is the first thing you’re going to want to have. Beyond controlling AWS services it allows you to configure credential profiles.

Once you have the CLI installed, to configure the default profile simply run and follow the prompt to enter your access key, secret and region.

> aws configure

For the rest of this example, I’m going to be using the default profile that I’ve configured that contains my access key and secret.

AppSettings

The AWS SDK will look for an AWS key in your appsettings.json file. It will use this section for configuration. In this section, you can define which Profile to use as well as many other options including as Region.

Environment Variables

You can also use Environment Variables to define these same settings. Be sure to use colon as hierarchy.

Startup.cs

The AWSSDK.Extensions.NETCore.Setup NuGet package that adds extension methods to IConfiguration and IServiceCollection that makes it simple to retrieve AWS configuration and types.

Now if you inject the IAmazonS3 from a Controller or even if you resolve it from context.RequestServices.GetService<IAmazonS3>() you will get out an instance that is auto-configured with the access key and secret from your Default profile as well as the Region defined in your appsetting or Environment Variable.

AWS SDK in ASP.NET Core

That’s the quick start way of being able to use the AWS SDK without having to specify any of your credentials in your source as well as being able to use dependency injection to have the AWS SDK types resolve pre-configured.

If you have any questions or comments, please let me know on twitter as I will focus my posts on those questions and comments.

Related Links:

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.

Roundup #39: Performance Tricks, Orleans Dashboard, ASP.NET Tips, Six Little Lines of Fail

Here are the things that caught my eye this week in .NET.  I’d love to hear what you found most interesting this week.  Let me know in the comments or on Twitter.

Some performance tricks with .NET strings

I’ve created a pull request on the ASP.NET Core repository. At the beginning, the changes were just about changing the unsafe code (char*) for stackalloc to a safe version with Span<T>. So, it was a very small change. During the review, Oleksandr KolomiietsGünther Foidl, and David Fowler have suggested a few additional changes to improve the performance. Thank you very much for taking the time to review the PR! The comments were very interesting, so I’ve decided to explain them in a post.

Link: https://www.meziantou.net/2019/03/04/some-performance-tricks-with-net-strings

Microsoft Orleans   Dashboard

Quick update to a post I did a while back regarding Orleans Dashboard — additional reporting metrics for your cluster!

As a refresher, Orleans is a virtual actor model framework — a framework that can be used to build new, distributed “primitives”. These primitives’ work can be farmed out to a cluster of nodes as a means of getting “work” done faster than what would be possible if working constrained to a single piece of hardware.

Link: https://hackernoon.com/microsoft-orleans-dashboard-update-cpu-memory-stats-706daed82cf8

Tips and tricks for ASP.NET Core applications

This is a small collection of some tips and tricks which I keep repeating myself in every ASP.NET Core application. There’s nothing ground breaking in this list, but some general advice and minor tricks which I have picked up over the course of several real world applications.

Link: https://dusted.codes/advanced-tips-and-tricks-for-aspnet-core-applications

Six Little Lines of Fail – Jimmy Bogard

It seemed like an easy feature to implement, a checkout page to place an order. But this payment gateway has a simple API, so we added that. And this email service provider makes it possible to send an email with one line of code! Finally we can notify downstream systems via a message queue. The code looks simple, 6 little lines of distributed systems code.

But those lines hid a dark secret that we only found after launching. Customers complained they didn’t get their email. The back end system wasn’t getting updated from our messages. And by far the worst of all, customers complained they saw an error page but still got charged!

Clearly it wasn’t as easy as calling a few APIs and shipping, we actually need to worry about those other systems. In this session, we’ll look at taking our 6 lines of distributed systems fail, examining the inevitable failures that arise, and possible mitigating scenarios. We’ll also look at the coupling our code contains, and the ways we can address it. Finally, we’ll refactor towards a truly resilient checkout process that embraces, instead of ignoring, the fallacies of distributed computing.

Link: https://www.youtube.com/watch?v=LGG3IIHUG_w

Enjoy this post? Subscribe!

Subscribe to our weekly Newsletter and stay tuned.