Forum Discussion
rblocker
Mar 04, 2025Copper Contributor
Function 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 t...
Kidd_Ip
Mar 05, 2025MVP
Would suggest taking a look at below area:
- Managed Dependency Download Issue:
- The warning about the managed dependency download suggests that the required modules (like Az) might not have been downloaded successfully. This could be due to network restrictions or a temporary issue with the Azure Functions service.
- Solution: Ensure that your function app has access to the internet and that there are no firewall rules blocking the download. You can also try manually installing the required modules locally and deploying them with your function app.
- Version Compatibility:
- You've updated the host.json and requirements.psd1 files to use newer versions, but there might still be compatibility issues with the Az module or the specific cmdlet Get-AzWvdUserSession.
- Solution: Verify that the Az module version 13.* includes the Get-AzWvdUserSession cmdlet. If not, you might need to install a specific version of the Az module that supports this cmdlet.
- Cmdlet Recognition Issue:
- The error indicates that the Get-AzWvdUserSession cmdlet is not recognized. This could happen if the module containing this cmdlet is not loaded properly.
- Solution: Add an explicit Import-Module Az.DesktopVirtualization statement in your script to ensure the required module is loaded.
- Function App Restart:
- Restarting the function app was a good step, but sometimes a full redeployment is necessary to ensure all changes are applied.
- Solution: Redeploy your function app after making the changes to host.json and requirements.psd1.
- Debugging Locally:
- To isolate the issue, you can try running the script locally in a PowerShell session with the same Az module version. This can help identify if the problem is with the function app environment or the script itself.