Skip to main content

Posts

Azure DevOps– Clean the work directory of your build agent

In Azure Pipelines when you use the classic task based pipeline, you can use the Clean option to clean up the working directory of your private agent before the build is run. You can find this setting by clicking on the Get Sources section in the pipeline editor. If you set this option to True you can choose what you exactly want to clean up: Using this option has a clear performance impact but can be useful in situations where the build is showing strange behavior. YAML pipelines But what if you are using YAML pipelines? When using YAML pipelines,  you can achieve the same goal by configuring the workspace clean option on the job: When you specify one of the clean options, they are interpreted as follows: outputs : Delete Build.BinariesDirectory before running a new job. resources : Delete Build.SourcesDirectory before running a new job. all : Delete the entire Pipeline.Workspace directory before running a new job. It is also possible to ...

AKS–The single biggest reason why you should apply a GitOps approach

GitOps is an approach to software delivery that uses Git as a single source of truth for declarative infrastructure and application deployment. With GitOps, all changes to infrastructure and applications are made through pull requests that are reviewed and approved before they are applied to the target environment. This approach offers several benefits, including improved visibility, traceability, but the single biggest reason why you should apply a GitOps approach is (enhanced) security compared to a traditional Continuous Delivery approach. Flux In Azure you can use GitOps in Azure Kubernetes Service (AKS) and Azure Arc-enabled Kubernetes clusters.Behind the scenes this uses Flux , a popular open-source tool set. Flux provides support for common file sources (Git and Helm repositories, Buckets, Azure Blob Storage) and template types (YAML, Helm, and Kustomize). GitOps vs traditional Continuous Delivery(CD) In a traditional CD setup, the CD tooling is running outside the AK...

Javascript–Using splice instead of delete

I have to admit that the amount of Javascript code I write is really limited. And even then I use TypeScript most of the time. Anyway this is only a disclaimer because maybe I'm stating something that is obvious to you. It certainly wasn't to me :-)! I had a really simple use case to solve: I needed to delete a specific item from an array .I didn’t know the exact function name anymore so I asked Google and got back with the delete operator . This turns out to the wrong approach as the delete operation will delete a property from an object and set it to undefined: The correct way is to use the splice function : I hope I never forget it anymore!

ASP.NET Core Guidance

When building scalable server applications using ASP.NET Core, there are common pitfalls that should be avoided and some (best) practices that can help you along the way. Last week I was watching the NDC recording of Damian Edwards and David Fowler talk Why your ASP.NET Core application won’t scal e: In this presentation they share a lot of interesting insides in how to built better performing ASP.NET Core applications. During this talk they point to this Github repo from David Fowler: davidfowl/AspNetCoreDiagnosticScenarios The goal of this repository is to show problematic application patterns for ASP.NET Core applications and a walk through on how to solve those issues. At the moment of writing it contains 2 guides with related code examples General ASP.NET Core Asynchronous Programming A must read for every developer who wants to build scalable ASP.NET Core applications!

Applying the decorator pattern in .NET Core using Castle.DynamicProxy

In this post I want to explain what the decorator pattern is, why it is useful and how you can implement it in a generic way using Castle.DynamicProxy. What is the Decorator pattern? Before we dive into the technical details, let us start with a recap about what the decorator pattern actually is: Decorator is a structural design pattern that lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors. There are a lot of use cases where the decorator pattern can help, in this blog post I focus on one of them; using a decorator to handle cross cutting concerns(caching, error handling, logging, …) without polluting your original object. I’ll show you an example where I introduce caching at the repository interface level. How to integrate the decorator pattern in a generic way? You don’t need a special library or anything to implement the decorator pattern in C#. However I would like to write it in a gener...

AutoMapper issue after upgrading to .NET 7

While upgrading a .NET Core 5 application to .NET 7 I encountered the following issue; when I tried to run the application it failed with the following error message: Method System.Linq.Enumerable.MaxFloat: type argument 'System.Int32' violates the constraint of type parameter 'T'. And for completeness, the full stack trace: at System.RuntimeType.ValidateGenericArguments(MemberInfo definition, RuntimeType[] genericArguments, Exception e) at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(Type[] methodInstantiation) at AutoMapper.Internal.TypeDetails.<>c__DisplayClass25_1.b__10(MethodInfo extensionMethod) at System.Linq.Enumerable.WhereSelectArrayIterator 2.MoveNext() at System.Linq.Enumerable.ConcatIterator 1.MoveNext() at System.Linq.Enumerable.d__231 3.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator 2.MoveNext() at System.Linq.Enumerable.UnionIterator 1.MoveNext() at System.Linq.Enumerable.ConcatIterator 1.MoveNext() at AutoM...

Encapsulate libraries not frameworks

Encapsulation is a way of organizing code into separate modules, where each module has a clear and well-defined responsibility. It allows for better code reusability, maintainability, and testability. Libraries and frameworks are both useful tools for building software applications. However, there is a key difference between the two in terms of encapsulation. Libraries are typically designed to provide a set of functions or utilities that can be used in a variety of contexts. They are generally more loosely coupled and have fewer dependencies on your application code. Encapsulating a library means that you isolate its functionality and implementation details, allowing your application code to interact with it through a well-defined interface. It can be a good idea to encapsulate a library to limit the dependencies to third-party components which makes it harder to maintain your application in the long run. Typically we do this by creating a wrapper that isolates our component by ...