azure-functions-powershell-worker
azure-functions-powershell-worker copied to clipboard
using module shows error in vscode, but works when debugging locally
I have a module in the Module folder at the root path of my Azure Functions App. Locally, to get these to import, I have to use the full path or a relative path. No problems there. When I debug it locally and call my function, it doesn't load it.
Since these modules are added to $env:PSModulePath at runtime, I can just say using module ModuleName and it works when I call the funciton, but VSCode highlights the line with the squiggly red underlines.
It should be able to do something similar, but I haven't found a solution. I tried the profile.ps1, but no dice.
Thanks for reporting the issue. Yes, the module path is currently a gap in the developer experience. There needs to be a way to update the module path of the integrated powershell console when working with a PS Azure function app. Maybe powershell extension should start a new integrated PS console with the updated module path in that case.
/cc @TylerLeonhardt
The solution here is to do one of two things:
Install-Module/Update-ModuleandSave-Moduleso that you have the module in both yourPSModulePathand your local function app directory- Add the local function app
Modulesdirectory to process-levelPSModulePath
Realistically, we need something like a venv for PowerShell that gives you a "Functions dev environment" once you enter a function app directory (e.g. Enter/Exit-FuncEnvironment) where you have the special types (e.g. HttpResponseContext), your PSModulePath gets the local Modules directory, and maybe modify your prompt to denote that you're in a session of some kind.
Then, we could modify the VS Code extension to automatically enter that session when you open a workspace that's detected as a function app.
/cc @Francisco-Gamino this would likely serve as the "helper module" we discussed before
Will document this and also look to add to the VS Code extension.