Posted by Anuraj on Sunday, August 25, 2019 Reading time :1 minute
CI GitHub Actions ASPNET Core
In the last post we learned about working with GitHub actions and creating a CI workflow for our dotnet core application. In this post, we will learn how to deploy the middleware to nuget.org using dotnet nuget push command.
Posted by Anuraj on Monday, August 19, 2019 Reading time :1 minute
CI GitHub Actions ASPNET Core
GitHub Actions makes it easy to automate all your software workflows. GitHub actions is still in Beta and it is free for Open source projects. This post is writing your first GitHub action for implementing continuous integration for a dotnet core application. Similar to Azure DevOps or Travis CI, it is also supports YAML scripts to implement automation.
Posted by Anuraj on Tuesday, August 6, 2019 Reading time :2 minutes
This post is about how to mock entity framework DbContext class for unit testing without any third party framework. The dotnet core framework designed and developed considering testability of the apps in mind. Usually for testing the applications which interacts with database, we used to follow two approaches 1) We will be using a repository layer to interact with Database and using any mock framework (without a mocking framework also we can implement it.), we will mock the repository and test the application. 2) Use In Memory Database provider instead of the actual database provider. In this post, I am showing the second approach, the actual code is using SQL Server provider. And for unit testing I am using In Memory provider for EF Core.
Posted by Anuraj on Tuesday, May 14, 2019 Reading time :1 minute
C# 8.0 C#
This post is about the new C# 8.0 feature Default implementations in interfaces. This feature helps you to provide an implementation for your new method in an interface. So you won’t break existing implementation by adding a new method. From the documentation - An interface member can now be specified with a code body, and if an implementing class or struct does not provide an implementation of that member, no error occurs. Instead, the default implementation is used.
Posted by Anuraj on Monday, May 13, 2019 Reading time :1 minute
This post is about getting all the blobs in a container and change the content type. This tip or snippet is quite useful in scenarios where you want to change content type of big number of blobs. This is a tip or snippet more than a blog post. I faced this issue in my current project, where our application used to push images to Azure Blob, but we were not setting the content type, and by default the content type is application/octet-stream. Because of this, when we used to browse the URL, instead of displaying it in the browser, browser used to show a download prompt. In this I am using a dotnet core console app, which will get all the blobs and if the extension of the file is jpg, setting the content type to image/jpg.
Posted by Anuraj on Sunday, April 14, 2019 Reading time :2 minutes
ASP.NET Core gRPC
This post is about Working with gRPC in ASP.NET Core. gRPC is a language agnostic, high-performance Remote Procedure Call (RPC) framework.
Posted by Anuraj on Friday, April 5, 2019 Reading time :3 minutes
ASP.NET Core Azure Serverless
This post is about how to resize images uploaded to a blob storage using Azure functions. In my current project, system used to resize the image while uploading the image to blob storage. This approach got two major drawbacks - the process will take some time and the resize is implemented using System.Drawing - which is not recommended to use in Server side applications. By implementing a function - which triggers while someone uploads a photo to blob storage - using ImageSharp - resize the image. Since the code is very minimal I am using the Azure portal to build the Azure Function. In the portal, click New and Search for Functions, select Function App. And you need to provide a name, resource group and storage.