Deploying MSonline powershell module in Azure function

Krish Venkatraman 1 Reputation point
2020-07-27T18:44:51.757+00:00

Hi,

I created a Azure function and now want to deploy the MSOnline PowerShell module, So I can connect to O365 and execute some PowerShell scripts. I have a automation platform where I am calling Azure functions to run some PowerShell stuffs which are not supported by Graph API's. I tried to open up my PowerShell console inside my functions and install nuget and it is not working.

PS D:\home\site\wwwroot>Install-Package nuget -force -scope CurrentUser Install-Package : No match was found for the specified search criteria and package name 'nuget'. Try Get-PackageSource to see all available registered package sources. At line:1 char:1 + Install-Package nuget -force -scope CurrentUser + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Microsoft.Power....InstallPacka ge:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.Pac kageManagement.Cmdlets.InstallPackage

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,327 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,591 Reputation points Microsoft Employee
    2020-07-28T02:59:19.803+00:00

    Azure Functions now includes PowerShell Core 7, which includes support for loading older modules like AzureAD by running Import-Module AzureAD -UseWindowsPowerShell. Refer to this thread that validates this.

    And if your function app still uses version 6, refer to this comment for changing the runtime version to 7.

    0 comments No comments