PowerShell is a powerful scripting language that can be run in an Azure Function Apps. However, working with PowerShell in this environment often requires adding custom modules and enabling command-line tools (CLI). In this post, I’ll walk through multiple approaches for adding PowerShell modules and several ways to integrate CLI tools into your Function App. Before adding any module, it’s important to check whether it’s already loaded and confirm that it’s compatible with the version of PowerShell your Function App uses. By the end, you’ll have practical options to choose from based on your scenario.
How to check if a module is available
To check if a specific module is available run the Get-Module command. For example for the Microsoft PowerApps Administration PowerShell module.
Get-Module -Name Microsoft.PowerApps.Administration.PowerShell -ListAvailable
How to check if CLI is available
You can verify PAC CLI availability by checking its path or running its version command:
& "c:/home/site/wwwroot/Modules/paccli/tools/pac.exe" --version
$pacPath = "c:/home/site/wwwroot/Modules/paccli/tools/pac.exe"
if (Test-Path $pacPath) {
Write-Host "PAC CLI is installed at $pacPath"
} else {
Write-Host "PAC CLI is NOT installed"
}
Get-Command pac.exe -ErrorAction SilentlyContinue
How to install CLI
You can install the CLI by running the script below directly in your Function App, or run it locally and then manually upload the extracted CLI folder to the Function App’s file system. For better organization, I recommend placing the CLI inside the Modules folder.
# Download PAC CLI NuGet package only needed once. You can also do this locally and manual place the PAC CLI files on the function apps file drive
Invoke-WebRequest -Uri "https://www.nuget.org/api/v2/package/Microsoft.PowerApps.CLI/1.50.1" -OutFile "paccli.nupkg"
# Extract NuGet package. You can also do this locally and manual place the PAC CLI files on the function apps file drive
Expand-Archive -Path "paccli.nupkg" -DestinationPath "c:/home/site/wwwroot/Modules/paccli"
How to install the Microsoft crmsdk coretools
- Download the latest Microsoft.crmsdk.coretools version.
- Rename the extension from nupkg to zip.
- Unpack the zip.
- Upload the Microsoft.crmsdk.coretools folder to the Function Apps drive.
How to install a module
Before installing any modules, make sure they aren’t already available in your Function App. You can either install the modules locally and upload the module folder to the Function App’s file system, or configure the Function App to install them automatically by updating the requirements.psd1 and host.json files.
- Make sure that in the host.json file (c:\home\site\wwwroot\host.json) managedDependency is set to Enable true.
- I included my whole host.json file to demonstrate where to place the code.
{
"version": "2.0",
"isDefaultHostConfig": true,
"managedDependency": {
"Enabled": true
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
}
}
- Open the requirements.psd1 file, or create a new one if it doesn’t exist.
- Add the modules that need to be installed inside the @{ }.
- In my example below, the modules are commented out, so they won’t be installed.
- Restart your Function App to begin the installation process. This step can take several minutes to complete.
# This file enables modules to be automatically managed by the Functions service.
# See https://aka.ms/functionsmanageddependency for additional information.
#
@{
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
# To use the Az module in your function app, please uncomment the line below.
#'Az.Accounts' = '2.*'
#'Microsoft.PowerApps.Administration.PowerShell' = '1.*'
#'Microsoft.PowerApps.PowerShell' = '1.*'
}
- After the installation is done, make sure to import the installed modules.
Import-Module "c:/home/site/wwwroot/Modules/Microsoft.PowerApps.Administration.PowerShell/2.0.216/Microsoft.PowerApps.Administration.PowerShell.psd1" -Verbose
Import-Module "c:/home/site/wwwroot/Modules/Microsoft.PowerApps.PowerShell/1.0.45/Microsoft.PowerApps.PowerShell.psd1" -Verbose
How to upload file to the Function Apps drive
Each Windows-based Function App includes a file system where you can store files. You can access this file system through your browser using Kudu, available under the Advanced Tools settings.
- Open your Function App and look for Advanced Tools or Kudu in the menu.
- Click on Advanced Tools, then click on Go.
- A new tab will open with the advanced Kudu tools.
- Click on Debug console, then choose either CMD or PowerShell.

- Navigate to the folder where you want to upload files. I most cases, this will be the C:\home\sites\wwwroot folder.
- Drag and drop the files you want to upload into the selected folder


















































