Monday, August 31, 2020

GraphQL–HotChocolate–Read HTTP headers

Quick tip if you want to read the HTTP headers from the incoming GraphQL request in .NET Core using HotChocolate.

There are 2 ways I found that can be used to achieve this:

  1. Inject the IHttpContextAccessor in your resolvers.
  2. Create a custom Query Interceptor and set the context data

First one is rather obvious but let’s see an example on how to take the second approach:

In your resolvers you can now access the context property through the ContextData directly or by injecting it:

Friday, August 28, 2020

Impress your colleagues with your knowledge about … the Immediate window

Sometimes when working with C# you discover some hidden gems. Some of them very useful, other ones a little bit harder to find a good way to benefit from their functionality. One of those hidden gems that I want to share today is a neat trick inside the Immediate window.

With the Immediate window you can debug and evaluate expressions, execute statements, and print variable values. The Immediate window evaluates expressions by building and using the currently selected project.

By default when you evaluate an expression in the Immediate window, the application state will change.

If that’s not something you want, you can avoid it. Just add the , nse (no side effects) postfix to an expression, and it will evaluate without changing the application state.

More information: https://docs.microsoft.com/en-us/visualstudio/ide/reference/immediate-window?view=vs-2019

Thursday, August 27, 2020

Nuget Push: Method not allowed

When trying to push a newly created nuget package to Azure Artifacts it failed with the following error message:

“Failed to process request. ‘Method not allowed’.”

Here is the exact command I tried to execute:

nuget.exe push –Source “Sample Source” –ApiKey AzureDevOps Example.1.0.nupkg

The problem turned out to be related to the nuget.exe version I was using. It was still an old(er) version.

After downloading the latest version(https://dist.nuget.org/win-x86-commandline/latest/nuget.exe) and re-executing the same command it worked as expected.

Wednesday, August 26, 2020

Visual Studio: The current page is inactive because you are not connected to a Git team project

After opening a git repo in Visual Studio I couldn’t do any git related action. All buttons were disabled and following message was shown on the top of the Team Explorer window:

“The current page is inactive because you are not connected to a Git team project. Connect to a different project”

Clicking on the Connect to a different project link brought me to the Manage connections screen where I tried multiple times to reselect the correct Azure DevOps repo. I even tried to switch the Source Control plugin type but nothing helped.

In the end I tried the good old trick; restarting Visual Studio. After loading my solution again everything worked as expected. Strange…

Tuesday, August 25, 2020

On avoiding ‘big bang’ rewrites

I encounter too much organizations where they move from one ‘big bang’ rewrite to another.

The situation always evolves in the same way:

A new system is created that will replace an old system. But this time we’ll do it right. We throw out all the old technology and choose the latest and greatest shiny tools. After a few months/years/decades the new system finally sees the light and it looks awfully similar to the old system(although the user interface is a little better). This ‘new’ system over time becomes harder and harder to maintain. Adding new functionality costs more and more until we arrive at the moment where developers throw in the towel and declare it became impossible to add any new feature or change. It’s time for the next rewrite…

Does this sounds familiar?

A smart man once said:

“The definition of insanity is doing the same thing over and over and expecting different results.”

The mistake that is made is that the team focusses too much on the technology and they’ll handle it as a technical migration. As a consequence you’ll end up with the same system written in a more modern(better?) technology without really improving the system.

The solution? Don’t do a rewrite, instead focus on evolutionary architecture and apply the strangler pattern to evolve from the old to the new system.

The universe was created with one big bang, since then it is continuously evolving We wouldn’t like it to have the universe evolve with a next big bang, as we’ll not survive the event.

So why we think it’s a valid approach for our systems?

Monday, August 24, 2020

Eventing and Messaging on Azure

There are a multitude of options available when choosing a messaging solution on Azure; Event Grid, Event Hub, Service Hub, …

But which one should you choose? A first comparison can be found in the Azure documentation but the best explanation I found is by Clemens Vasters in a presentation he gave at .NET Conf.

Here is the full presentation:

And here is the one slide that explains the differences:

Friday, August 21, 2020

Azure SQL Learning Tools

Although every developer seems to know the latest and greatest new Javascript framework, some other more basic(/important?) skills seems to be lacking.

One of these skills is good knowledge of SQL (Server). Although ORM’s made our life as developers a lot easier it has the side effect that people don’t know how to write a SQL query anymore.

It is painful to watch how I see developers struggle when they have to write a stored procedure (a what…?). 

So for all these developers out there that recognize themselves in the story above, you are lucky. The Azure Data team created a lot of new content that will help both beginners being introduced to Azure as well as SQL experts learn how to understand the benefits of Azure SQL.

From the announcement:

Microsoft Learn learning path: This six-course Azure SQL fundamentals learning path provides a built-in lab environment for you to learn at your own pace without a subscription.

YouTube/Channel9 series: We offer more than 60 videos to help beginners learn more about Azure SQL. Viewers can experience on-demand training through Microsoft Developer and Azure SQL playlists on YouTube and Channel9.

GitHub content: Learners and educators can dig into open-source code in a scenario-driven GitHub workshop, where forking and redelivering is encouraged. You can access this content by visiting the SQL Server workshops page and selecting “Workshop: Azure SQL”.

Learn Live in the Azure SQL Bootcamp: In this four-day series of live sessions, Microsoft SQL experts Anna Hoffman and Bob Ward will help you get ramped up and support you as you learn. You can sign up for Azure SQL Bootcamp here to join us.


Thursday, August 20, 2020

Azure DevOps/ GitHub emoji

I’m really bad at remembering emoji’s. So here is cheat sheet with all emoji’s that can be used in tools that support the github emoji markdown markup:

All credits go to rcaviers who created this list.

Wednesday, August 19, 2020

Release trains are NOT the solution

One of the techniques that you see in bigger organizations that struggle to move to an Agile mindset, is the introduction of Release trains:

A release train tries to align the vision, planning, and interdependencies of many teams by providing cross-team synchronization based on a common cadence. A release train focuses on fast, flexible flow at the level of a larger product.

It is especially used in SAFe(Scaled Agile Framework) organizations. Their definition of a release train is:

Agile Release Trains align teams to a shared business and technology mission. Each is a virtual organization (typically 50 – 125 people) that plans, commits, develops, and deploys together. ARTs are organized around the Enterprise’s significant Value Streams and exist solely to realize the promise of that value by building Solutions that deliver benefit to the end-user.

Based on the definitions above you would think that a release train is something you should aim for, an end goal you should achieve to become ‘Agile’. I don’t agree with that. Although release train can help you get in the right direction, they are a temporary workaround for an organization moving to continuous delivery. THAT is what you should aim for. Release trains are a remedial technique to get out of the mess that the release process in most organizations is today.

The biggest risk is that release trains bring you on the path of distributed monoliths. As you get used to the fact that all your services are deployed together, your architecture will start to depend on it. Now you have all the complexity of a distributed system, but also the downsides of a single unit of deployment as well.

Every part of your architecture should be independently deployable.

Intrigued? Read following article: https://rollout.io/blog/release-train-crashed/

I’ll leave you with one quote:

“If you have a release engineer/manager chances are you have a distributed monolith”

Tuesday, August 18, 2020

The resource utilization trap

I could write a whole blog post about the resource utilization trap(and don’t get me started on the word ‘resource’) but I cannot explain it better as demonstrated in this brilliant video:

A must watch for every (project) manager…