Doug Finke
Doug Finke

Reputation: 6823

How to share a Powershell psm1 across Azure Functions

You can create a modules folder and place a psm1 file there for auto loading. Is there a way to share that psm1 across functions in the same App Service?

Upvotes: 2

Views: 214

Answers (1)

Ling Toh
Ling Toh

Reputation: 2474

Yes, you may move your modules folder up the directory tree and place it under wwwroot, e.g. D:\home\site\wwwroot\mymodules. Auto-loading will not occur in this setup, so you will need to explicitly add the Import-Module command in your PowerShell script, e.g.

Import-Module "D:\home\site\wwwroot\mymodules\MyScript.psm1";

If you suspect that MyScript.psm1 is already installed on the system and need to override it with your version, add the -Global flag as follows

Import-Module "D:\home\site\wwwroot\mymodules\MyScript.psm1" -Global;

Upvotes: 2

Related Questions