This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Tech Community.
One wants to install AzureAD and AzureADPreview in his/her windows PowerShell function app. Modules are already input in requirements.psd1, managedDependency is also enabled in host.json. But when executing functions in Azure, error "Could not load file or assembly…" shows up.
Analysis:
The problem is rooted in the compatibility issue between PS7(PowerShell Core 7) and module AzureAD and AzureADPreview.
As of now, the Functions runtime with PowerShell 7 is being rolled out globally. If one wants to check the powershell Core Version, he/she can simply goes to Function Portal --> Configuration --> General settings.
AzureAD works out of the box with Powershell 7! People need to import AzureAD with the -UseWindowsPowershell switch.
Below is the detailed step one can use in order to install AzureAD and AzureADPreview module in Azure Function App.
Step 1: In requirements.psd1, input the two modules with their versions, wildcard is recommend to get the latest version of module;
Step 2: make sure “managedDependency” is set to true in host.json;
Step 3: import module with below syntax:
Results:
Modules will be presented under C:\home\data\ManagedDependencies\xxxxxx.r. One can also invoke methods this module provides in his function code.