13
13
// ----------------------------------------------------------------------------------
14
14
15
15
16
+ using System ;
16
17
using Microsoft . Azure . Commands . WebApps . Models ;
17
18
using System . Management . Automation ;
18
19
using Microsoft . Azure . Commands . ResourceManager . Common . ArgumentCompleters ;
@@ -100,6 +101,11 @@ public override void ExecuteCmdlet()
100
101
var accessRestrictionList = TargetScmSite ? siteConfig . ScmIpSecurityRestrictions : siteConfig . IpSecurityRestrictions ;
101
102
IpSecurityRestriction ipSecurityRestriction = null ;
102
103
bool accessRestrictionExists = false ;
104
+ int ruleTypes = Convert . ToInt32 ( ! string . IsNullOrWhiteSpace ( IpAddress ) ) + Convert . ToInt32 ( ! string . IsNullOrWhiteSpace ( ServiceTag ) ) +
105
+ Convert . ToInt32 ( ! string . IsNullOrWhiteSpace ( SubnetId ) || ( ! string . IsNullOrWhiteSpace ( SubnetName ) && ! string . IsNullOrWhiteSpace ( VirtualNetworkName ) ) ) ;
106
+
107
+ if ( ruleTypes > 1 )
108
+ throw new Exception ( "Please specify only one of: IpAddress or ServiceTag or Subnet" ) ;
103
109
104
110
foreach ( var accessRestriction in accessRestrictionList )
105
111
{
@@ -117,7 +123,7 @@ public override void ExecuteCmdlet()
117
123
if ( ! string . IsNullOrWhiteSpace ( accessRestriction . IpAddress ) && accessRestriction . IpAddress . ToLowerInvariant ( ) == IpAddress . ToLowerInvariant ( ) && accessRestriction . Action . ToLowerInvariant ( ) == Action . ToLowerInvariant ( ) )
118
124
{
119
125
if ( ! string . IsNullOrWhiteSpace ( Name ) )
120
- if ( ! string . IsNullOrWhiteSpace ( accessRestriction . Name ) && accessRestriction . Name . ToLowerInvariant ( ) = = Name . ToLowerInvariant ( ) )
126
+ if ( ! string . IsNullOrWhiteSpace ( accessRestriction . Name ) && accessRestriction . Name . ToLowerInvariant ( ) ! = Name . ToLowerInvariant ( ) )
121
127
continue ;
122
128
123
129
ipSecurityRestriction = accessRestriction ;
@@ -130,7 +136,7 @@ public override void ExecuteCmdlet()
130
136
if ( ! string . IsNullOrWhiteSpace ( accessRestriction . IpAddress ) && accessRestriction . IpAddress . ToLowerInvariant ( ) == ServiceTag . ToLowerInvariant ( ) && accessRestriction . Action . ToLowerInvariant ( ) == Action . ToLowerInvariant ( ) )
131
137
{
132
138
if ( ! string . IsNullOrWhiteSpace ( Name ) )
133
- if ( ! string . IsNullOrWhiteSpace ( accessRestriction . Name ) && accessRestriction . Name . ToLowerInvariant ( ) = = Name . ToLowerInvariant ( ) )
139
+ if ( ! string . IsNullOrWhiteSpace ( accessRestriction . Name ) && accessRestriction . Name . ToLowerInvariant ( ) ! = Name . ToLowerInvariant ( ) )
134
140
continue ;
135
141
136
142
ipSecurityRestriction = accessRestriction ;
@@ -145,7 +151,7 @@ public override void ExecuteCmdlet()
145
151
if ( ! string . IsNullOrWhiteSpace ( accessRestriction . VnetSubnetResourceId ) && accessRestriction . VnetSubnetResourceId . ToLowerInvariant ( ) == subnetResourceId . ToLowerInvariant ( ) && accessRestriction . Action . ToLowerInvariant ( ) == Action . ToLowerInvariant ( ) )
146
152
{
147
153
if ( ! string . IsNullOrWhiteSpace ( Name ) )
148
- if ( ! string . IsNullOrWhiteSpace ( accessRestriction . Name ) && accessRestriction . Name . ToLowerInvariant ( ) = = Name . ToLowerInvariant ( ) )
154
+ if ( ! string . IsNullOrWhiteSpace ( accessRestriction . Name ) && accessRestriction . Name . ToLowerInvariant ( ) ! = Name . ToLowerInvariant ( ) )
149
155
continue ;
150
156
151
157
ipSecurityRestriction = accessRestriction ;
0 commit comments