Jump to content

Steps to Manually Add PowerShell Modules in Function App


Recommended Posts

Guest Raven_Zhang
Posted

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:

 

 

 

[iCODE]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' }[/iCODE]

 

 

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".

 

 

 


  1. Find and download modules from PowerShell Gallery to your local system. You should choose "manual download" and download the .nupkg files of the modules.
     
    mediumvv2px400.png.288863054c70f15b56cbbf0fb65a4dc7.png

  2. Unzip the .nupkg files and rename the folder to the module official name without the version number.
     
    mediumvv2px400.png.6a6a72a2015923654eb12cc091343b79.png

  3. Open "App Service Editor" and create a new folder with name "Modules" under "wwwroot" folder.
     
    mediumvv2px400.png.9d039b03ebfe35113ff0731009f5b0d9.pngmediumvv2px400.png.5a07df31ae29af62a75a7c62636649bd.png

  4. Go to SCM site of the Function App and navigate to "C:\home\site\wwwroot\Modules" path on the file system.
     
    mediumvv2px400.png.c17c5fd3b1b25005e26e4db436d0dfff.pngmediumvv2px400.png.f14a95daba4dd5d9deabd3b90658d768.png

  5. Drag and drop the module package that you have downloaded before to the "Modules" folder on the SCM site.
     
     

  6. Go to "App Files", modify the "requirements.psd1" as the following, with the corresponding version number of the module:
     
    mediumvv2px400.png.3eee4d9fecfa893e26d89295b1376bb7.png

  7. In "host.json file", verify the managedDependency setting has a value of "Enabled" and is set to "False".
     
    mediumvv2px400.png.f16d45ce9eac772b5a52ca2eebb08fd4.png

  8. 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.

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...