You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
The text was updated successfully, but these errors were encountered:
Hi @TwiggyDev, this seems to be faulty logic at my part. Also, I am being unecessarily "clever" by setting the default value of ProfilePath in the parameter definition when there exist cases where the configuration path will not be set. So in the update I intend to post today I have moved the join-path command to the section where the code has established that it will indeed use a saved profile to connect, hopefully solving this issue permanently.
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.
The text was updated successfully, but these errors were encountered: