List all Azure Functions with older runtime with Powershell

When you create an Azure Function app, the runtime is responsible for executing function code on the underlying WebJobs SDK host.

Azure Functions currently supports two versions of the runtime host:

  • 4.x: Recommended runtime version for functions in all languages. 
  • 1.x: Supported only for C# apps that must use .NET Framework. This version is in maintenance mode, with enhancements provided only in later versions. Support will end on September 14, 2026. 

Starting from December 13, 2022, function apps running on versions 2.x and 3.x of the Azure Functions runtime have reached the end of extended support.

The version of the Functions runtime used by published apps in Azure is dictated by the FUNCTIONS_EXTENSION_VERSION application setting. By default, function apps created in the Azure portal, by the Azure CLI or from Visual Studio/Visual Studio Code tools are now set to runtime version 4.x:

If you are a long-time Azure Functions developer (or user), probably in your Azure subscriptions now you could have some Azure Function apps created with unsupported runtime and that should be updated. The Azure Portal gives you a warning message when you open the function app:

and if you inspect the runtime, you can see what is the unsupported version:

But as you can imagine, if you have a lot of Azure Functions running in a subscription (like me) it’s not easy to check app by app what are the functions running on an unsupported runtime version.

This was the task that I needed to do today. I had the need to discover all the Azure Function apps running on an unsupported runtime on some of my Azure subscriptions. So why not using Powershell for that?

I started this task using the following Powershell script:

$FunctionApps = Get-AzFunctionApp

$FunctionApps | Sort-Object { $_.Name } | Where-Object { $_.ApplicationSettings["FUNCTIONS_EXTENSION_VERSION"] -ne "~4" }

but misteriously it doesn’t work: it listed ALL my function apps despite the filter on the runtime version! I had also a discussion with some Azure MVPs on that because I remember it worked in the past, but no result…

I spent hours on finding a solution for that, but finally I have a result that works! Here is the Powershell script:

$functionRuntime=@{l="FunctionRuntimeVersion";e={(Get-AzFunctionAppSetting -Name $_.Name -ResourceGroupName $_.ResourceGroupName)["FUNCTIONS_EXTENSION_VERSION"]}}

(Get-AzFunctionApp | Where-Object { $(if ((Get-AzFunctionAppSetting -Name $_.Name -ResourceGroupName $_.ResourceGroupName) -eq $null) {""} else {(Get-AzFunctionAppSetting -Name $_.Name -ResourceGroupName $_.ResourceGroupName)["FUNCTIONS_EXTENSION_VERSION"]}) -ne "~4" } ) | Select-Object Name,ResourceGroupname,$functionRuntime |Format-Table -AutoSize

The script declares a functionRuntime variable that defines an object used as a custom column for the Select-Object statement that I will use later. This object has two properties used to define the title of the column and the expression for obtaining the value of this custom column.

Then it uses Get-AzFunctionApp to list all the function apps and Get-AzFunctionAppSetting to retrieve the app settings for the function app.

If you execute this Powershell script, you have a full list of the Azure Function apps running on an unsupported runtime (and its corresponding version):

The script is available on my GitHub if you need it a day.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.