Get-AzP2sVpnGatewayDetailedConnectionHealth: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. #24181
Whenever I run Get-AzP2sVpnGatewayDetailedConnectionHealth I receive this error:
Get-AzP2sVpnGatewayDetailedConnectionHealth: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
Had a look at https://github.com/Azure/azure-powershell/issues/12964, but the resolution in there does not apply... even when generating a SAS token through the Azure Portal specifically for the blob where the output should be saved, the issue still occurs.
// There may be a required Json serialize for the returned contents to conform to REST-API
// The try-catch below handles the case till the change is made and deployed to PROD
Unsure whether this is the cause?
Maybe another cause for this could be because we have multiple p2SConnectionConfigurations, with User Groups assigned from Entra Groups?
Issue script & Debug output
DEBUG: 10:38:41 - GetAzureRmP2SVpnGatewayDetailedConnectionHealthCommand begin processing with ParameterSet 'ByP2SVpnGatewayName'.
DEBUG: 10:38:41 - using account id 'user-name-here'...
DEBUG: 10:38:41 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: 'user-name-here', environment: 'AzureCloud', tenant: 'tenant-id-here'
DEBUG: 10:38:41 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 10:38:41 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'tenant-id-here', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'user-name-here'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - a2e8b2d5-5784-4d50-96b6-17d7a112e668] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - a2e8b2d5-5784-4d50-96b6-17d7a112e668] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - a2e8b2d5-5784-4d50-96b6-17d7a112e668] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - a2e8b2d5-5784-4d50-96b6-17d7a112e668] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - a2e8b2d5-5784-4d50-96b6-17d7a112e668] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - a2e8b2d5-5784-4d50-96b6-17d7a112e668] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z] Found 2 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z] Returning 2 accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] MSAL MSAL.NetCore with assembly version '4.49.1.0'. CorrelationId(887fe618-7b7e-47e3-9906-59b78a958284)
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] LoginHint provided: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] Account provided: True
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] ForceRefresh: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 887fe618-7b7e-47e3-9906-59b78a958284
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] === Token Acquisition (SilentRequest) started:
Scopes: https://management.core.windows.net//.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] Access token is not expired. Returning the found cache entry. [Current time (02/20/2024 10:38:41) - Expiration Time (02/20/2024 11:51:00 +00:00) - Extended Expiration Time (02/20/2024 11:51:00 +00:00)]
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] Returning access token found in cache. RefreshOn exists ? False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.15 Microsoft Windows 10.0.22631 [2024-02-20 10:38:41Z - 887fe618-7b7e-47e3-9906-59b78a958284] AT expiration time: 20/02/2024 11:51:00 +00:00, scopes: https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default. source: Cache
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2024-02-20T11:51:00.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: 'tenant-id-here', UserId: 'user-name-here'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/p2svpnGateways/p2s-gateway-name-here?api-version=2023-06-01
Headers:
Accept-Language : en-US
x-ms-client-request-id : b05048f2-915e-4a6f-9bf3-afaa754222da
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
ETag : W/"1a80768e-61ef-4674-a5dc-65a5e2bc9d4f"
x-ms-request-id : bd4c119e-7493-4317-ad35-923eb5c5270d
x-ms-correlation-request-id : b76431d3-8061-49e9-bd75-e1e6683e1054
x-ms-arm-service-request-id : 5a21fc85-c982-4e75-af85-5100cddc375b
Strict-Transport-Security : max-age=31536000; includeSubDomains
Server : Microsoft-HTTPAPI/2.0,Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-reads: 11999
x-ms-routing-request-id : UKSOUTH:20240220T103846Z:b76431d3-8061-49e9-bd75-e1e6683e1054
X-Content-Type-Options : nosniff
Date : Tue, 20 Feb 2024 10:38:46 GMT
Body:
{
"name": "p2s-gateway-name-here",
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/p2sVpnGateways/p2s-gateway-name-here",
"etag": "W/\"1a80768e-61ef-4674-a5dc-65a5e2bc9d4f\"",
"type": "Microsoft.Network/p2sVpnGateways",
"location": "uksouth",
"properties": {
"provisioningState": "Succeeded",
"virtualHub": {
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/virtualHubs/virtual-hub-name-here"
},
"vpnServerConfiguration": {
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/vpnServerConfigurations/p2s-gateway-config-name-here"
},
"vpnServerConfigurationLocation": "uksouth",
"p2SConnectionConfigurations": [
{
"name": "AdminConfiguration",
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/p2sVpnGateways/p2s-gateway-name-here/p2sConnectionConfigurations/AdminConfiguration",
"etag": "W/\"1a80768e-61ef-4674-a5dc-65a5e2bc9d4f\"",
"type": "Microsoft.Network/p2sVpnGateways/p2sConnectionConfigurations",
"properties": {
"provisioningState": "Succeeded",
"routingConfiguration": {
"associatedRouteTable": {
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/virtualHubs/virtual-hub-name-here/hubRouteTables/defaultRouteTable"
},
"propagatedRouteTables": {
"labels": [
"default"
],
"ids": [
{
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/virtualHubs/virtual-hub-name-here/hubRouteTables/defaultRouteTable"
}
]
}
},
"vpnClientAddressPool": {
"addressPrefixes": [
"some-ip-range"
]
},
"configurationPolicyGroupAssociations": [
{
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/vpnServerConfigurations/p2s-gateway-config-name-here/configurationPolicyGroups/Admins"
}
],
"enableInternetSecurity": true
}
},
{
"name": "NormalConfiguration",
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/p2sVpnGateways/p2s-gateway-name-here/p2sConnectionConfigurations/NormalConfiguration",
"etag": "W/\"1a80768e-61ef-4674-a5dc-65a5e2bc9d4f\"",
"type": "Microsoft.Network/p2sVpnGateways/p2sConnectionConfigurations",
"properties": {
"provisioningState": "Succeeded",
"routingConfiguration": {
"associatedRouteTable": {
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/virtualHubs/virtual-hub-name-here/hubRouteTables/defaultRouteTable"
},
"propagatedRouteTables": {
"labels": [
"default"
],
"ids": [
{
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/virtualHubs/virtual-hub-name-here/hubRouteTables/defaultRouteTable"
}
]
}
},
"vpnClientAddressPool": {
"addressPrefixes": [
"some-ip-range"
]
},
"configurationPolicyGroupAssociations": [
{
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/vpnServerConfigurations/p2s-gateway-config-name-here/configurationPolicyGroups/Normal"
}
],
"enableInternetSecurity": true
}
},
{
"name": "LimitedConfiguration",
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/p2sVpnGateways/p2s-gateway-name-here/p2sConnectionConfigurations/LimitedConfiguration",
"etag": "W/\"1a80768e-61ef-4674-a5dc-65a5e2bc9d4f\"",
"type": "Microsoft.Network/p2sVpnGateways/p2sConnectionConfigurations",
"properties": {
"provisioningState": "Succeeded",
"routingConfiguration": {
"associatedRouteTable": {
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/virtualHubs/virtual-hub-name-here/hubRouteTables/defaultRouteTable"
},
"propagatedRouteTables": {
"labels": [
"default"
],
"ids": [
{
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/virtualHubs/virtual-hub-name-here/hubRouteTables/defaultRouteTable"
}
]
}
},
"vpnClientAddressPool": {
"addressPrefixes": [
"some-ip-range"
]
},
"configurationPolicyGroupAssociations": [
{
"id": "/subscriptions/subscription-id-here/resourceGroups/resource-group-name-here/providers/Microsoft.Network/vpnServerConfigurations/p2s-gateway-config-name-here/configurationPolicyGroups/Limited"
}
],
"enableInternetSecurity": true
}
}
],
"vpnGatewayDetachStatus": "Attached",
"vpnGatewayScaleUnit": 1,
"customDnsServers": [],
"isRoutingPreferenceInternet": false,
"useRadiusProxyIPs": false,
"radiusProxyIPs": []
}
}
DEBUG: 10:41:42 - [ConfigManager] Got nothing from [DisableErrorRecordsPersistence], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 10:41:42 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
Get-AzP2sVpnGatewayDetailedConnectionHealth: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
DEBUG: 10:41:42 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:41:42 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 10:41:42 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Network:7.3.0; CommandName: Get-AzP2sVpnGatewayDetailedConnectionHealth; PSVersion: 7.3.11; IsSuccess: False; Duration: 00:03:01.2555961; Exception: Index (zero based) must be greater than or equal to zero and less than the size of the argument list.;
DEBUG: 10:41:43 - GetAzureRmP2SVpnGatewayDetailedConnectionHealthCommand end processing.
Environment data
Name Value
---- -----
PSVersion 7.3.11
PSEdition Core
GitCommitId 7.3.11
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
DEBUG: 10:55:29 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 10:55:29 - using account id 'user-id-here'...
DEBUG: 10:55:29 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
HistoryId: 35
Message : Index (zero based) must be greater than or equal to zero and less than the size of the argument list.
StackTrace : at System.Text.ValueStringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ReadOnlySpan`1 args)
at System.String.FormatHelper(IFormatProvider provider, String format, ReadOnlySpan`1 args)
at System.String.Format(String format, Object arg0, Object arg1)
at Microsoft.Azure.Commands.Network.NetworkClient.ExecuteOperationWithHttpMessagesAsync(String resourceGroupName, String resourceName, Object parameters, String apiUrl, String apiVersion, Dictionary`2 customHeaders, CancellationToken cancellationToken)
at Microsoft.Azure.Commands.Network.NetworkClient.GetP2SVpnGatewayDetailedConnectionHealthAsync(String resourceGroupName, String p2sVpnGatewayName, P2SVpnConnectionHealthRequest parameters, CancellationToken cancellationToken)
at Microsoft.Azure.Commands.Network.NetworkClient.GetP2SVpnGatewayDetailedConnectionHealth(String resourceGroupName, String p2sVpnGatewayName, P2SVpnConnectionHealthRequest parameters)
at Microsoft.Azure.Commands.Network.GetAzureRmP2SVpnGatewayDetailedConnectionHealthCommand.Execute()
at Microsoft.Azure.Commands.Network.NetworkBaseCmdlet.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor)
at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet)
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception : System.FormatException
InvocationInfo : {Get-AzP2sVpnGatewayDetailedConnectionHealth}
Line : Get-AzP2sVpnGatewayDetailedConnectionHealth -Name p2sgateway-name-here -ResourceGroupName resource-group-name-here -OutputBlobSasUrl
"SAS-url-generated-in-portal-here" -Debug
Position : At line:1 char:1
+ Get-AzP2sVpnGatewayDetailedConnectionHealth -Name xxx …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId : 35
Description
Trying to implement the solution mentioned on https://learn.microsoft.com/en-us/azure/virtual-wan/monitor-point-to-site-connections.
Whenever I run Get-AzP2sVpnGatewayDetailedConnectionHealth I receive this error:
Had a look at https://github.com/Azure/azure-powershell/issues/12964, but the resolution in there does not apply... even when generating a SAS token through the Azure Portal specifically for the blob where the output should be saved, the issue still occurs.
I do see a comment in the source code that says:
Unsure whether this is the cause?
Maybe another cause for this could be because we have multiple p2SConnectionConfigurations, with User Groups assigned from Entra Groups?
Issue script & Debug output
Environment data
Module versions
Error output