Azure / Azure/azure-functions-powershell-worker

Azure Function Parser doesn't take dependent modules into consideration

Open
#800 5 comments 0 reactions 1 assignee Claimed by @Francisco-Gamino View on GitHub
investigation P2
Dominant language
C#
Stars
215
Forks
61
Avg merge
21h 4m
Merged PRs (30d)
6

Description

If I have a module that implements a custom enum, I cannot use that enum in my run.ps1 even if I have `#requires -module myCustomModule defined`. This is because the function info AST parser does not load these modules/types prior to parse in the runspace.

https://github.com/Azure/azure-functions-powershell-worker/blob/c77e1b705b4c8cd4bb37d508dba7bbb9c6bfbd44/src/FunctionInfo.cs#L163

```
[2022-04-20T14:56:29.713Z] Worker failed to load function: 'PushHttpOutputBindingDemo' with function id: '8f898310-1762-403a-9c7c-7fe3970da7cd'.
[2022-04-20T14:56:29.716Z] Result: Failure
Exception: The script file 'C:\Users\JGrote\Projects\AzureFunctionsMissingManual\FunctionApp\PushHttpOutputBindingDemo\run.ps1' has parsing errors:
Attribute argument must be a constant or a script block.
[2022-04-20T14:56:29.719Z]
Stack: at Microsoft.Azure.Functions.PowerShellWorker.AzFunctionInfo.GetParameters(String scriptFile, String entryPoint, ScriptBlockAst& scriptAst) in /home/vsts/work/1/s/src/FunctionInfo.cs:line 186
[2022-04-20T14:56:29.722Z] at Microsoft.Azure.Functions.PowerShellWorker.AzFunctionInfo..ctor(RpcFunctionMetadata metadata) in /home/vsts/work/1/s/src/FunctionInfo.cs:line 73
[2022-04-20T14:56:29.725Z] at Microsoft.Azure.Functions.PowerShellWorker.FunctionLoader.LoadFunction(FunctionLoadRequest request) in /home/vsts/work/1/s/src/FunctionLoader.cs:line 52
[2022-04-20T14:56:29.727Z] at Microsoft.Azure.Functions.PowerShellWorker.RequestProcessor.ProcessFunctionLoadRequest(StreamingMessage request) in /home/vsts/work/1/s/src/RequestProcessor.cs:line 223.
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.