How To Add Custom Modules to Azure Functions App

You can add the custom modules to your Azure Functions App using the FTP. So basically what we need to do is, We will have to configure one service account using the Azure Portal that will have access to the Azure Function App FTP. Now from the FTP we can able to add the the Custom modules to the Azure Functions App in the path \Site\wwwroot\[Functionname].

How To Add Custom Modules to Azure Functions App

Another option to use external PowerShell Modules inside of your Azure Function App is to use Advanced tools (Kudu) for this purpose. This is one of the best options to use in this case. Let’s follow the below steps

Add Custom Modules to Azure Functions App using Kudu

Navigate to your Azure Function app that you have created to use with PowerShell. Click on the Advanced Tools link under the Development Tools section.

Import PowerShell Module or Package into your Azure Function App

Now click on the Go button on the Advanced Tools window.

How To Add Custom Modules In The Azure Functions App

Select the CMD option from the Debug console DropDown from the top navigation window.

Add Custom Modules In The Azure Functions App

Navigate to the subfolder site/wwwroot/{yourFunctionName}. You can able to see there that two default files run.ps1 and function.json

Click on the Home Button –> Site –> wwroot –> Click on your Function Name

How To Add Custom Modules In The Azure Functions App using Kudu

Now click on the + button –> NewFolder and create a folder with the module name like below

Custom Modules In The Azure Functions App
How To Load Custom Modules From The Azure Functions App

Now you can simply drag and drop the files from your local path to this folder

How To Load Custom Modules From The Azure Functions App using Kudu

Now copy the complete path from the CMD window and keep it as we need to add that in our Import statement

How To Load Custom Modules From The Azure Functions App Kudu

For me, the path is D:\home\site\wwwroot\MyHttpPowerShellFunction\azurerm

Now you need to import the PowerShell module in the Run.ps1 file like below

Import-Module “D:\home\site\wwwroot\MyHttpPowerShellFunction\azurerm\AzureRM.AnalysisServices.psd1”

This is one of the best options to Add Custom Modules In The Azure Functions App.

FAQs

How To Load Custom Modules From The Azure Functions App

Once you upload the Custom Module in the Azure Functions App, then import the custom module in the Run. ps1 file on the Function windows as shown above. The import statement will be like below

Import-Module home\Site\wwwroot\MyHTTPPowerShellFunction\[YourModuleFolderName]\filename.psd1

Wrapping Up

In this article, we discussed, how to add custom modules to Azure Functions App. Thanks for reading this article !!!