PowerShell Function App is failing to import Microsoft.PowerApps.Administration.PowerShell Module

Mayank Gupta 1 Reputation point

I am trying to import the "Microsoft.PowerApps.Administration.PowerShell" module in my PowerShell Azure Function App. The import is successful but the following command in my "run.ps1" file is throwing an error:

Add-PowerAppsAccount -Username $username -Password $pass


Following are the contents of function.json:

  "bindings": [
      "authLevel": "function",
      "type": "httpTrigger",
      "direction": "in",
      "name": "Request",
      "methods": [
      "type": "http",
      "direction": "out",
      "name": "Response"

Following are the contents of host.json:

  "version": "2.0",
  "managedDependency": {
    "Enabled": true
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[3.*, 4.0.0)"

The error was pretty big so I have mentioned it in the attached file (Error.txt)

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,382 questions
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,161 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Limitless Technology 44,001 Reputation points

    Hello there,

    The workaround is to update the runtime version to by updating the FUNCTION_EXTENSION_VERSION in the application configuration of your function app if you are running PowerShell function version 7.

    You can find similar discussion here


    Hope this resolves your Query !!

    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments

  2. MuthuKumaranMurugaachari-MSFT 22,236 Reputation points

    Mayank Gupta Thanks for posting your question in Microsoft Q&A. Based on the description above and the error details, I assume you have added the module in requirements.psd1 as shown below and used FUNCTIONS_WORKER_RUNTIME_VERSION as 7.2 or greater.

        'Microsoft.PowerApps.Administration.PowerShell' = '2.0.156'

    When I test the code, I got the same error as you observed. User's image

    You need to include -UseWindowsPowershell while importing the older modules and more details are discussed in this thread: Validate PS7 Import-Module -UseWindowsPowerShell in Azure Functions cloud environment. This should mitigate the issue and let me know if you face any issues.

    Import-Module -Name Microsoft.PowerApps.Administration.PowerShell -UseWindowsPowershell

    If you found the answer to your question helpful, please take a moment to mark it as "Yes" for others to benefit from your experience. Or simply add a comment tagging me and would be happy to answer your questions.

    0 comments No comments