When creating Azure Functions with PowerShell, several common issues can arise:
1. Path Issues with `$PWD`: In Azure Functions, using `$PWD` can lead to unexpected behavior because it might not always return the expected path. Instead, using `$PSScriptRoot` is recommended for reliable path resolution[1].
2. Concurrency and Performance: Azure Functions on the Consumption Plan can experience concurrency issues, especially with PowerShell functions. This can lead to timeouts and queuing of requests. Adjusting settings like `FUNCTIONS_WORKER_PROCESS_COUNT` and `PSWorkerInProcConcurrencyUpperBound` can help mitigate these issues[3][7].
3. Cold Start: Azure Functions, particularly on the Consumption Plan, experience cold starts, which can delay the execution of your function. This is more pronounced during periods of inactivity[6].
4. Dependency Management: Running `Install-Module` within your function can cause performance issues. It's better to bundle necessary modules using `Save-Module` or `Save-PSResource` before deployment[6].
5. Debugging Challenges: Debugging PowerShell Azure Functions can be cumbersome, and relying solely on app logs may not be sufficient. Creating custom logging solutions, like using a storage table, can be beneficial[7].
6. Serialization Issues: Some objects returned by PowerShell scripts might be unserialized, causing issues when iterating over them. This might require workarounds like calling PowerShell.exe from within your script[5].
Citations:
[1] https://www.blimped.nl/dont-trust-pwd-in-azure-powershell-functions/
[2] https://stackoverflow.com/questions/75194965/azure-functions-powershell-how-to-use-table-input-binding
[3] https://blog.darrenjrobinson.com/powershell-azure-functions-concurrency/
[4] https://docs.azure.cn/en-us/cosmos-db/nosql/troubleshoot-changefeed-functions
[5] https://stackoverflow.com/questions/72227170/powershell-azure-function-fails
[6] https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-powershell
[7] https://www.reddit.com/r/AZURE/comments/1czkfat/is_it_just_me_or_is_azure_functions_extremely/
[8] https://github.com/Azure/Azure-Functions/issues/481