Tag: ASP.NET

Development

Getting Started with Application Insights for ASP.NET Core

In my previous posts I gave a quick Introduction to Application Insights and then I showed you how to Disable Application Insights from your app. In this post I’ll walk you through creating an ASP.NET Core application and then configuring it with Application Insights. Let’s get started.

Configuring your app for Application Insights

Start by creating a new ASP.NET Core application (this also applied to non-core ASP.NET applications). Once the application is created right click on the project file in the context menu look for Configure Application Insights… and then click on it.

image

You will see that the SDK has already been added to your application. Next click on the Start Free button to start using Application Insights.

image

You will need to have an existing Azure Subscription. If you don’t already have one you can create one for free and start with a $250 credit for 30 days + you will have access to popular services for 12 months + there are over 25 services that are always free. Now that you have your Azure Subscription, login with your Microsoft Account, select your Subscription and then a Resource. These can always be easily changed later on if need be.

You will now have access to the free plan which comes with 1 GB / Month of data included and data retention is 90 days. Click on he Register button to finish the configuration:

image

Now that Application Insights is configured for your application you have access to a wealth of information with the click of a button.

sshot-372

Accessing the Application Insights Telemetry from Visual Studio

You can search your Application Insights results from either the Azure Portal or from within Visual Studio. To use Visual Studio go to the View menu, select Other Windows and then Application Insight Search. You will then get view of the telemetry for the last 24 hours as shown below from a sample API I have. From here you can filter the telemetry and dive down into specific events.

image

Another nice feature is that Application Insights telemetry data including any exceptions that have been captured will show up in the CodeLens information as shown here:

image

There is a lot of value from using Application Insights in any of your applications. I hope you take a look and try it out for yourself.

Enjoy!

References

https://azure.microsoft.com/en-us/services/application-insights/

https://docs.microsoft.com/en-us/azure/application-insights/app-insights-asp-net-core

Development

How to Disable Azure Application Insights in ASP.NET Core

In my previous post I showed you how easy it was to get started with an Introduction to Application Insights for your ASP.NET Core application. However what if you you don’t want Application Insights? You might notice in your Output pane when running your app that it’s still partially enabled for you out of the box. I’ll walk you through what I mean by it being partially enabled and then how you can go about hiding it until such time you decide to fully turn it on. Let’s get started.

Start off by creating a new ASP.NET Core application (see below) and then immediately run it.

image

You will then notice that you will see the following statements in your Output pane:

Application Insights Telemetry (unconfigured): {“name”:”Microsoft.ApplicationInsights.Dev.Message”,”time”:”2018-03-24T03:39:26.5327026Z”,”tags”:{“ai.application.ver”:”1.0.0.0″,”ai.operation.parentId”:”|80d77757-4707b4b80d71a9b3.”,”ai.internal.sdkVersion”:”aspnet5c:2.1.1″,”ai.operation.id”:”80d77757-4707b4b80d71a9b3″,”ai.internal.nodeName”:”LT2206″,”ai.location.ip”:”127.0.0.1″,”ai.cloud.roleInstance”:”LT2206″,”ai.operation.name”:”GET Values/Get”,”ai.user.id”:”6RWa2″},”data”:{“baseType”:”MessageData”,”baseData”:{“ver”:2,”message”:”Executed action WebApplication5.Controllers.ValuesController.Get (WebApplication5) in 205.1085ms”,”severityLevel”:”Information”,”properties”:{“DeveloperMode”:”true”,”{OriginalFormat}”:”Executed action {ActionName} in {ElapsedMilliseconds}ms”,”ActionName”:”WebApplication5.Controllers.ValuesController.Get (WebApplication5)”,”AspNetCoreEnvironment”:”Development”,”ElapsedMilliseconds”:”205.1085″,”CategoryName”:”Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker”}}}}

image

You might be wondering why is it doing this and how can I disable it?

The easiest way to disable Application Insights without going through the process of ripping it out is to just disable it. You can do this by accessing TelemetryConfiguration.Active.DisableTelemetry and setting this to true. What I would recommend doing is to add a static method to your Startup.cs file and call this method from your Configure method like so:

image

Now when you run your application and look in the Output pane you will no longer see any statement pertaining to Application Insights.

image

I see a great deal of value of keeping Application Insights and using it in all your applications, so if you need to disable it then maybe do this when running in debug mode by using a conditional attribute on the method.

Enjoy!

References

https://github.com/aspnet/Home/issues/2051

DevelopmentWeb

ASP.NET 5 Overview

ASP.NET 5 is a significant redesign. Checkout the overview on the ASP.NET site.

“ASP.NET 5 is a lean .NET stack for building modern web apps. We built it from the ground up to provide an optimized development framework for apps that are either deployed to the cloud or run on-premises. It consists of modular components with minimal overhead, so you retain flexibility while constructing your solutions.”

Reference

http://www.asp.net/vnext/overview/aspnet-vnext/aspnet-5-overview

Development

Announcing .NET 2015 Preview: A New Era for .NET

“Today is a pivotal moment for .NET. With the release of .NET 2015 Preview, we are embarking on a new journey while maintaining our strong commitment to the 1+ billion customers that are using .NET today.

As Scott Guthrie and S. ‘Soma’ Somesegar announced at the Connect(); event today, .NET is entering a new era as it embraces open source as a core principal and enables .NET applications to run on multiple operating systems. As part of .NET 2015 Preview, we are delivering .NET Core 5 which is a completely open source stack and can run on multiple operating systems. In addition, not only are we contributing .NET Core 5 to the .NET Foundation but we will openly collaborate with the community and ensure that we continue our strong relationship with existing .NET open source communities, in particular the Mono community. Here are a set of announcement around open source and cross platform from today’s Connect(); event:

.NET Core 5 is the small optimized runtime for ASP.NET 5. It currently runs on Windows, and will be extended to Linux and Mac. You will have more choice of which operating systems you use for ASP.NET 5 development and deployment, supported by Microsoft. Azure will support ASP.NET 5 in both Linux and Windows VMs. You choose.”

Reference

http://blogs.msdn.com/b/dotnet/archive/2014/11/12/announcing-net-2015-preview-a-new-era-for-net.aspx

DevelopmentWeb

How to get your ASP.NET application working in IE11

Excellent post on Telerik blog on how to update your server to recognize IE11:

http://blogs.telerik.com/blogs/13-12-19/how-to-get-your-asp.net-application-working-in-ie11

Enjoy!

CloudDevelopmentWeb

Windows Azure Web Sites: How Application Strings and Connection Strings Work

Great article on how Windows Azure Web Sites: How Application Strings and Connection Strings Work.

Windows Azure Web Sites has a handy capability whereby developers can store key-value string pairs in Azure as part of the configuration information associated with a website.  At runtime, Windows Azure Web Sites automatically retrieves these values for you and makes them available to code running in your website.  Developers can store plain vanilla key-value pairs as well as key-value pairs that will be used as connection strings.

Since the key-value pairs are stored behind the scenes in the Windows Azure Web Sites configuration store, the key-value pairs don’t need to be stored in the file content of your web application.  From a security perspective that is a nice side benefit since sensitive information such as Sql connection strings with passwords never show up as cleartext in a web.config or php.ini file.

 

Enjoy!

Development

Visual Studio 2012 Now Available

IC611657

Today Microsoft has made Visual Studio 2012 and all it’s related products available to download. You should note that with the 2012 edition, Team Foundation Server Express is available. Sweet!

Download and try it today

Attend the launch event on September 12