@@ -1096,10 +1096,14 @@ public GetVirtualNetworkGatewayContext GetVirtualNetworkGateway(string gatewayId
1096
1096
VnetId = response . VnetId ,
1097
1097
SubnetId = response . SubnetId ,
1098
1098
EnableBgp = response . EnableBgp . ToString ( ) ,
1099
- Asn = response . BgpSettings . Asn ,
1100
- BgpPeeringAddress = response . BgpSettings . BgpPeeringAddress ,
1101
- PeerWeight = response . BgpSettings . PeerWeight ,
1102
1099
} ;
1100
+
1101
+ if ( response . BgpSettings != null )
1102
+ {
1103
+ gatewayContext . Asn = response . BgpSettings . Asn ;
1104
+ gatewayContext . BgpPeeringAddress = response . BgpSettings . BgpPeeringAddress ;
1105
+ gatewayContext . PeerWeight = response . BgpSettings . PeerWeight ;
1106
+ }
1103
1107
PopulateOperationContext ( response . RequestId , gatewayContext ) ;
1104
1108
1105
1109
return gatewayContext ;
@@ -1148,10 +1152,15 @@ public GetLocalNetworkGatewayContext GetLocalNetworkGateway(string gatewayId)
1148
1152
GatewayName = response . GatewayName ,
1149
1153
IpAddress = response . IpAddress ,
1150
1154
AddressSpace = response . AddressSpace . ToList ( ) ,
1151
- Asn = response . BgpSettings . Asn ,
1152
- BgpPeeringAddress = response . BgpSettings . BgpPeeringAddress ,
1153
- PeerWeight = response . BgpSettings . PeerWeight ,
1154
1155
} ;
1156
+
1157
+ if ( response . BgpSettings != null )
1158
+ {
1159
+ gatewayContext . Asn = response . BgpSettings . Asn ;
1160
+ gatewayContext . BgpPeeringAddress = response . BgpSettings . BgpPeeringAddress ;
1161
+ gatewayContext . PeerWeight = response . BgpSettings . PeerWeight ;
1162
+ }
1163
+
1155
1164
PopulateOperationContext ( response . RequestId , gatewayContext ) ;
1156
1165
1157
1166
return gatewayContext ;
@@ -1202,6 +1211,9 @@ public IEnumerable<GetVirtualNetworkGatewayContext> ListVirtualNetworkGateways()
1202
1211
VnetId = virtualNetworkGateway . VnetId ,
1203
1212
SubnetId = virtualNetworkGateway . SubnetId ,
1204
1213
EnableBgp = virtualNetworkGateway . EnableBgp . ToString ( ) ,
1214
+ Asn = virtualNetworkGateway . BgpSettings != null ? virtualNetworkGateway . BgpSettings . Asn : 0 ,
1215
+ BgpPeeringAddress = virtualNetworkGateway . BgpSettings != null ? virtualNetworkGateway . BgpSettings . BgpPeeringAddress : "" ,
1216
+ PeerWeight = virtualNetworkGateway . BgpSettings != null ? virtualNetworkGateway . BgpSettings . PeerWeight : 0
1205
1217
} ;
1206
1218
} ) ;
1207
1219
PopulateOperationContext ( response . RequestId , virtualNetworkGateways ) ;
@@ -1260,7 +1272,7 @@ public SharedKeyContext GetSharedKeyV2(string gatewayId, string connectedentityI
1260
1272
}
1261
1273
1262
1274
public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway ( string vnetName , string gatewayName , string gatewayType , string gatewaySKU , string location , string vnetId ,
1263
- uint Asn , string BgpPeeringAddress , int PeerWeight )
1275
+ uint Asn , int PeerWeight )
1264
1276
{
1265
1277
VirtualNetworkGatewayCreateParameters parameters = new VirtualNetworkGatewayCreateParameters ( )
1266
1278
{
@@ -1269,9 +1281,9 @@ public GatewayGetOperationStatusResponse CreateVirtualNetworkGateway(string vnet
1269
1281
GatewayType = gatewayType ,
1270
1282
Location = location ,
1271
1283
VnetId = vnetId ,
1272
- BgpSettings = Asn > 0 ? new BgpSettings {
1284
+ BgpSettings = ( Asn > 0 || PeerWeight > 0 ) ? new BgpSettings {
1273
1285
Asn = Asn ,
1274
- BgpPeeringAddress = BgpPeeringAddress ,
1286
+ BgpPeeringAddress = "" , // We don't allow changing the gateway's BgpPeeringAddress
1275
1287
PeerWeight = PeerWeight
1276
1288
} : null ,
1277
1289
} ;
@@ -1379,7 +1391,7 @@ public AzureOperationResponse UpdateLocalNetworkGateway(string gatewayId, List<s
1379
1391
UpdateLocalNetworkGatewayParameters parameters = new UpdateLocalNetworkGatewayParameters ( )
1380
1392
{
1381
1393
AddressSpace = addressSpace ,
1382
- BgpSettings = Asn > 0 ? new BgpSettings {
1394
+ BgpSettings = ( Asn > 0 || PeerWeight > 0 || ! string . IsNullOrEmpty ( BgpPeeringAddress ) ) ? new BgpSettings {
1383
1395
Asn = Asn ,
1384
1396
BgpPeeringAddress = BgpPeeringAddress ,
1385
1397
PeerWeight = PeerWeight ,
0 commit comments