Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

What is the current .NET version on an Azure App Service

I have an App Service here (currentdotnetversion) that shows the output of the current (when I wrote this article) .NET version using C# code.  Here is a partial code snippet:

protected void Page_Load(object sender, EventArgs e)
{
  const string subkey = @"SOFTWAREMicrosoftNET Framework SetupNDPv4Full";
  using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,
         RegistryView.Registry32).OpenSubKey(subkey))
  {
   if (ndpKey != null && ndpKey.GetValue("Release") != null)
   {
     LabelPublished.Text = ".NET Framework Version: " +
       $"{CheckFor45PlusVersion((int)ndpKey.GetValue("Release"))}";
   }
   else
   {
     LabelPublished.Text = ".NET Framework Version 4.5 or later is not detected.";
   }
 }
 LabelTargeted.Text = "The targeted .NET Framework version is: " +
    $"{System.Web.HttpRuntime.TargetFramework.ToString()}";
}

I took the code from here and I got the Microsoft.Win32 assembly via a NuGet package, see Figure 1.

Figure 1, where to get the Microsoft.Win32 assembly, how to find the .NET versions

The code basically checks for the release version in the registry, see Figure 2.  Sure you can dump it our using REG QUERY, I discuss more ways to use this command in these other articles:

  • How to see the cipher suites on an Azure App Service
  • Visual C++ Redistributable Packages for Visual Studio Azure App Service
  • Not written by me, but a good post “How to determine the installed .NET version in Azure App Services”

Figure 2, How to find the .NET versions on an Azure App Service

You can also check is out in the Azure Portal on the App Service –> Application Settings blade, see Figure 3.

Figure 3, How to find the .NET versions on an Azure App Service

I thought about coding the same to get the version which is targeted by my ASP.NET app because it can be different than the most current version installed on the platform.  I immediately jumped to this static property, which is right:

System.Web.HttpRuntime.TargetFramework.ToString();

Then I saw that there were targetFramework attributes in 2 places within my web.config file and needed to find out which one had precedence and what this meant.

I found this article very helpful “All about ” which states:

Use to opt-in to new 4.5 behaviors.

Use identifies which reference assemblies are used when when performing compilation.

I interpret that to mean that use the httpRuntime which focuses your application on the 4.5 or greater version of the CLR, while compilation points the ASP.NET app to a specific version of the .Net Framework.

I discuss the difference between side-by-side and in-place upgrade here “Lab 5: Basic and Advanced Application Pool Settings” which you should also understand to get the total context.  There is also a link to this article as well “.NET Versioning and Multi-Targeting - .NET 4.5 is an in-place upgrade to .NET 4.0”.

Share the post

What is the current .NET version on an Azure App Service

×

Subscribe to Msdn Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The Msdn Blogs.

Get updates delivered right to your inbox!

Thank you for your subscription

×