I found that Connect-AtwsWebAPI.ps1 had a nice little secret logic flow that looks for Environment Variables of interest when running in an Azure Function; something that I have been leveraging with a serverless automation system I've been developing for my workplace.
However, I have intermittently been running into an issue, where it seems that the AutoTask connection needs to be re-established, so "Get-ATWSData" (or an equivalent CMDlet) calls Connect-AtwsWebAPI without any parameters; this seems to follow the DefaultParameterSet of 'ConfigurationFile'
The error is thrown as a result of the $ProfilePath using the 'Join-Path' CMDlet, with the generic error: "Path" cannot be bound because it is null
[Parameter( ParameterSetName = 'ConfigurationFile' )] [ArgumentCompleter( { param($Cmd, $Param, $Word, $Ast, $FakeBound) $(Get-ChildItem -Path $Global:AtwsModuleConfigurationPath -Filter "*.clixml").FullName })] [ValidateScript( { Test-Path $_ })] [Alias('Path')] [IO.FileInfo] # The path to an alternate clixml file with connection profiles $ProfilePath = $(Join-Path -Path $Global:AtwsModuleConfigurationPath -ChildPath AtwsConfig.clixml)
I have been able to get around this issue by editing the DefaultParameterSet to one I defined, which doesn't actually take any relevant variables - allowing the command to go through, reach the "$ENV:FUNCTIONS_WORKER_RUNTIME" clause, and then obtain the Environment variables I set from there.
Is it possible to get a new Parameter Set that is targeted for official Azure Function use? Otherwise, could the assignment of $profilePath occur in the $PSCmdlet.ParameterSetName clause for 'ConfigurationFile' instead? Either solution should work.
I found that Connect-AtwsWebAPI.ps1 had a nice little secret logic flow that looks for Environment Variables of interest when running in an Azure Function; something that I have been leveraging with a serverless automation system I've been developing for my workplace.
However, I have intermittently been running into an issue, where it seems that the AutoTask connection needs to be re-established, so "Get-ATWSData" (or an equivalent CMDlet) calls Connect-AtwsWebAPI without any parameters; this seems to follow the DefaultParameterSet of 'ConfigurationFile'
The error is thrown as a result of the $ProfilePath using the 'Join-Path' CMDlet, with the generic error: "Path" cannot be bound because it is null
[Parameter( ParameterSetName = 'ConfigurationFile' )] [ArgumentCompleter( { param($Cmd, $Param, $Word, $Ast, $FakeBound) $(Get-ChildItem -Path $Global:AtwsModuleConfigurationPath -Filter "*.clixml").FullName })] [ValidateScript( { Test-Path $_ })] [Alias('Path')] [IO.FileInfo] # The path to an alternate clixml file with connection profiles $ProfilePath = $(Join-Path -Path $Global:AtwsModuleConfigurationPath -ChildPath AtwsConfig.clixml)I have been able to get around this issue by editing the DefaultParameterSet to one I defined, which doesn't actually take any relevant variables - allowing the command to go through, reach the "$ENV:FUNCTIONS_WORKER_RUNTIME" clause, and then obtain the Environment variables I set from there.
Is it possible to get a new Parameter Set that is targeted for official Azure Function use? Otherwise, could the assignment of $profilePath occur in the $PSCmdlet.ParameterSetName clause for 'ConfigurationFile' instead? Either solution should work.