@@ -18,6 +18,7 @@ type NetworkInterfaceConfig = {
18
18
SubnetName: string option
19
19
SubnetPrefix: IPAddressCidr option
20
20
LinkedSubnet: LinkedResource option
21
+ NetworkSecurityGroup: LinkedResource option
21
22
PrivateIpAddress: AllocationMethod
22
23
PrivateIpAddressVersion: AddressVersion
23
24
Tags: Map < string , string >
@@ -56,7 +57,7 @@ type NetworkInterfaceConfig = {
56
57
IpConfigs = subnetIpConfigs
57
58
Primary = this.IsPrimary
58
59
VirtualNetwork = vnetId
59
- NetworkSecurityGroup = None
60
+ NetworkSecurityGroup = this.NetworkSecurityGroup
60
61
Tags = this.Tags
61
62
}
62
63
@@ -102,7 +103,7 @@ type NetworkInterfaceConfig = {
102
103
IpConfigs = subnetIpConfigs
103
104
Primary = this.IsPrimary
104
105
VirtualNetwork = vnetId
105
- NetworkSecurityGroup = None
106
+ NetworkSecurityGroup = this.NetworkSecurityGroup
106
107
Tags = this.Tags
107
108
}
108
109
| _ ->
@@ -120,6 +121,7 @@ type NetworkInterfaceBuilder() =
120
121
SubnetName = None
121
122
SubnetPrefix = None
122
123
LinkedSubnet = None
124
+ NetworkSecurityGroup = None
123
125
PrivateIpAddress = AllocationMethod.DynamicPrivateIp
124
126
PrivateIpAddressVersion = IPv4
125
127
Tags = Map.empty
@@ -195,6 +197,40 @@ type NetworkInterfaceBuilder() =
195
197
| _ -> IPv4
196
198
}
197
199
200
+ /// Sets the network security group for network interface
201
+ [<CustomOperation " network_security_group" >]
202
+ member _.NetworkSecurityGroup ( state : NetworkInterfaceConfig , nsg : IArmResource ) = {
203
+ state with
204
+ NetworkSecurityGroup = Some( Managed nsg.ResourceId)
205
+ }
206
+
207
+ member _.NetworkSecurityGroup ( state : NetworkInterfaceConfig , nsg : ResourceId ) = {
208
+ state with
209
+ NetworkSecurityGroup = Some( Managed nsg)
210
+ }
211
+
212
+ member _.NetworkSecurityGroup ( state : NetworkInterfaceConfig , nsg : NsgConfig ) = {
213
+ state with
214
+ NetworkSecurityGroup = Some( Managed ( nsg :> IBuilder ). ResourceId )
215
+ }
216
+
217
+ /// Links the network interface to an existing network security group.
218
+ [<CustomOperation " link_to_network_security_group" >]
219
+ member _.LinkToNetworkSecurityGroup ( state : NetworkInterfaceConfig , nsg : IArmResource ) = {
220
+ state with
221
+ NetworkSecurityGroup = Some( Unmanaged( nsg.ResourceId))
222
+ }
223
+
224
+ member _.LinkToNetworkSecurityGroup ( state : NetworkInterfaceConfig , nsg : ResourceId ) = {
225
+ state with
226
+ NetworkSecurityGroup = Some( Unmanaged nsg)
227
+ }
228
+
229
+ member _.LinkToNetworkSecurityGroup ( state : NetworkInterfaceConfig , nsg : NsgConfig ) = {
230
+ state with
231
+ NetworkSecurityGroup = Some( Unmanaged ( nsg :> IBuilder ). ResourceId )
232
+ }
233
+
198
234
interface ITaggable< NetworkInterfaceConfig> with
199
235
member _.Add state tags = {
200
236
state with
0 commit comments