Azure Automation Account adding Microsoft.Graph module failed

cthivierge 3,976 Reputation points
2022-08-11T14:19:43.587+00:00

Hi,

we are deploying Azure Automation Account using Azure pipelines and it work well. But when we try to add Microsoft.Graph module using ARM templates, it fail every time with the following error.

Error importing the module Microsoft.Graph. Import failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: While importing the module, an error occurred while processing the module content. Internal error message: Function Update-MgShareListContentTypeColumnLink cannot be created because function capacity 4096 has been exceeded for this scope.. at Orchestrator.Activities.SetModuleVersion.ExecuteInternal(CodeActivityContext context, String moduleName, ModuleLanguage moduleLanguage, String pythonModuleVersion, String modulePath, Guid accountId, Guid moduleVersionId, Int64 moduleContentByteSize, String storageUri, Int32 moduleVersion) at Orchestrator.Activities.SetModuleVersion.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

I have tried using Azure hosted VM as well as our self hosted VM's but it fail with the same error.

I did another test and instead of importing the Microsoft.Graph module using a ARM template, i used a inline script

New-AzAutomationModule -name Microsoft.Graph -AutomationAccountName $AutAccount.Name -ResourceGroupName $(resourceGroupName) -ContentLink https://www.powershellgallery.com/api/v2/package/Microsoft.Graph/1.11.0

But it still fail with the same error message.

Any help will be appreciated

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
755 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Ryan Hill 16,621 Reputation points Microsoft Employee
    2022-08-15T19:27:38.19+00:00

    @cthivierge came across https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/1449. Appears this is a PowerShell 5.1 limitation but there are some proposed workarounds.

    • Use PowerShell 7+
    • Only load the Microsoft.Graph modules you template needs
    • Set $maximumfunctioncount to its max value of 32768.

    Let me know down below either way if all, any, or none of the workarounds worked.

    ---
    EDIT 2022 September 14 These are the only workarounds that are available. Microsoft.Graph has ~7k unique API paths which is why you're hitting that error. All the commands simply can't fit into PowerShell 5.1. For Automation Accounts, change the runtime to 7+.


  2. cthivierge 3,976 Reputation points
    2022-08-16T12:51:06.63+00:00

    I just did a test using Powershell to update all Microsft.Graph modules.
    All of them work well from 1.9.6 to 1.11.0 except for "Microsoft.Graph". It fail with the same error:

    Error importing the module Microsoft.Graph. Import failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: While importing the module, an error occurred while processing the module content. Internal error message: Function Update-MgShareListContentTypeColumnLink cannot be created because function capacity 4096 has been exceeded for this scope.. at Orchestrator.Activities.SetModuleVersion.ExecuteInternal(CodeActivityContext context, String moduleName, ModuleLanguage moduleLanguage, String pythonModuleVersion, String modulePath, Guid accountId, Guid moduleVersionId, Int64 moduleContentByteSize, String storageUri, Int32 moduleVersion) at Orchestrator.Activities.SetModuleVersion.Execute(CodeActivityContext context) at System.Activities.CodeActivity.InternalExecute(ActivityInstance instance, ActivityExecutor executor, BookmarkManager bookmarkManager) at System.Activities.Runtime.ActivityExecutor.ExecuteActivityWorkItem.ExecuteBody(ActivityExecutor executor, BookmarkManager bookmarkManager, Location resultLocation)

    and i have added the $maximumfunctioncount = 32768 at the beginning of the Script.

    There should be something that has changed from module version 1.10.0+...

    thanks


  3. Morten Lerudjordet 6 Reputation points
    2022-08-31T16:28:31.42+00:00

    I wrote 2 runbooks to handle module management for AA. It also does dependencies.

    Can either find them under Runbooks and Browse gallery or:
    https://github.com/mortenlerudjordet/Update-PSGalleryModulesInAA
    https://github.com/mortenlerudjordet/Import-PSGalleryModulesToAA