@@ -44,26 +44,15 @@ public override void ExecuteCmdlet()
44
44
SecondaryBytesIn = ( ulong ) 0 ,
45
45
SecondaryBytesOut = ( ulong ) 0
46
46
} ;
47
- AzureBgpPeering peering = ExpressRouteClient . GetAzureBGPPeering ( ServiceKey , BgpPeeringAccessType . Private ) ;
48
- if ( peering != null )
49
- {
50
- stats = compute ( stats , ServiceKey , BgpPeeringAccessType . Private ) ;
51
- }
52
- peering = ExpressRouteClient . GetAzureBGPPeering ( ServiceKey , BgpPeeringAccessType . Public ) ;
53
- if ( peering != null )
54
- {
55
- stats = compute ( stats , ServiceKey , BgpPeeringAccessType . Public ) ;
56
- }
57
- peering = ExpressRouteClient . GetAzureBGPPeering ( ServiceKey , BgpPeeringAccessType . Microsoft ) ;
58
- if ( peering != null )
59
- {
60
- stats = compute ( stats , ServiceKey , BgpPeeringAccessType . Microsoft ) ;
61
- }
47
+ stats = compute ( stats , ServiceKey , BgpPeeringAccessType . Private ) ;
48
+ stats = compute ( stats , ServiceKey , BgpPeeringAccessType . Public ) ;
49
+ stats = compute ( stats , ServiceKey , BgpPeeringAccessType . Microsoft ) ;
50
+
62
51
WriteObject ( stats ) ;
63
52
64
53
}
65
54
BgpPeeringAccessType type ;
66
- if ( BgpPeeringAccessType . TryParse ( AccessType , out type ) )
55
+ if ( BgpPeeringAccessType . TryParse ( AccessType , true , out type ) )
67
56
{
68
57
var stats = ExpressRouteClient . GetAzureDedicatedCircuitStatsInfo ( ServiceKey , type ) ;
69
58
WriteObject ( stats ) ;
@@ -72,12 +61,24 @@ public override void ExecuteCmdlet()
72
61
73
62
private AzureDedicatedCircuitStats compute ( AzureDedicatedCircuitStats stats , Guid key , BgpPeeringAccessType type )
74
63
{
75
- var tempstats = ExpressRouteClient . GetAzureDedicatedCircuitStatsInfo ( key , type ) ;
76
- stats . PrimaryBytesIn += tempstats . PrimaryBytesIn ;
77
- stats . PrimaryBytesOut += tempstats . PrimaryBytesOut ;
78
- stats . SecondaryBytesIn += tempstats . SecondaryBytesIn ;
79
- stats . SecondaryBytesOut += tempstats . SecondaryBytesOut ;
80
- return stats ;
64
+ try
65
+ {
66
+ AzureBgpPeering peering = ExpressRouteClient . GetAzureBGPPeering ( ServiceKey , type ) ;
67
+ if ( peering != null )
68
+ {
69
+ var tempstats = ExpressRouteClient . GetAzureDedicatedCircuitStatsInfo ( key , type ) ;
70
+ stats . PrimaryBytesIn += tempstats . PrimaryBytesIn ;
71
+ stats . PrimaryBytesOut += tempstats . PrimaryBytesOut ;
72
+ stats . SecondaryBytesIn += tempstats . SecondaryBytesIn ;
73
+ stats . SecondaryBytesOut += tempstats . SecondaryBytesOut ;
74
+ }
75
+ return stats ;
76
+ }
77
+ catch
78
+ {
79
+ // The cirucit might not have corresponding peering
80
+ return stats ;
81
+ }
81
82
}
82
83
}
83
84
}
0 commit comments