Hi Team,
I have installed tfe module using requirements.psd1 and given in host.json "managedDependency": {
"Enabled": true
},
In requirements.psd1 , it is as below
@{
For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
'Az' = '6.'
tfe = '1.'
Terraform = '1.*'
}
I am able to see my tfe module is installed in my function by running the command "get-module -listavailable -Name tfe"
After this, I am running few commands for creating New-TFEWorkspace.
Where as I am getting error when I trigger this function. Below is the error.
2021-08-11T06:39:15.837 [Information] OUTPUT: ModuleType Version PreRelease Name PSEdition ExportedCommands
2021-08-11T06:39:15.838 [Information] OUTPUT: ---------- ------- ---------- ---- --------- ----------------
2021-08-11T06:39:15.841 [Information] OUTPUT: Script 1.0.2 tfe Desk {Add-TFEContent, Set-TFEWorkspace, Get-T…
2021-08-11T06:39:15.842 [Information] INFORMATION: After Installing module
2021-08-11T06:39:18.713 [Error] ERROR: The 'New-TFEWorkspace' command was found in the module 'tfe', but the module could not be loaded. For more information, run 'Import-Module tfe'.Exception :Type : System.Management.Automation.CommandNotFoundExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : The 'New-TFEWorkspace' command was found in the module 'tfe', but the module could not be loaded. For more information, run 'Import-Module tfe'.HResult : -2146233087TargetObject : New-TFEWorkspaceCategoryInfo : ObjectNotFound: (New-TFEWorkspace:String) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : CouldNotAutoloadMatchingModuleInvocationInfo :ScriptLineNumber : 68OffsetInLine : 21HistoryId : 1ScriptName : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line : $newWorkspace = New-TFEWorkspace -TFEBaseURL $TFEBaseURL -Org $org -WorkspaceName $WorkSpaceName -TerraformVersion $TerraformVersion -AutoApply $bAutoApply -AllowDestroyPlan $bAllowDestroyPlan -Token $secTokenPositionMessage : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:68 char:21+ $newWorkspace = New-TFEWorkspace -TFEBaseURL $TFEBaseURL -Org $or …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\site\wwwroot\HttpTrigger1PSCommandPath : C:\home\site\wwwroot\HttpTrigger1\run.ps1InvocationName : New-TFEWorkspaceCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 68CommandName : New-TFEWorkspaceTargetSite :Name : TryModuleAutoDiscoveryDeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.CommandDiscovery.TryModuleAutoDiscovery(String commandName, ExecutionContext context, String originalCommandName, CommandOrigin commandOrigin, SearchResolutionOptions searchResolutionOptions, CommandTypes commandTypes, Exception& lastError)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable1 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.ActionCallInstruction6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Message : The 'New-TFEWorkspace' command was found in the module 'tfe', but the module could not be loaded. For more information, run 'Import-Module tfe'.Data : System.Collections.ListDictionaryInternalInnerException :Type : System.Management.Automation.CmdletInvocationExceptionErrorRecord :Exception :Type : System.Management.Automation.RuntimeExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Unable to locate tar command. Unable to continue.HResult : -2146233087CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : RuntimeExceptionWasThrownFromThrowStatement : TrueTargetSite :Name : ThrowTerminatingErrorDeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)Message : Unable to locate tar command. Unable to continue.Source : System.Management.AutomationHResult : -2146233087TargetObject : Unable to locate tar command. Unable to continue.CategoryInfo : OperationStopped: (Unable to locate ta…Unable to continue.:String) [Import-Module], RuntimeExceptionFullyQualifiedErrorId : Unable to locate tar command. Unable to continue.,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleHistoryId : 1InvocationName : Import-ModuleCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\210811045631133.r\tfe\1.0.2\tfe.psm1: line 1100at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 68PipelineIterationInfo :TargetSite :Name : InvokeDeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)at System.Management.Automation.Runspaces.Pipeline.Invoke()at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.Invoke[T]()at System.Management.Automation.CommandDiscovery.AutoloadSpecifiedModule(String moduleName, ExecutionContext context, SessionStateEntryVisibility visibility, Exception& exception)Message : Unable to locate tar command. Unable to continue.InnerException :Type : System.Management.Automation.RuntimeExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Unable to locate tar command. Unable to continue.HResult : -2146233087CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : RuntimeExceptionWasThrownFromThrowStatement : TrueTargetSite :Name : ThrowTerminatingErrorDeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)Message : Unable to locate tar command. Unable to continue.Source : System.Management.AutomationHResult : -2146233087Source : System.Management.AutomationHResult : -2146233087Source : System.Management.AutomationHResult : -2146233087TargetObject : New-TFEWorkspaceCategoryInfo : ObjectNotFound: (New-TFEWorkspace:String) [], CommandNotFoundExceptionFullyQualifiedErrorId : CouldNotAutoloadMatchingModuleInvocationInfo :ScriptLineNumber : 68OffsetInLine : 21HistoryId : 1ScriptName : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line : $newWorkspace = New-TFEWorkspace -TFEBaseURL $TFEBaseURL -Org $org -WorkspaceName $WorkSpaceName -TerraformVersion $TerraformVersion -AutoApply $bAutoApply -AllowDestroyPlan $bAllowDestroyPlan -Token $secTokenPositionMessage : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:68 char:21+ $newWorkspace = New-TFEWorkspace -TFEBaseURL $TFEBaseURL -Org $or …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\site\wwwroot\HttpTrigger1PSCommandPath : C:\home\site\wwwroot\HttpTrigger1\run.ps1InvocationName : New-TFEWorkspaceCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 68Microsoft.Azure.WebJobs.Script.Workers.Rpc.RpcException : Result: ERROR: The 'New-TFEWorkspace' command was found in the module 'tfe', but the module could not be loaded. For more information, run 'Import-Module tfe'.Exception :Type : System.Management.Automation.CommandNotFoundExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : The 'New-TFEWorkspace' command was found in the module 'tfe', but the module could not be loaded. For more information, run 'Import-Module tfe'.HResult : -2146233087TargetObject : New-TFEWorkspaceCategoryInfo : ObjectNotFound: (New-TFEWorkspace:String) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : CouldNotAutoloadMatchingModuleInvocationInfo :ScriptLineNumber : 68OffsetInLine : 21HistoryId : 1ScriptName : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line : $newWorkspace = New-TFEWorkspace -TFEBaseURL $TFEBaseURL -Org $org -WorkspaceName $WorkSpaceName -TerraformVersion $TerraformVersion -AutoApply $bAutoApply -AllowDestroyPlan $bAllowDestroyPlan -Token $secTokenPositionMessage : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:68 char:21+ $newWorkspace = New-TFEWorkspace -TFEBaseURL $TFEBaseURL -Org $or …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\site\wwwroot\HttpTrigger1PSCommandPath : C:\home\site\wwwroot\HttpTrigger1\run.ps1InvocationName : New-TFEWorkspaceCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 68CommandName : New-TFEWorkspaceTargetSite :Name : TryModuleAutoDiscoveryDeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.CommandDiscovery.TryModuleAutoDiscovery(String commandName, ExecutionContext context, String originalCommandName, CommandOrigin commandOrigin, SearchResolutionOptions searchResolutionOptions, CommandTypes commandTypes, Exception& lastError)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable1 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.ActionCallInstruction6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)Message : The 'New-TFEWorkspace' command was found in the module 'tfe', but the module could not be loaded. For more information, run 'Import-Module tfe'.Data : System.Collections.ListDictionaryInternalInnerException :Type : System.Management.Automation.CmdletInvocationExceptionErrorRecord :Exception :Type : System.Management.Automation.RuntimeExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Unable to locate tar command. Unable to continue.HResult : -2146233087CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : RuntimeExceptionWasThrownFromThrowStatement : TrueTargetSite :Name : ThrowTerminatingErrorDeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)Message : Unable to locate tar command. Unable to continue.Source : System.Management.AutomationHResult : -2146233087TargetObject : Unable to locate tar command. Unable to continue.CategoryInfo : OperationStopped: (Unable to locate ta…Unable to continue.:String) [Import-Module], RuntimeExceptionFullyQualifiedErrorId : Unable to locate tar command. Unable to continue.,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleHistoryId : 1InvocationName : Import-ModuleCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\data\ManagedDependencies\210811045631133.r\tfe\1.0.2\tfe.psm1: line 1100at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 68PipelineIterationInfo :TargetSite :Name : InvokeDeclaringType : System.Management.Automation.Runspaces.PipelineBase, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input)at System.Management.Automation.Runspaces.Pipeline.Invoke()at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection1 input, PSDataCollection1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.Invoke[T](IEnumerable input, IList1 output, PSInvocationSettings settings)at System.Management.Automation.PowerShell.InvokeTat System.Management.Automation.CommandDiscovery.AutoloadSpecifiedModule(String moduleName, ExecutionContext context, SessionStateEntryVisibility visibility, Exception& exception)Message : Unable to locate tar command. Unable to continue.InnerException :Type : System.Management.Automation.RuntimeExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Unable to locate tar command. Unable to continue.HResult : -2146233087CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : RuntimeExceptionWasThrownFromThrowStatement : TrueTargetSite :Name : ThrowTerminatingErrorDeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)Message : Unable to locate tar command. Unable to continue.Source : System.Management.AutomationHResult : -2146233087Source : System.Management.AutomationHResult : -2146233087Source : System.Management.AutomationHResult : -2146233087TargetObject : New-TFEWorkspaceCategoryInfo : ObjectNotFound: (New-TFEWorkspace:String) [], CommandNotFoundExceptionFullyQualifiedErrorId : CouldNotAutoloadMatchingModuleInvocationInfo :ScriptLineNumber : 68OffsetInLine : 21HistoryId : 1ScriptName : C:\home\site\wwwroot\HttpTrigger1\run.ps1Line : $newWorkspace = New-TFEWorkspace -TFEBaseURL $TFEBaseURL -Org $org -WorkspaceName $WorkSpaceName -TerraformVersion $TerraformVersion -AutoApply $bAutoApply -AllowDestroyPlan $bAllowDestroyPlan -Token $secTokenPositionMessage : At C:\home\site\wwwroot\HttpTrigger1\run.ps1:68 char:21+ $newWorkspace = New-TFEWorkspace -TFEBaseURL $TFEBaseURL -Org $or …+ ~~~~~~~~~~~~~~~~PSScriptRoot : C:\home\site\wwwroot\HttpTrigger1PSCommandPath : C:\home\site\wwwroot\HttpTrigger1\run.ps1InvocationName : New-TFEWorkspaceCommandOrigin : InternalScriptStackTrace : at <ScriptBlock>, C:\home\site\wwwroot\HttpTrigger1\run.ps1: line 68Exception: The 'New-TFEWorkspace' command was found in the module 'tfe', but the module could not be loaded. For more information, run 'Import-Module tfe'.Stack: at System.Management.Automation.CommandDiscovery.TryModuleAutoDiscovery(String commandName, ExecutionContext context, String originalCommandName, CommandOrigin commandOrigin, SearchResolutionOptions searchResolutionOptions, CommandTypes commandTypes, Exception& lastError)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable1 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.ActionCallInstruction6.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
2021-08-11T06:39:18.750 [Information] OUTPUT:
2021-08-11T06:39:22.196 [Information] OUTPUT:
2021-08-11T06:39:22.402 [Information] Executed 'Functions.HttpTrigger1' (Succeeded, Id=83e48ffb-11c0-4e07-a718-9d5c6ad1be3a, Duration=8813ms)
If I give import-module tfe as per above error, I am getting additional error related to it.
2021-08-11T06:42:34.111 [Error] ERROR: Unable to locate tar command. Unable to continue.Exception :Type : System.Management.Automation.RuntimeExceptionErrorRecord :Exception :Type : System.Management.Automation.ParentContainsErrorRecordExceptionMessage : Unable to locate tar command. Unable to continue.HResult : -2146233087CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordExceptionFullyQualifiedErrorId : RuntimeExceptionWasThrownFromThrowStatement : TrueTargetSite :Name : ThrowTerminatingErrorDeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35MemberType : MethodModule : System.Management.Automation.dllStackTrace :at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)Message : Unable to locate tar command. Unable to continue.Source : System.Management.AutomationHResult : -2146233087TargetObject : Unable to locate tar command. Unable to continue.CategoryInfo : OperationStopped: (Unable to locate ta…Unable to continue.:String) [Import-Module], RuntimeExceptionFullyQualifiedErrorId : Unable to locate tar command. Unable to continue.,Microsoft.PowerShell.Commands.ImportModuleCommandInvocationInfo :MyCommand : Import-ModuleScriptLineNumber : 22OffsetInLine