Skip to content

Error when executing Automation Runbook using Workflow: Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified. #21129

Open
@kvsrkrishnan

Description

@kvsrkrishnan

Description

Error when executing Automation Runbook using Workflow

Trying to test a runbook using workflows (and ForEach -Parallel) targeting PowerShell Module 5.1 and I can't seem to get past the above mentioned error:

Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.

Steps to reproduce

Here is my script (automation name and RG name masked & I am passing the $RunbookName as parameter):

Workflow Test-Runbook
{
    Param(
        [string]$RunBookName
    )
    ForEach -Parallel -throttle 3 ($VM in $VMs)
    {
        $job = Start-AzAutomationRunbook `
            -AutomationAccountName "automationaccountname" `
            -Name $RunBookName -ResourceGroupName "resourcegroupname"
        Start-Sleep -s 3 
    }
}
Test-Runbook -RunBookName $RunBookName  | Write-Output

I would like to note that I was able to execute the runbook within a function. My requirement is to execute a Foreach loop with Parallel which requires Workflow.

Related documentation:

Expected behavior

Be able to execute the workflow successfully.

Actual behavior

`Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.`

More info based on `Resolve-AzError`:

InnerException   : False
Exception        : System.Management.Automation.RemoteException: Could not load file or assembly 'Newtonsoft.Json, 
                   Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The 
                   system cannot find the file specified.
                      at Microsoft.PowerShell.Activities.PSActivity.OnResumeBookmark(NativeActivityContext context, 
                   Bookmark bookmark, Object value)
                      at System.Activities.Runtime.BookmarkWorkItem.Execute(ActivityExecutor executor, BookmarkManager 
                   bookmarkManager)
Message          : Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, 
                   PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file 
                   specified.
StackTrace       :    at Microsoft.PowerShell.Activities.PSActivity.OnResumeBookmark(NativeActivityContext context, 
                   Bookmark bookmark, Object value)
                      at System.Activities.Runtime.BookmarkWorkItem.Execute(ActivityExecutor executor, BookmarkManager 
                   bookmarkManager)
HelpLink         : 
ErrorDetails     : 
ErrorCategory    : NotSpecified: (:) [Write-Error], RemoteException
InvocationInfo   : System.Management.Automation.InvocationInfo
ScriptStackTrace : 

Related documentation:



### Error details

```console
System.Management.Automation.CommandNotFoundException: The term 'Get-Error' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
   at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
   at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
   at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)

Environment data

Name                           Value                                                                                    
----                           -----                                                                                    
PSVersion                      5.1.15063.726                                                                            
PSEdition                      Desktop                                                                                  
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                  
BuildVersion                   10.0.15063.726                                                                           
CLRVersion                     4.0.30319.42000                                                                          
WSManStackVersion              3.0                                                                                      
PSRemotingProtocolVersion      2.3                                                                                      
SerializationVersion           1.1.0.1

Visuals

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions