Function App
1 TopicFunction app script stopped working
I have a simple function app that uses this script to shut down inactive AVD VMs that had worked for about two years simply stopped working. Instead, it produce this error: ERROR: Error stopping the VM: GenericArguments[0], 'Microsoft.Azure.Management.Compute.Models.VirtualMachine', on 'System.Nullable`1[T] MaxInteger[T](System.Collections.Generic.IEnumerable`1[System.Nullable`1[T]])' violates the constraint of type 'T'. After much troubleshooting and searching for something relevant, I discovered that the function app's host.json file was set to: { "version":"2.0", "managedDependency": { "Enabled": true }, "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[2.*, 3.0.0]" } } Since v.2 and v.3 are [no longer supported](http://learn.microsoft.com/en-us/azure/azure-functions/functions-versions?tabs=isolated-process%2Cv4&pivots=programming-language-powershell), I changed it to { "version":"2.0", "managedDependency": { "Enabled": true }, "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[4.0.0, 5.0.0]" } } ``` I also noticed that the `requirements.psd1` file was set to # This file enables modules to be automatically managed by the Functions service. # See https://aka.ms/functionsmanageddependency for additional information. # @{ # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. # To use the Az module in your function app, please uncomment the line below. 'Az' = '8.*' } So I changed it to # This file enables modules to be automatically managed by the Functions service. # See https://aka.ms/functionsmanageddependency for additional information. # @{ # For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'. # To use the Az module in your function app, please uncomment the line below. 'Az' = '13.*' } None of this helped. The same error was generated. I then realized I might need to restart the app, which I did. After this, I see this warning and error: 2025-03-03T21:42:45Z [Warning] The first managed dependency download is in progress, function execution will continue when it's done. Depending on the content of requirements.psd1, this can take a few minutes. Subsequent function executions will not block and updates will be performed in the background. 2025-03-03T21:42:45Z [Error] Executed 'Functions.TwelveMinuteTimerTrigger' (Failed, Id=58b46678-c1d2-4ca8-8083-fab1e657c608, Duration=95ms) After waiting a while for the download to finish, I get this error: [Error] ERROR: Error getting a list of user sessions: The term 'Get-AzWvdUserSession' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. The line "Get-AzWvdUserSession is not recognized" seems to indicate that the download of the Az modules has failed. Does anyone know what would cause the download to fail and how to fix it?23Views0likes1Comment