English
Français

Blog of Denis VOITURON

for a better .NET world

Microphone, Webcam, software for your meetings or podcasts.

Since many years now, I have been hosting the french podcast DevApps.ms, which talks about news, development and architecture of .NET technologies. On this occasion, I learned about the hardware and software that allow to produce quality podcasts. Scott Hanselman’s site helped me a lot.

For a few months now, the global pandemic has often forced us to homework. For a few days, talking with colleagues using the laptop’s microphone and camera can probably be enough. But after a few months, you probably want to have better image and sound quality.

These are two of these reasons why I want to share my experiences in choosing audio and video equipment. This equipment is certainly not of professional quality, but it has a lot of assets to improve our daily telework.

Teams-Skype


Microsoft Teams - How to create a Bot using C#

In this article, we will create a Microsoft Teams Bot developed in C#, using the Microsoft SDK. Then we will host it in Azure and publish it in your company’s Teams. This way you can easily adapt the C# code to improve the discussion with your Bot.

The steps are :

  1. Developing a Bot in C#
  2. Test the Bot locally
  3. Publish the Bot in Azure
  4. Create a Bot Channels Registration
  5. Setting up the Teams channel
  6. Create a deployment package for Teams
  7. Install the package in Teams

Windows Terminal - Display the GIT status

Recently, Microsoft released a page that explains how to customize Windows Terminal to colour and display GIT status. Git Colored


Azure DevOps - Easy Code coverage

In all projects you develop in .NETCore, it is essential to add a test project :-) And then it becomes very simple to complete this project with a code coverage calculation procedure. Developers will be asked to create test procedures that go through all the branches of your source code. A code coverage rate of at least 80% is very often recommended.


TechDay Conf 2020

This Saturday, I had the chance to participate in the first edition of TechDay Conf, it’s a virtual conference. It includes technical sessions of a few minutes. This conference is dedicated exclusively to application development, cloud transformation and new web framework like Blazor.

My two sessions today are about:

  1. Avoid Entity Framework. Do Object Relational Mapping: french speaking session.
  2. Visual Studio 2019 - Code like a ninja: french speaking session.

SSL certificate for an Azure App Services

In a previous article, I showed you how to create a free SSL certificate via Lets’Encrypt.

The main (or only) problem with Let’s Encrypt is that the certificate has a lifetime of maximum 3 months. This means that you have to renew and install it manually or automatically very regularly.

To avoid this it is necessary to purchase a SSL certificate with an expiration date of up to several years.

Secure web site

Several steps are required to create and install an SSL Certificate in Azure.


How to mock DateTime in Unit Tests (C#)

Today, a developer came to me asking how to test his code that contains a reference to DateTime.Now. Indeed, sometimes your application treats its data differently, depending on today’s date. For example, how do you check the following code, which depends on the current trimester?

int trimester = (DateTime.Today.Month - 1) / 3 + 1;
if (trimester <= 2)
    ...
else 
    ...

Application Insights for your WebAPI

Application Insights is a feature of Azure Monitor. It is an extensible service of Application Performance Management (APM). Use it to monitor your application. It will automatically detect performance anomalies. It includes powerful analysis tools to help you diagnose problems and understand what users are actually doing with your application.

1. Enable Application Insights.

To use this service, it is very simple.

  1. Simply add this service Application Insights to your Azure portal. If you already have a App Service (for your website, for example), you already have the service. Retrieve the Instrumentation Key key from the Overview screen of the Application Insights service.

  2. In your ASP.NET Core project, add the NuGet package ApplicationInsights.

  3. Refer this new service to your Startup class: services.AddApplicationInsightsTelemetry();

  4. Create or modify your file appsettings.json by specifying the Instrumentation Key:

{
  "ApplicationInsights": {
    "InstrumentationKey": "2212b9e0-4715-1765-1746-12cbe02edd67"
  }    
}

Start your project and navigate through the APIs or screens. After a few seconds, you will see the traces appear in the Azure portal.

Application Insights Demo


Blazor Code Behind (partial class)

UPDATE: On October 15th 2019, Microsoft announced the partial class support. This article is the update version of the article of october 6th.

If, like me, you start developing projects with Blazor, you may prefer to separate your HTML code from your CSharp code.

Indeed, all the examples presented by Microsoft use this format, where the code is injected from the web page via the @code attribute.

<!-- File "Counter.razor" -->
@page "/counter"

<h1>Counter</h1>
<p>Current count: @currentCount</p>
<button @onclick="IncrementCount">Click me</button>

@code {
    int currentCount = 0;

    void IncrementCount()
    {
        currentCount++;
    }
}

Personally, I prefer to decompose the visual into a .razor file and the CSharp code into a .razor.cs file. This file contains a partial class named as the component.


GIT authentication

To connect to Azure DevOps, there are several ways to authenticate. One of the easiest ways to do this, under Windows, is to use GIT Credential Manager. This GIT Credential Manager creates and registers a Personal Access Token by opening a connection window to Azure DevOps.

Sometimes the Token is invalid. You must then ask to generate a new one.

\> git fetch
remote: TF401019: The Git repository with name or identifier MyProject does not exist or you do not have permissions for the operation you are attempting.
fatal: repository 'https://dev.azure.com/.../MyProject/_git/MyProject/' not found

Languages

EnglishEnglish
FrenchFrançais

Follow me

Recent posts