.NET Blogs


Deploying .NET apps to TAP on AWS

Layla Porter & Cal Kadourah October 7, 2022

In this video, join Layla Porter and Cal Kadourah, an Advisory Solution Engineer at VMware, as they go through the new AWS quickstart for deploying TAP workloads on AWS.

Full instructions can be found on this GitHub repository and further details about TAP on AWS can be found on this page.

If you have any questions or ideas please feel free to reach out to Layla on one of the following platforms.

Email: laylap@vmware.com
Twitter: @LaylaCodesIt
GitHub: layla-p
Twitch: LaylaCodesIt
YouTube: LaylaCodesIt

Read more

Building a Topic Exchange with RabbitMQ and .NET 6

Layla Porter August 3, 2022

What Is RabbitMQ?

alt_text

At a high level, RabbitMQ is an open source message broker. A message broker accepts messages from a producer (the message sender) and holds it in a queue so that a consumer (the message receiver) can retrieve it. This allows for multiple producers and consumers to share the same queue without having to directly pass messages between each other. What RabbitMQ excels at is doing this at scale whilst staying lightweight and easy to deploy.

To get started with a basic RabbitMQ implementation, checkout this guide.

Why use a message broker?

The first question you may have is “why do I want to add in additional complexity?”

If you were not using a message broker, you would most likely be using an HTTP or socket-based form of communication. These methods can be difficult to scale and are not always robust. HTTP communication can also tightly couple two systems together - increasing inter-dependency, which is undesirable.

The addition of a message broker improves the fault tolerance and resiliency of the systems in which they are employed.

They are easy to scale as their publish/subscribe pattern means the addition of many more services can be easily supported - without having to modify existing systems.

What is a Topic Exchange?

RabbitMQ has four types of exchanges (or message routers) available to route the message in different ways. You will focus …

Read more

Top-Level Statements in .NET 6

Layla Porter May 25, 2022

When the community first saw .NET 6 there was a little bit of uproar, myself included, about how the way we structured web applications had changed.

In earlier versions of .NET Core, we had grown familiar with the symbiotic relationship between the Startup and Program classes. We even engineered ways to add a Startup class to Azure Functions and console applications.

Cover image of a stack of four rocks on a wooden table

The Startup class was the place to register all of the application’s dependencies, set up the middleware, and of course, configure the configuration.

Yet, in .NET 6, all of that changed with the launch of top-level statements. By making the program’s entry point a static method, the new Program class could relinquish its hold on ceremony including all of the set up we used to do in the Startup class—so no more Startup class!

The Program class now looks like this:

var builder = WebApplication.CreateBuilder(args);

// Add services to the container. builder.Services.AddControllers(); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle builder.Services.AddEndpointsApiExplorer(); builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(); }

app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run();

I haven’t omitted any code—this is the …

Read more

.NET Beyond 2022 Wrap Up

Lizz Smullen April 11, 2022

The whirlwind that was .NET Beyond 2022 just wrapped up. If you had a chance to attend, we hope you learned a lot, and had some fun in the process. If you couldn’t attend, check out some talk summaries below. If you want to know more, check out all the talks on YouTube.

Why F# Works in the Enterprise

Python and Java developers who have tried using F# in a .NET ecosystem are in awe over the succinctness in their code.

“It’s not like Python,” said Philip Carter, a senior product manager at HoneyComb, “It has a heritage based on functional programming, not out of smorgasbord programming that Python does.”

Carter, who spent six years working at Microsoft, and five years working with F# for Visual Studio Code, said that F# got its start as a basic Microsoft research project, “It’s really hard for a research project to become a real product,” said Carter.

According to Carter, F# provides excellent Visual Studio Code integration because it lets you use first class software development kits (SDKs) such as Badger, AWS, or any other service that has a standard .NET or small library. He also likes Immutable first, a feature that forces developers to structure their programming so that everything flows cleanly, from top to bottom. He said you can declare something as mutable by just turning off the Immutable first feature.

Immutable first …

Read more

Build an API gateway with .NET 6, C# and YARP

Layla Porter March 1, 2022

Consider an API gateway to be a virtual “garden gate” to all your backend services. Implementing one means that all external traffic must pass through the gateway. This is great as it increases security and simplifies a lot of processes such as rate limiting and throttling.

Cover image of a gateway silhouetted by the sun

There are many paid for services that offer API management but they can be costly and you may not need all the features they offer.

In this tutorial, you will build a basic API Gateway using YARP or “Yet Another Reverse Proxy”. YARP is an open-source library built by developers from within Microsoft. It’s highly customisable, but you are just going to use a simple implementation today.

Before you begin you will need:

What does an app look like without an API gateway?

Below is a simple diagram consisting of 3 services and a database - note our demo looks slightly different to this. The front end client app is talking directly to all three services directly. This means that each service will need to manage its own security and makes implementing patterns such as service discovery much harder.

Diagram showing a client and how it talks directly to 3 backend services

Once you add in an API gateway, as you can see in the diagram below, all external traffic …

Read more

Build an API gateway with .NET 6, C#, YARP, and Netflix Eureka

Layla Porter March 1, 2022

In this previous blog, you learnt how to implement an API gateway in .NET 6 with YARP, a reverse proxy library. All external traffic can be routed through the API gateway to the backend services, making securing and managing the application far easier.

Cover image of a white wooden gate nestled in some large shrubs with white flowers

However, if you have a scalable, distributed system, your API gateway may not know where all of the instances of your services actually are. That’s where a service registry, such as Netflix Eureka can save the day.

Eureka is a RESTful service that is primarily used in the AWS cloud for the purpose of discovery, load balancing and failover of middle-tier servers. It plays a critical role in Netflix mid-tier infrastructure. It’s built with Java, but for your purposes, you can run Eureka easily from a Docker container.

You’ll register all your services and instances with Eureka and then Eureka will tell your API gateway where everything is, so that it can direct traffic to the right place.

Before you begin you will need:

The API Gateway

If you followed along with the Build an API gateway with .NET 6, C# and YARP blog …

Read more

The New Global Usings Directive in C# 10

Layla Porter November 30, 2021

If you’re a C# developer, you’ll recognise the oftentimes extensive list of using directives at the top of a .cs or .razor file. You’ll have also most likely considered a way to obfuscate them - maybe in a #REGION, maybe a setting in an IDE. Many are duplicated across multiple files; I’m looking at you, System, and all your little derivatives!

Although there is nothing inherently wrong with this, it’s been a convention since 2002, it just takes up a lot of screen space at the top of every file.

With C# and .NET 6, however, all that can change…

Cover image

Introducing the new Global Using Directive!

Before you can start making use of Global Using Directive, you will need:

  • The .NET 6 SDK installed
  • An IDE of your choice as long as it supports .NET 6

Creating a global usings file

Many of the most common using directives will already be in a global format out of the box, known as “implicit using directives”, but I find this obfuscation a little confusing.

Implicit using directives will mean the compiler automatically adds a set of using directives based on the project type, meaning the most common libraries will be available out-of-the-box. For example, in a console application, the following directives are implicitly included in the application:

using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading;
using …

Read more