Azure / Azure/azure-powershell
Az.Resources New-AzResourceGroupDeployment could not load file or assembly Newtonsoft.Json Version=10.0.0.0
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 54
Description
## Description
Running New-AzResourceGroupDeployment from within an Azure Automation runbook fails with the following error:
Cannot retrieve the dynamic parameters for the cmdlet. 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
Create an Azure Automation account
Import Az.Resources module into the automation account. In the context where this is failing, I have also needed to import the following additional modules for my scenario:
- Az.Account
- Az.Compute
- Az.KeyVault
- Az.Resources
- Az.Storage
- Az.Monitor
- Az.EventHub
Update modules using the runbook documented here, and with the "Az" parameter specified:
https://docs.microsoft.com/en-us/azure/automation/automation-update-azure-modules
Create an Azure Automation runbook that includes a call to New-AzResourceGroupDeployment and that references a valid template and JSON parameters file.
```powershell
New-AzResourceGroupDeployment `
-Name $depname `
-Verbose `
-ResourceGroupName $using:rg.ResourceGroupName `
-TemplateFile $src_template_path `
-TemplateParameterFile $dst_params_path
```
## Environment data
```
(obtained by executing an Azure Automation runbook containing the $psversiontable command)
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
```
## Module versions
(obtained by executing an Azure Automation runbook with the command: Get-Module -ListAvailable )
```
Directory: C:\Modules\User
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 0.0 AdeTest {Invoke-AdeTestMonitor, Start-AdeTest, New-AdeTestConfig, R...
Script 2.5.2 Az.Accounts {Disable-AzDataCollection, Disable-AzContextAutosave, Enabl...
Script 4.16.0 Az.Compute {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAva...
Script 1.8.0 Az.EventHub {New-AzEventHubNamespace, Get-AzEventHubNamespace, Set-AzEv...
Script 3.4.5 Az.KeyVault {Add-AzKeyVaultCertificate, Update-AzKeyVaultCertificate, S...
Script 2.7.0 Az.Monitor {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile,...
Script 4.3.0 Az.Resources {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRo...
Script 3.10.0 Az.Storage {Get-AzStorageAccount, Get-AzStorageAccountKey, New-AzStora...
Directory: C:\Modules\Global
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.1.0.0 AuditPolicyDsc
The runbook job failed due to a job stream being larger than 1MB, the limit that is supported by an Azure Automation sandbox. See some common ways to resolve this at https://aka.ms/AAjobstreamlimit
Manifest 1.0.3 Azure.Storage {Get-AzureStorageBlob, Get-AzureStorageBlobContent, Get-Azu...
Manifest 1.0.3 AzureRM.Automation {Get-AzureRmAutomationJobOutputRecord, Import-AzureRmAutoma...
Manifest 1.2.1 AzureRM.Compute {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet,...
Manifest 1.0.3 AzureRM.Profile {Enable-AzureRmDataCollection, Disable-AzureRmDataCollectio...
Manifest 1.0.3 AzureRM.Resources {Get-AzureRmADApplication, Get-AzureRmADGroupMember, Get-Az...
Manifest 1.0.3 AzureRM.Sql {Get-AzureRmSqlDatabaseThreatDetectionPolicy, Set-AzureRmSq...
Manifest 1.0.3 AzureRM.Storage {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, G...
Manifest 5.0.0.0 ComputerManagementDsc
Script 0.2 GPRegistryPolicyParser {Parse-PolFile, Read-RegistryPolicies, Create-RegistrySetti...
Script 0.0 Microsoft.PowerShell.Core
Script 0.0 Microsoft.PowerShell.Diagnostics
Script 0.0 Microsoft.PowerShell.Management
Script 0.0 Microsoft.PowerShell.Security
Script 0.0 Microsoft.PowerShell.Utility
Script 0.0 Microsoft.WSMan.Management
Binary 1.0 Orchestrator.AssetManagement.Cmd... {Get-AutomationCertificate, Get-AutomationConnection, Get-S...
Manifest 2.9.0.0 PSDscResources
Manifest 2.1.0.0 SecurityPolicyDsc
Manifest 1.0 StateConfigCompositeResources
Manifest 1.1 xDSCDomainjoin
Manifest 1.1.0.0 xPowerShellExecutionPolicy {Get-TargetResource, Test-TargetResource, Set-TargetResource}
Manifest 1.1.0.0 xRemoteDesktopAdmin
Directory: C:\Program Files\WindowsPowerShell\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Script 1.0.1 Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packag...
Script 3.4.0 Pester {Describe, Context, It, Should...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Set-PSReadlineKeyHandler, Remove...
Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.0 AppBackgroundTask {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgrou...
Manifest 2.0.0.0 Appx {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest,...
Manifest 2.0.0.0 BitsTransfer {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Rem...
Manifest 1.0.0.0 CimCmdlets {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, ...
Manifest 1.0 Defender {Get-MpPreference, Set-MpPreference, Add-MpPreference, Remo...
Manifest 1.0.0.0 DeliveryOptimization {Get-DeliveryOptimizationStatus, Get-DeliveryOptimizationPe...
Manifest 1.0.0.0 DirectAccessClientComponents {Disable-DAManualEntryPointSelection, Enable-DAManualEntryP...
Script 3.0 Dism {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-Windows...
Manifest 1.0.0.0 DnsClient {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-...
Manifest 1.0.0.0 EventTracingManagement {Start-EtwTraceSession, New-EtwTraceSession, Get-EtwTraceSe...
Manifest 2.0.0.0 International {Get-WinDefaultInputMethodOverride, Set-WinDefaultInputMeth...
Manifest 1.0.0.0 iSCSI {Get-IscsiTargetPortal, New-IscsiTargetPortal, Remove-Iscsi...
Script 1.0.0.0 ISE {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}
Manifest 1.0.0.0 Kds {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsCo...
Manifest 1.0.1.0 Microsoft.PowerShell.Archive {Compress-Archive, Expand-Archive}
Manifest 3.0.0.0 Microsoft.PowerShell.Diagnostics {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}
Manifest 3.0.0.0 Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
Manifest 1.0.0.0 Microsoft.PowerShell.LocalAccounts {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser,...
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Script 1.0 Microsoft.PowerShell.ODataUtils Export-ODataEndpointProxy
Manifest 3.0.0.0 Microsoft.PowerShell.Security {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Format-List, Format-Custom, Format-Table, Format-Wide...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSS...
Manifest 1.0 MMAgent {Disable-MMAgent, Enable-MMAgent, Set-MMAgent, Get-MMAgent...}
Manifest 1.0.0.0 MsDtc {New-DtcDiagnosticTransaction, Complete-DtcDiagnosticTransa...
Manifest 2.0.0.0 NetAdapter {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-Net...
Manifest 1.0.0.0 NetConnection {Get-NetConnectionProfile, Set-NetConnectionProfile}
Manifest 1.0.0.0 NetEventPacketCapture {New-NetEventSession, Remove-NetEventSession, Get-NetEventS...
Manifest 2.0.0.0 NetLbfo {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam...
Manifest 1.0.0.0 NetNat {Get-NetNat, Get-NetNatExternalAddress, Get-NetNatStaticMap...
Manifest 2.0.0.0 NetQos {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, N...
Manifest 2.0.0.0 NetSecurity {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsec...
Manifest 1.0.0.0 NetSwitchTeam {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam...
Manifest 1.0.0.0 NetTCPIP {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol,...
Manifest 1.0.0.0 NetworkConnectivityStatus {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset...
Manifest 1.0.0.0 NetworkSwitchManager {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEth...
Manifest 1.0.0.0 NetworkTransition {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfigu...
Manifest 1.0.0.0 PcsvDevice {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Restart...
Manifest 1.0.0.0 PKI {Add-CertificateEnrollmentPolicyServer, Export-Certificate,...
Manifest 1.0.0.0 PnpDevice {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Di...
Manifest 1.1 PrintManagement {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-Print...
Script 3.0 Provisioning {Install-ProvisioningPackage, Export-ProvisioningPackage, I...
Manifest 1.1 PSDesiredStateConfiguration {Set-DscLocalConfigurationManager, Start-DscConfiguration, ...
Script 1.0.0.0 PSDiagnostics {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSM...
Binary 1.1.0.0 PSScheduledJob {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-Job...
Manifest 2.0.0.0 PSWorkflow {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}
Manifest 1.0.0.0 PSWorkflowUtility Invoke-AsWorkflow
Manifest 1.0.0.0 ScheduledTasks {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTa...
Manifest 2.0.0.0 SecureBoot {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBoot...
Manifest 2.0.0.0 SmbShare {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShar...
Manifest 2.0.0.0 SmbWitness {Get-SmbWitnessClient, Move-SmbWitnessClient, gsmbw, msmbw...}
Manifest 1.0.0.0 StartLayout {Export-StartLayout, Import-StartLayout, Export-StartLayout...
Manifest 2.0.0.0 Storage {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-...
Manifest 2.0.0.0 TLS {New-TlsSessionTicketKey, Enable-TlsSessionTicketKey, Disab...
Manifest 1.0.0.0 TroubleshootingPack {Get-TroubleshootingPack, Invoke-TroubleshootingPack}
Manifest 2.0.0.0 TrustedPlatformModule {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm...}
Manifest 2.0.0.0 VpnClient {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection...
Manifest 1.0.0.0 Wdac {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn...}
Manifest 1.0.0.0 WindowsDeveloperLicense {Get-WindowsDeveloperLicense, Unregister-WindowsDeveloperLi...
Script 1.0 WindowsErrorReporting {Enable-WindowsErrorReporting, Disable-WindowsErrorReportin...
Manifest 1.0.0.0 WindowsSearch {Get-WindowsSearchSetting, Set-WindowsSearchSetting}
Manifest 1.0.0.0 WindowsUpdate Get-WindowsUpdateLog
```
## Debug output
```
no additional debug output was observed in portal when running the runbook with this setting added
```
## Error output
```
Cannot retrieve the dynamic parameters for the cmdlet. 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.
```
Contributor guide
Research direction
Start with the New-AzResourceGroupDeployment call in the Azure Automation runbook and the Az.Resources module import process; review the linked module-loading troubleshooting guide first. Reproduce the failure with the listed module versions and inspect how the runbook resolves dependencies. Done means the deployment runs without the Newtonsoft.Json assembly error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100