How to Install Microsoft.Graph.Applications Powershell Module in Azure Function

user20201 346 Reputation points
2022-12-22T10:23:20.68+00:00

I am trying to install Microsoft.Graph.Applications module in my run.ps1 Azure Function but upon running the line -> Install-Module -Name Microsoft.Graph.Applications i got the below Warning. This is to fix the error " [Error] ERROR: The term 'Get-ScriptCmdlet' is not recognized as a name of a cmdlet, function, script file, or executable program."

[Warning] WARNING: User declined to install module (Microsoft.Graph.Applications).

Can you guide me on how to import that module in Azure Functions? I just know the uncommenting of 'Az' modules in requirements.psd1 and tried as well creating folder in Kudu but still no luck. Thank you.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Arun Siripuram 911 Reputation points
    2022-12-22T17:47:29.563+00:00

    @user20201

    To install the Microsoft.Graph.Applications module in an Azure Function, you can use the Install-Module cmdlet from the PowerShell command line, as you tried. However, it looks like you encountered an error when trying to do this.

    There are a few things you can try to resolve this issue:

    Make sure you have the required permissions to install modules in your Azure Function. If you are not the owner of the Azure Function or do not have the necessary permissions, you will not be able to install modules.

    Make sure that you are using the correct syntax for the Install-Module cmdlet. The correct syntax is Install-Module -Name <module name>.

    Make sure that you are running the Install-Module cmdlet in an elevated PowerShell window. This may be required if you do not have the necessary permissions to install modules.

    If you are still encountering issues after trying the above steps, you can try manually installing the module by downloading it from the PowerShell Gallery and placing it in the correct location in your Azure Function. To do this, you can follow these steps:

    Download the Microsoft.Graph.Applications module from the PowerShell Gallery (https://www.powershellgallery.com/packages/Microsoft.Graph.Applications/).

    Extract the downloaded module to a folder on your local machine.
    In the Kudu console for your Azure Function, navigate to the D:\home\site\wwwroot\Modules directory.

    Upload the extracted module folder to the Modules directory.
    After uploading the module, you should be able to use the Import-Module cmdlet to import it into your Azure Function.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


1 additional answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2022-12-23T04:00:04.06+00:00

    Hi @user20201 ,

    Thanks for reaching out to Q&A forum.

    The ideal way to install powershell module in Azure functions is to use managed dependency. You can specify the module name and version in the requirements.psd1 file.

    Example requirements.psd1,

    @{
    Az = '1.*'
    Microsoft.Graph.Applications = '1.19.0'
    }

    Versions of module : https://www.powershellgallery.com/packages/Microsoft.Graph.Applications/2.0.0-preview2

    You can access the requirements.psd1 file through below steps

    (1) Select Advanced tools in Azure portal
    (2) In the Kudu site, click on Debug console and select cmd
    (3) Navigate to the below file path

    273476-image.png

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.