-
Notifications
You must be signed in to change notification settings - Fork 490
Closed
Labels
bugThis issue is a bug.This issue is a bug.module/custom-runtimep2This is a standard priority issueThis is a standard priority issuequeued
Description
Description
AWS PowerShell Lambda does not currently permit the use of any cmdlets/functions from an Azure Az module.
Expectation
#Requires -Modules @{ModuleName='Az.Accounts';ModuleVersion='2.7.2'}
With an Az module added to a PowerShell Lambda - the module should be able to be successfully imported and functions engaged.
Actual Behavior
Importing module ./Modules/Az.Accounts/2.7.2/Az.Accounts.psd1
[Error] - Value cannot be null. (Parameter 'path1')
Reproduction Steps
- Add any Azure Az module to required modules for PowerShell Lambda:
#Requires -Modules @{ModuleName='Az.Accounts';ModuleVersion='2.7.2'}
- Deploy Lambda
- Attempt to run Lambda and observe import of Az module
Logs
When adding the Az module to the #Requires
:
An exception was thrown when the constructor for type 'AzModuleProcessor.Bootstrap' was invoked. Check inner exception for more details.: LambdaException
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
Value cannot be null. (Parameter 'path1'): ArgumentNullException
at Amazon.Lambda.PowerShellHost.PowerShellFunctionHost..ctor()
at Amazon.Lambda.PowerShellHost.PowerShellFunctionHost..ctor(String powerShellScriptFileName)
at AzModuleProcessor.Bootstrap..ctor() in /tmp/LambdaStaging/AzModuleProcessor/Bootstrap.cs:line 9
Importing module ./Modules/Az.Accounts/2.7.2/Az.Accounts.psd1
[Error] - Value cannot be null. (Parameter 'path1')
As a troubleshooting step I also attempted the following from within the Lambda logic code:
- Use
Save-Module
and download an Az module directly from the PSGallery. - Perform a manual import within the Lambda using
Import-Module
. This also does not work and results in the following log entries:
2022-02-23T07:45:36.799-06:00 [Warning] - An error was encountered importing: Az.Accounts
2022-02-23T07:45:36.802-06:00 [Error] - Cannot bind argument to parameter 'Path' because it is an empty string.
Environment
- Build Version:
7.0.8
- OS Info: AWS PowerShell Lambda
- Targeted .NET Platform:
dotnetcore3.1
Lambda
Resolution
I think the issue is something with the System.IO.IsolatedStorage
as that's the only place I see the "Path1" parameter.
Additional mentions of this issue
- Can't import AZ.Resources in AWS Lambda - Azure/azure-powershell
- Cannot import Azure AZ Modules into PS Script under AWS Lambda .NetCore - StackOverFlow
This is a 🐛 bug-report
Metadata
Metadata
Assignees
Labels
bugThis issue is a bug.This issue is a bug.module/custom-runtimep2This is a standard priority issueThis is a standard priority issuequeued