Function App lets you leverage PowerShell gallery for managing dependencies. Your PowerShell modules defined in requirements.psd1 file will be downloaded automatically if you enable dependency management. However, if your Function App runs on Consumption plan and the size of dependent modules is too large, chances are the download would fail. During the installation, the modules would be unziped and saved in the "D:\local\Temp", which is the temp storage on the plan worker. Due to the 500 MB limit of temp storage on consumption plan, the installation would fail with not enough space error:
System Log: { Log-Level: Warning; Log-Message: Save-Module('Microsoft.Graph', '2.18.0'): Package 'Microsoft.Graph.Files' failed to be installed because: There is not enough space on the disk. : 'C:\local\Temp\282636592\Microsoft.Graph.Files.2.18.0\bin\Microsoft.Graph.Files.private.dll' }
The easiest workaround is to scale up the function app plan to premium plan, as premium plan has much larger temp file size. However, this is not the most cost-saving option. You can install the module seperately to the app without depending on the dependency management feature either from local deployment or manual installation from the portal. Here I provide the steps with the second option to add the PowerShell modules directly using "Advanced Tools".
-
Find and download modules from PowerShell Gallery to your local system. You should choose "manual download" and download the .nupkg files of the modules.
-
Unzip the .nupkg files and rename the folder to the module official name without the version number.
-
Open "App Service Editor" and create a new folder with name "Modules" under "wwwroot" folder.
-
Go to SCM site of the Function App and navigate to "C:\home\site\wwwroot\Modules" path on the file system.
-
Drag and drop the module package that you have downloaded before to the "Modules" folder on the SCM site.
-
Go to "App Files", modify the "requirements.psd1" as the following, with the corresponding version number of the module:
-
In "host.json file", verify the managedDependency setting has a value of "Enabled" and is set to "False".
-
Restart the app, which is very important.
Now, you have successfully added the PowerShell modules to the Function App running on consumption plan, minus the "not enough space" error.