Archive

Posts Tagged ‘powershell’

Find #Azure Functions still using the in-process model in #Azure

If you got the following email from Microsoft Azure:

Migrate your .NET apps in Azure Functions to the isolated worker model by 10 November 2026
You’re receiving this email because you use the in-process model with .NET applications in Azure Functions.

Beginning 10 November 2026, the in-process model for .NET apps in Azure Functions will no longer be supported. To ensure that your apps that use this model continue being supported, you’ll need to transition to the isolated worker model by that date.

You may still use your .NET apps with the in-process model beyond 10 November 2026, but they will no longer receive security and feature updates from Microsoft.

The isolated worker model offers all the same functionality as the in-process model, plus improvements such as:

Full control of the dependency chain.
Isolation from platform lifecycle activities.
The ability to target Standard Term Support (STS) versions of .NET.
Required action
To ensure your .NET apps in Azure Functions continue to receive support, migrate to the isolated worker model by 10 November 2026.

Here is a script in both Powershell and Dos (Batch), to check which functions are using the in-process model; (Using the azure CLI for Windows)

This script logs into Azure, sets the subscription, lists the function apps, and checks the settings to identify which apps are using the in-process model for .NET:

powershellCopy code# Log in to Azure
az login

# Set your subscription (replace with your subscription ID)
$subscriptionId = "<your-subscription-id>"
az account set --subscription $subscriptionId

# List all function apps in the subscription
$functionApps = az functionapp list --query "[].{name:name, resourceGroup:resourceGroup}" --output tsv

Write-Output "Function Apps using in-process model for .NET:"
Write-Output "--------------------------------------------"

# Loop through each function app
$functionApps | ForEach-Object {
    $name, $resourceGroup = $_ -split "`t"

    # Get the app settings for the function app
    $appSettings = az functionapp config appsettings list --name $name --resource-group $resourceGroup --query "[?name=='FUNCTIONS_WORKER_RUNTIME' || name=='FUNCTIONS_EXTENSION_VERSION']" | ConvertFrom-Json

    # Check if the function app is using the in-process model
    $isInProcess = $appSettings | Where-Object { $_.name -eq 'FUNCTIONS_WORKER_RUNTIME' -and $_.value -eq 'dotnet' }

    if ($isInProcess) {
        Write-Output "Function App Name: $name, Resource Group: $resourceGroup"
    }
}

To run this script:

  1. Open PowerShell on your Windows machine.
  2. Copy and paste the script into the PowerShell window (or save it as a .ps1 file and run it).
  3. Replace <your-subscription-id> with your actual Azure subscription ID.

This script will list all function apps that are using the in-process model for .NET, helping you identify which ones need to be migrated to the isolated worker model.

If you prefer a DOS batch script, it’s a bit more complex due to the limitations of batch scripting, but here’s an attempt to do something similar using basic batch commands and PowerShell for processing:

batchCopy code@echo off

REM Log in to Azure (this will open a browser for authentication)
az login

REM Set your subscription (replace with your subscription ID)
set SUBSCRIPTION_ID=<your-subscription-id>
az account set --subscription %SUBSCRIPTION_ID%

REM List all function apps in the subscription and save to a temporary file
az functionapp list --query "[].{name:name, resourceGroup:resourceGroup}" --output tsv > functionapps.txt

echo Function Apps using in-process model for .NET:
echo --------------------------------------------

REM Loop through each function app
for /F "tokens=1,2" %%A in (functionapps.txt) do (
    set NAME=%%A
    set RESOURCE_GROUP=%%B

    REM Get the app settings for the function app and save to a temporary file
    az functionapp config appsettings list --name %NAME% --resource-group %RESOURCE_GROUP% --query "[?name=='FUNCTIONS_WORKER_RUNTIME' || name=='FUNCTIONS_EXTENSION_VERSION']" --output json > appsettings.json

    REM Use PowerShell to check if the function app is using the in-process model
    powershell -Command "
        $appSettings = Get-Content 'appsettings.json' | ConvertFrom-Json;
        $isInProcess = $appSettings | Where-Object { $_.name -eq 'FUNCTIONS_WORKER_RUNTIME' -and $_.value -eq 'dotnet' };
        if ($isInProcess) { Write-Output 'Function App Name: %NAME%, Resource Group: %RESOURCE_GROUP%' }
    "
)

REM Clean up temporary files
del functionapps.txt
del appsettings.json

To run this batch script:

  1. Open a text editor and copy the script into it.
  2. Save the file with a .bat extension, for example, checkFunctionApps.bat.
  3. Run the batch file from the command prompt.

This script uses az commands to log in, set the subscription, and list the function apps. It then checks each app’s settings using PowerShell to determine if it is using the in-process model for .NET.