Azure / Azure/azure-powershell

`Az.Resources` v6.6.1 fails to import to Azure Automation Account with PowerShell v5.1

Open
#21,647 77 comments 0 reactions 1 assignee Claimed by @wyunchi-ms View on GitHub
ADO bug customer-reported Tracking
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

Edit 2025-02-23:

* PowerShell v7.4 is available inside Automation Account -> Runbook Environments, even though it's not announced yet.
*
*

---

Edit 2024-01-03:

* [PowerShell 7.2 is GA in Automation Account](https://azure.microsoft.com/en-us/updates/azure-automation-powershell7-2-general-availability/) and works great with the newest Az modules.
* If still using 5.1: See [temp workaround](https://github.com/Azure/azure-powershell/issues/21647#issuecomment-1521820690) if you are affected.

---

### Description

Tried three times to import `Az.Resources` v6.6.1 to an Azure Automation Account, but it fails.

I imported/updated `Az.Accounts` to v2.12.2 prior to this.

This is using the built in "Browse gallery" method.

![image](https://user-images.githubusercontent.com/6450056/234285492-4e4f41a9-b556-43f5-998a-dd55673c6741.png)

### Issue script & Debug output

```PowerShell
None.
```

### Environment data

```PowerShell
5.1 in Azure Automation Account
```

### Module versions

```PowerShell
Az.Accounts v2.12.2
Az.Resources v6.6.1
```

### Error output

> Error importing the module Az.Resources. Import failed with the following error: Orchestrator.Shared.AsyncModuleImport.ModuleImportException: An error occurred when trying to import the module to an internal PowerShell session. Either the module dependencies are not imported correctly or the module is unsupported. Internal Error Message: The type initializer for 'Microsoft.Azure.Commands.Common.AzModule' threw an exception. The type initializer for 'Microsoft.Azure.Commands.Common.AzModule' threw an exception. . at Orchestrator.Activities.SetModuleVersion.GetPsModuleVersion(String moduleName, String moduleFullPath, Guid accountId, Guid moduleVersionId, InitialSessionState defaultSessionState) at Orchestrator.Activities.SetModuleVersion.InsertModuleVersion(String moduleName, ModuleLanguage moduleLanguage, String pythonModuleVersion, String moduleFullyQualifiedName, ActivitiesMetadataWorkflowExtension activitiesMetadataWorkflowExtension, Guid accountId, Guid moduleVersionId, Int64 moduleContentByteSize, ContentUriInfo contentUri, String storageUri, Int32 moduleVersion) 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)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.