Skip to content

Commit 630163e

Browse files
authored
{AzureNetworking} fixes #19436 Support for -WhatIf parameter (#20473)
* {AzureNetworking} fixes #19436 Support for -WhatIf parameter fixes #19436 Support for -WhatIf parameter All 'AzIpGroup' cmdlets that make changes support the -whatIf parameters. New-AzIpGroup and Remove-AzIpGroup honor this, displaying a "What If: " message and not making changes. Set-AzIpGroup supports -whatif according to the documentation and accepts the parameter, but ignores it and changes the configuration of the resource instead. This PR fixes a Bug for Set-AzIpGroup to support the -whatif parameter. * Update ChangeLog.md
1 parent 8feae8d commit 630163e

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/Network/Network/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
## Upcoming Release
2222
* Fixed a bug that added Ddos related properties when viewing PublicIpAddress and DdosProtectionPlan objects
23+
* Fixed a Bug for Set-AzIpGroup cmdlet to support the -whatif parameter
2324

2425
## Version 5.2.0
2526
* Added optional parameters `CustomBlockResponseStatusCode` and `CustomBlockResponseBody` parameter to `AzApplicationGatewayFirewallPolicySettings`

src/Network/Network/IpGroup/SetIpGroupCommand.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,25 @@ public class SetIpGroupsCommand : IpGroupBaseCmdlet
3535

3636
public override void Execute()
3737
{
38-
base.Execute();
39-
40-
if (!this.IsIpGroupsPresent(this.IpGroup.ResourceGroupName, this.IpGroup.Name))
38+
if (ShouldProcess(this.IpGroup.Name, "Updating IpGroup"))
4139
{
42-
throw new System.ArgumentException(string.Format(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound, this.IpGroup.Name));
43-
}
40+
base.Execute();
4441

45-
// Map to the sdk object
46-
var ipGroupSdkObject = NetworkResourceManagerProfile.Mapper.Map<MNM.IpGroup>(this.IpGroup);
47-
ipGroupSdkObject.Tags = TagsConversionHelper.CreateTagDictionary(this.IpGroup.Tag, validate: true);
42+
if (!this.IsIpGroupsPresent(this.IpGroup.ResourceGroupName, this.IpGroup.Name))
43+
{
44+
throw new System.ArgumentException(string.Format(Microsoft.Azure.Commands.Network.Properties.Resources.ResourceNotFound, this.IpGroup.Name));
45+
}
4846

49-
// Execute the PUT IpGroups call
50-
this.IpGroupsClient.CreateOrUpdate(this.IpGroup.ResourceGroupName, this.IpGroup.Name, ipGroupSdkObject);
47+
// Map to the sdk object
48+
var ipGroupSdkObject = NetworkResourceManagerProfile.Mapper.Map<MNM.IpGroup>(this.IpGroup);
49+
ipGroupSdkObject.Tags = TagsConversionHelper.CreateTagDictionary(this.IpGroup.Tag, validate: true);
5150

52-
var getIpGroups = this.GetIpGroup(this.IpGroup.ResourceGroupName, this.IpGroup.Name);
53-
WriteObject(getIpGroups);
51+
// Execute the PUT IpGroups call
52+
this.IpGroupsClient.CreateOrUpdate(this.IpGroup.ResourceGroupName, this.IpGroup.Name, ipGroupSdkObject);
53+
54+
var getIpGroups = this.GetIpGroup(this.IpGroup.ResourceGroupName, this.IpGroup.Name);
55+
WriteObject(getIpGroups);
56+
}
5457
}
5558
}
56-
}
59+
}

0 commit comments

Comments
 (0)