vsteam
vsteam copied to clipboard
Running VSTeam in azure function app with restricted access to github fails with error
Steps to reproduce
Having VSTeam module installed on a server behind a network appliance (Azure function app behind private endpoint and some firewall rules to grant permissions only to required sites). That is, the server has access to Azure DevOps and powershellgallery.com, but not to github.com
When loading the module, it raises an error (see actual behaviour)
This error will not happen if the env variable VSTEAM_NO_UPDATE_MESSAGE is set to true
Expected behavior
The module is loaded without issues
This error will not happen if the env variable VSTEAM_NO_UPDATE_MESSAGE is set to true
In case the variable is not set or set to false the function checks connectivity in the _pinpGithub
function. This should return a true/false value. Not an exception.
Possible fix:
function _pinpGithub {
Write-Verbose "Checking if client is online"
try {
$pingGh = [System.Net.NetworkInformation.Ping]::new()
[System.Net.NetworkInformation.PingReply]$reply = $pingGh.Send('github.com', 150)
return $reply.Status
} catch {
return $false
}
}
That is, catching any error and return 'No connectivity' status.
Actual behavior?
2022-12-01T15:26:48Z [Error] ERROR: Exception calling "Send" with "2" argument(s): "An exception occurred during a Ping request."
Exception :
Type : System.Management.Automation.MethodInvocationException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : Exception calling "Send" with "2" argument(s): "An exception occurred during a Ping request."
HResult : -2146233087
CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : PingException
InvocationInfo :
ScriptLineNumber : 1050
OffsetInLine : 4
HistoryId : -1
ScriptName : D:\home\data\ManagedDependencies\2212010851515500722.r\VSTeam\7.6.1\vsteam.functions.ps1
Line : [System.Net.NetworkInformation.PingReply]$reply = $pingGh.Send('github.com', 150)
PositionMessage : At D:\home\data\ManagedDependencies\2212010851515500722.r\VSTeam\7.6.1\vsteam.functions.ps1:1050 char:4
+ [System.Net.NetworkInformation.PingReply]$reply = $pingGh.Send('gi …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : D:\home\data\ManagedDependencies\2212010851515500722.r\VSTeam\7.6.1
PSCommandPath : D:\home\data\ManagedDependencies\2212010851515500722.r\VSTeam\7.6.1\vsteam.functions.ps1
CommandOrigin : Internal
ScriptStackTrace : at _pinpGithub, D:\home\data\ManagedDependencies\2212010851515500722.r\VSTeam\7.6.1\vsteam.functions.ps1: line 1050
at _showModuleLoadingMessages<Process>, D:\home\data\ManagedDependencies\2212010851515500722.r\VSTeam\7.6.1\vsteam.functions.ps1: line 1064
at <ScriptBlock>, D:\home\data\ManagedDependencies\2212010851515500722.r\VSTeam\7.6.1\VSTeam.psm1: line 26
at <ScriptBlock>, D:\home\site\wwwroot\profile.ps1: line 23
TargetSite :
Name : ConvertToMethodInvocationException
DeclaringType : System.Management.Automation.ExceptionHandlingOps, System.Management.Automation, Version=7.2.6.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : System.Management.Automation.dll
Message : Exception calling "Send" with "2" argument(s): "An exception occurred during a Ping request."
Data : System.Collections.ListDictionaryInternal
InnerException :
Type : System.Net.NetworkInformation.PingException
TargetSite :
Name : GetAddressAndSend
DeclaringType : System.Net.NetworkInformation.Ping
MemberType : Method
Module : System.Net.Ping.dll
Message : An exception occurred during a Ping request.
InnerException :
Type : System.ComponentModel.Win32Exception
NativeErrorCode : 5
ErrorCode : -2147467259
TargetSite :
Name : InitialiseIcmpHandle
DeclaringType : System.Net.NetworkInformation.Ping
MemberType : Method
Module : System.Net.Ping.dll
Message : Access is denied.
Source : System.Net.Ping
HResult : -2147467259
The source of the problem is the Access is denied at the end of the exception log
On Which OS have you tried it?
Windows
What was your server version?
Azure DevOps Services
Other server version
No response
Log output of used API
it is not possible invoke directly Get-VSTeamAPIVersion in the function app from the kudu console, but the problem will raise starting from version 7.6.0
Log output of $PSVersionTable
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.14393.5127
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.5127
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1