Description
With version 5.8 I could install the CLI on an Azure PowerShell Function and run it successfully.
Since a recent version this now throws an error: Access Denied / System.Management.Automation.RemoteException exception.
I have an inkling this has to do with the CLI trying to access the file system. In 5.9 Shell tracking was introduced, for which the file system is used as a cache: #3769
The file system on an Azure Function cannot just be accessed in any place. The wwwroot should be okay though.

CLI for Microsoft 365 version
6.1
nodejs version
16
Operating system (environment)
Windows / Azure Function
Shell
PowerShell
Steps to reproduce:
- Create an Azure Function / PowerShell / Windows based
- Open Kudu
- navigate to wwwroot
- Install CLI LOCALLY(!)
npm install @pnp/cli-microsoft365@next
- Wait 20 minutes until its installed
- Open the App Service Editor
- Add the following lines to profile.ps1:
Write-Host "Setting up m365 in PATH variable"
Write-Host "Current Path: $($Env:Path)"
$functionPath = "$PWD\node_modules\.bin"
if ($Env:PATH.Contains($functionPath) -eq $false) {
[System.Environment]::SetEnvironmentVariable('PATH',$Env:PATH + ";$functionPath")
}
Write-Host "Changed Path: $($Env:Path)"
This is to ensure the locally installed cli can be reached from the path
- Create a TimerTrigger and add
m365 version in the code.
- Run the TimerTrigger
Description
With version 5.8 I could install the CLI on an Azure PowerShell Function and run it successfully.
Since a recent version this now throws an error:
Access Denied/System.Management.Automation.RemoteExceptionexception.I have an inkling this has to do with the CLI trying to access the file system. In 5.9 Shell tracking was introduced, for which the file system is used as a cache: #3769
The file system on an Azure Function cannot just be accessed in any place. The wwwroot should be okay though.
CLI for Microsoft 365 version
6.1
nodejs version
16
Operating system (environment)
Windows / Azure Function
Shell
PowerShell
Steps to reproduce:
npm install @pnp/cli-microsoft365@nextThis is to ensure the locally installed cli can be reached from the path
m365 versionin the code.