Welcome to imar.spaanjaars.com

image
Welcome to the personal web site of Imar Spaanjaars where I write about software development with a focus on Microsoft web technologies
Image representing the Articles category

Building and auto-deploying an ASP.NET Core application - Part 4 - Setting up a CI pipeline in Azure DevOps to build and test your code

Published about 7 hours ago

In this article I finally get to showing you how to create pipelines in Azure DevOps. I've been mentioning this for a few articles now but there was some groundwork I had to take care of first. In this article, the 4th in a series of 7, I'll show you the following:

  • What YAML is and why you need it
  • How to build a pipeline in Azure DevOps to build your source code every time you do a check in on GitHub.
  • How to modify your build to save the results so they can be deployed to a remote server at a later stage
  • How to add a unit test project to your solution and configure the build to execute your tests
  • How to create EF Migration scripts which can be run against the database during the release

If you haven't read the previous parts in this series you're encouraged to do that now. Here's the full list of the articles in the series:

  1. Introduction
  2. Creating the web application
  3. Using GitHub and managing change in your application
  4. Setting up a CI Pipeline in Azure DevOps (you're reading it now)
  5. Setting up a CD pipeline: Deploying with web deploy to a Virtual Machine or on-premises server (not yet published)
  6. Setting up a CD pipeline: Deploying to an Azure App Service (not yet published)
  7. Improving your builds with a custom build agent and Azure Deployment Slots (not yet published)

Note: if you like to purchase the entire series now and not wait for the remaining parts to come online, check out this blog posts that explains how you can purchase it for only $8.

Read on ...
Image representing the Articles category

Building and auto-deploying an ASP.NET Core application - Part 3 - Dealing with change

Published 15 days ago

In the previous article in this series I showed how to set up the initial web application and add Entity Framework as the database persistence framework. This provides a good starting point for the application. As you'll be expanding the application you need a good way to manage code and database schema changes. In this article you'll see how to leverage Git, GitHub and EF migrations to manage code changes. In the next article in the series I'll then finally show you how to set up a CI pipeline followed by a CD pipeline in a later article.

If you haven't read the previous parts in this series you're encouraged to do that now. Here's the full list of the articles in the series:

  1. Introduction
  2. Creating the web application
  3. Using GitHub and managing change in your application (you're reading it now)
  4. Setting up a CI Pipeline in Azure DevOps
  5. Setting up a CD pipeline: Deploying with web deploy to a Virtual Machine or on-premises server (not yet published)
  6. Setting up a CD pipeline: Deploying to an Azure App Service (not yet published)
  7. Improving your builds with a custom build agent and Azure Deployment Slots (not yet published)

Note: if you like to purchase the entire series now and not wait for the remaining parts to come online, check out this blog posts that explains how you can purchase it for only $8.

Read on ...
Image representing the Articles category

Building and auto-deploying an ASP.NET Core application - Part 2 - Creating the web application

Published about a month ago

This is part 2 in a series of 7 articles showing you how to build a database-driven ASP.NET Core 5.0 app and deploy it to a remote web server using continuous integration and deployment with GitHub and Azure DevOps. In this part I'll show you how to set up the basic application, add a model that uses Entity Framework Core 5.0 to persist data to the database and how to create to the initial database.

Note: if you like to purchase the entire series now and not wait for the remaining parts to come online, check out this blog posts that explains how you can purchase it for only $8.

If you haven't read the first part of this series you're encouraged to do that now. Here's the full list of the articles in the series:

  1. Introduction
  2. Creating the web application (you're reading it now)
  3. Using GitHub and managing change in your application
  4. Setting up a CI Pipeline in Azure DevOps
  5. Setting up a CD pipeline: Deploying with web deploy to a Virtual Machine or on-premises server (not yet published)
  6. Setting up a CD pipeline: Deploying to an Azure App Service (not yet published)
  7. Improving your builds with a custom build agent and Azure Deployment Slots (not yet published)

Read on ...
Image representing the Articles category

Building and auto-deploying an ASP.NET Core application - Part 1 - Introduction

Published about a month ago

I have been programming for many years and over those years, I have seen the development landscape change quite a lot. Things have become both simpler and more complex at the same time. For example, setting up a web server on Windows to run a Classic ASP site with COM+ components was pretty complicated back in the days. Setting up an Azure app service today to do more or less the same as that old web server did takes just a couple of clicks in the Azure portal. At the same time, things have become more complicated because possibilities, demands and requirements have changed. For example, when I started programming, distributed source control usually meant a shared network drive where everyone would write to and that was occasionally backed up ;-) But nowadays, we have powerful source control systems like Git that allow for more feature-rich management of your source code including history, branching and a lot more. And combined with powerful online platforms like Azure DevOps and GitHub, you have all the tools you need at your fingertips.

Read on ...
Image representing the Blogs category

Introducing a new article series: Building and auto-deploying an ASP.NET Core application with EF Core 5.0

Published about a month ago

Over the past couple of weeks I have been working on a new article series on building and auto-deploying an ASP.NET Core application using ASP.NET Core 5.0, Entity Framework Core 5.0, Git, GitHub and Azure DevOps. Just this week I wrapped up the last article and the series is now done! I've published the first article in the series today, and the remaining 6 parts will come online in the coming weeks.

Read on ...
Image representing the Articles category

Improving your ASP.NET Core site's e-mailing capabilities

Published 3 months ago

Many websites depend heavily on e-mail: they send account confirmation e-mails, password reset e-mails, order confirmations, back-in-stock notifications and much more. Despite its importance, I often see that sending e-mail is an overlooked area when writing well maintainable and stable code. It's also often overlooked when monitoring sites and lots of code I have seen just assumes the mail server is up and running. But problems will occur; mail servers will go down, passwords do expire or get changed without updating the web site and more.

In a preceding article you saw how to monitor your site's SMTP server using an ASP.NET Core health check. While it's great to be notified when your SMTP server is unavailable, it would be even better if your site has an alternative way to deliver the messages when the primary SMTP is not available.

In this article, I'll show you a couple of ways to improve the way you send e-mails from your ASP.NET Core applications. In particular, I'll discuss:

You'll find the full code for the article as a download at the end of this article, as well as in the Github repository for this article.

Read on ...
Image representing the Articles category

Using Standard Health Checks and Building your Own in ASP.NET Core

Published 3 months ago

Being able to monitor your ASP.NET Core web applications and APIs and detect any issues early on is crucial in ensuring your sites are up and running and in a healthy state. In previous articles I talked about creating a custom health check solution for ASP.NET Framework applications and implementing ASP.NET Core health checks with standard functionality. In this article I'll show you how to add and configure some existing, open-source health checks to monitor an SMTP server and the web server's disk space (these are just examples; there are many more health checks available that you can plug in to your own web site). And if the standard health checks aren't sufficient, you can build your own; something you'll see how to do in the second part of this article.

Read on ...
Image representing the Snippets category

Unit Testing Authorization on your Controllers

Published 3 months ago

In many of my ASP.NET web applications (mostly MVC or Web APIs) I have a mix of content with endpoints that either require authentication and authorization or that can be accessed anonymously. For example I have mostly public content (such as my own web site) with a protected management (admin) section. Or I have a Web API project with many endpoints protected by authorization but with a few of them publicly available. To ensure you protect your controllers well, you have many different options. In this article I'll show you a short unit test that you can use to ensure your controllers are properly configured when using a mixed authorization scenario.

Read on ...
Image representing the Articles category

Improving IntelliSense for the asp-page Tag Helper using T4 Templates

Published 3 months ago

I find ASP.NET Tag Helpers super helpful. They provide powerful features and yet use clean markup. As an example, here's a tag helper that creates a link to an action method in some controller:

<a asp-controller="Contact" asp-action="Index">Get in Touch</a>

At run-time, ASP.NET then generates the correct URL for this action method and creates an href attribute on the anchor for it:

<a href="/contact">Get in Touch</a>

Read on ...
Image representing the Articles category

Implementing Health Checks in ASP.NET Core

Published 4 months ago

Being able to monitor your ASP.NET Core web applications and APIs and detect any issues early on is crucial in ensuring your sites are up and running and in a healthy state. In a previous article I talked about creating a custom health check solution for ASP.NET Framework applications. In this article I'll show you how to leverage the built-in Health Check framework along with some third-party open-source add-ons available for ASP.NET Core applications. You may want to check out the previous article to better understand health checks and why they are useful. And seeing the custom solution for the .NET Framework may have you appreciate the built-in ASP.NET Core functionality even more. And in this article I'll dive a little deeper into some existing third-party health checks that make monitoring your sites and services super easy and show you how to build your own health checks and plug them into the system.

Read on ...

Mobile: False

Crawler: True

I: False