Azure / Azure/azure-rest-api-specs
import automation module sometimes fails
- Dominant language
- TypeSpec
- Stars
- 3.1k
- Forks
- 5.9k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 444
Description
creating automation module using following script sometimes fails
```
resource azurerm_automation_module az_resources {
name = "Az.Resources"
resource_group_name = azurerm_resource_group.test.name
automation_account_name = azurerm_automation_account.test.name
module_link {
uri = "https://www.powershellgallery.com/api/v2/package/Az.Resources/1.11.0"
}
}
```
this is the server error message:
```
Orchestrator.Shared.AsyncModuleImport.ModuleImportException: An error occurred during module validation. When importing the module to an internal PowerShell session, it was not able to be loaded by PowerShell. There is likely an issue with the contents of the module that results in PowerShell's not being able to load it. Please verify that the module imports successfully in a local PowerShell session, correct any issues, and then try importing again.
Internal error message: The specified module 'Az.Accounts' with version '1.7.2' was not loaded because no valid module file was found in any module directory.
Could not load file or assembly 'Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.Azure.PowerShell.Clients.ResourceManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
.
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)
```
I think there may be some problem with this module link, but there is no reason that sometimes it's success and sometimes it failed
https://github.com/terraform-providers/terraform-provider-azurerm/issues/7540
Contributor guide
Research direction
Start by reproducing the provided azurerm_automation_module configuration and its module_link URI, then compare successful and failed imports using the reported Az.Resources and Az.Accounts errors. Done means establishing whether the failure is in the package, dependency loading, or Azure Automation import path and documenting a reliable reproduction or actionable resolution.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell, terraform
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100