Category Archives: Microsoft Azure

.NET Core Api – Catch exceptions using a middleware

In .NET Core, we are starting to get used to the fact that nothing comes for free, and in the world of ultimate freedom of choice, every feature needs to be implemented by us. This includes error handling. In a … Continue reading

Posted in .NET Core, c#, Microsoft Azure | Tagged , , , | 3 Comments

Sitecore and Application Insights – How to remove 90% of all log lines without sacrificing traceability

In this article I will explain how you can remove up to 90% of all log lines from the Application Insights log, but still keep every log line in the file log. All of this without loosing any important information. … Continue reading

Posted in Microsoft Azure, Sitecore 8, Sitecore 9 | Tagged , , , , , | 1 Comment

.NET Core Catch Model Binding Exceptions

In .NET Core, if you create an API project, and you have an controller receiving an object you defined yourself, the controller will not be called if you use the wrong model, or if the model is not in a … Continue reading

Posted in .NET Core, c#, Microsoft Azure | Tagged , , | 1 Comment

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the ‘await’ operator to the result of the call

This C# warning occurs if you call an async method from your non-async code. Imagine you have this imaginary async method: And you call the method from this imaginary non-async method: The compiler will warn you with the following message: … Continue reading

Posted in .net, .NET Core, c#, General .NET, Microsoft Azure | Tagged , , , | Leave a comment

Sitecore use Application Insights Metrics and Telemetry

Although Sitecore have an integration for Application Insights (which is part of Azure Monitor), you can implement the TelemetryClient yourself. This is useful if you wish to log Metrics or Trace your own code, without involving the complete Sitecore solution. … Continue reading

Posted in .net, c#, Microsoft Azure, Sitecore 7, Sitecore 8, Sitecore 9 | Tagged , , | 1 Comment

Calling Azure Functions from JavaScript – The CORS configuration

You cannot call Azure Functions from JavaScript unless you configure the CORS settings for your Function Apps: This is because Microsoft have by default enabled CORS and only allows only some azure domains to access the Function Apps: So to … Continue reading

Posted in Microsoft Azure | Tagged , , | Leave a comment

Azure Functions CRON expressions

When creating Microsoft Azure Functions, you can have a timer that triggers your function. The time for when the function should run is specified in a CRON expression: The CRON format is widely used in UNIX environments, so therefore a … Continue reading

Posted in Microsoft Azure | Tagged , , , | Leave a comment

Read blob file from Microsoft Azure Storage with .NET Core

In order to read a blob file from a Microsoft Azure Blob Storage, you need to know the following: The storage account connection string. This is the long string that looks like this: DefaultEndpointsProtocol=https; AccountName=someaccounfname; AccountKey=AVeryLongCrypticalStringThatContainsALotOfChars== The blob storage container … Continue reading

Posted in .NET Core, Microsoft Azure | Tagged , | Leave a comment

Serilog – Add thread ID to the log file

Serilog is more or less the default file logger when developing .NET Core applications. The simple logger can easily be modified to – for example – add the thread ID. FIRST THINGS FIRST: THE SERILOG NUGET PACKAGES You need these … Continue reading

Posted in .NET Core, c#, Microsoft Azure | Tagged , , | Leave a comment

Azure ApplicationInsights track custom metrics using the TelemetryClient

The Microsoft.ApplicationInsights nuget package is your code gateway to the Microsoft Application Insights portal, and also to the Azure Monitor universe. You use these tools as a shared place for your log data, telemetry, alerts, diagnostics etc. The Application Insights comes … Continue reading

Posted in .net, c#, Microsoft Azure | Tagged , , , , | 1 Comment