Skip to content

Commit b41234e

Browse files
NetworkSecurityGroup bug fix.
1 parent c6b0f02 commit b41234e

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

src/ResourceManager/Common/Commands.Common.Strategies/Network/NetworkSecurityGroupPolicy.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,20 @@ public static ResourceConfig<NetworkSecurityGroup> CreateNetworkSecurityGroupCon
2323
name,
2424
_ => new NetworkSecurityGroup
2525
{
26-
SecurityRules = new SecurityRule[]
27-
{
28-
new SecurityRule
26+
SecurityRules = openPorts
27+
.Select((port, index) => new SecurityRule
2928
{
30-
DestinationPortRanges = openPorts.Select(v => v.ToString()).ToList()
31-
}
32-
}
29+
Name = name + port,
30+
Protocol = "Tcp",
31+
Priority = index + 1000,
32+
Access = "Allow",
33+
Direction = "Inbound",
34+
SourcePortRange = "*",
35+
SourceAddressPrefix = "*",
36+
DestinationPortRange = port.ToString(),
37+
DestinationAddressPrefix = "*"
38+
})
39+
.ToList()
3340
});
3441
}
3542
}

src/ResourceManager/Common/Commands.Common.Strategies/UpdateStateExtensions.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Linq;
1+
using System;
2+
using System.Linq;
23
using System.Threading;
34
using System.Threading.Tasks;
45

@@ -48,10 +49,17 @@ await _OperationContext.GetOrAdd(
4849
.Select(UpdateStateAsyncDispatch);
4950
await Task.WhenAll(tasks);
5051
// call the CreateOrUpdateAsync function for the resource.
51-
return await config.CreateOrUpdateAsync(
52-
_OperationContext.Client,
53-
model,
54-
_OperationContext.CancellationToken);
52+
try
53+
{
54+
return await config.CreateOrUpdateAsync(
55+
_OperationContext.Client,
56+
model,
57+
_OperationContext.CancellationToken);
58+
}
59+
catch (Exception e)
60+
{
61+
throw e;
62+
}
5563
});
5664
}
5765
}

0 commit comments

Comments
 (0)