azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Set-AzureRmNetworkSecurityRuleConfig sets values of not provided parameters to null

Open jadzikow opened this issue 8 years ago • 8 comments

Cmdlet(s)

Set-AzureRmNetworkSecurityRuleConfig

Module Version

5.1.1 (Noticed on Azure Stack's version 1.2.11 but read the source code and the issue exists on Azure as well)

Description

Set-AzureRmNetworkSecurityRuleConfig modifies the chosen parameters of the network security rule but sets all other parameters to null. This seems very unintuitive, therefore I'm filing a bug to discuss whether it wouldn't be better to change the behaviour so that the cmdlet modifies only the provided parameters.

Script/Steps for Reproduction

$nsg = Get-AzureRmNetworkSecurityGroup ...
$nsg = Set-AzureRmNetworkSecurityRuleConfig -Name <rule_name_here> -NetworkSecurityGroup $nsg -Priority 123

At this point if you take a look at the NSG object, you will notice that while the priority of the rule was changed to 123, all other rule's properties were set to null.

Before executing the cmdlet, the security rule "ruleIn" has all properties. before After executing the cmdlet, the security rule had its priority updated, but all other properties were set to null. after

Root cause of the issue

The reason why it happens is here: SetAzureNetworkSecurityRuleConfigCommand.cs. All the properties of the security rule are set even though they were not necessarily provided to the cmdlet:

            rule.Description = this.Description;
            rule.Protocol = this.Protocol;
            rule.SourcePortRange = this.SourcePortRange;
            rule.DestinationPortRange = this.DestinationPortRange;
            rule.SourceAddressPrefix = this.SourceAddressPrefix;
            rule.DestinationAddressPrefix = this.DestinationAddressPrefix;
            rule.Access = this.Access;
            rule.Priority = this.Priority;
            rule.Direction = this.Direction;

jadzikow avatar Jan 17 '18 18:01 jadzikow

@DeepakRajendranMsft Can you take a look at this request? I agree with @jadzikow that this is unexpected and destructive behavior.

maddieclayton avatar Jan 17 '18 19:01 maddieclayton

Any updates on this?

jadzikow avatar Jan 26 '18 19:01 jadzikow

@MikhailTryakhov Hey Mikhail, would you mind assigning this to the proper contact? (is it the same as NSG?)

cormacpayne avatar Jul 06 '18 21:07 cormacpayne

Any updates on this?

sbgillett avatar Oct 30 '18 12:10 sbgillett

Well, this behavior was sure annoying and unexpected. Any progress on fixing this issue?

jwikman avatar Mar 29 '19 10:03 jwikman

@MikhailTryakhov Hey Mikhail, would you mind making sure that the proper team has a chance to look at this issue?

cormacpayne avatar Mar 29 '19 16:03 cormacpayne

@chandrasekarsrinivasan @avijitgupta owns this issue

MikhailTryakhov avatar Apr 01 '19 22:04 MikhailTryakhov

:bell: Routing this issue to @act-quality-productivity-squad.