public override void Execute() { base.Execute(); var networkRule = new PSAzureFirewallNetworkRule { Name = this.Name, Description = this.Description, Protocols = this.Protocol?.ToList(), SourceAddresses = this.SourceAddress?.ToList(), DestinationAddresses = this.DestinationAddress?.ToList(), DestinationPorts = this.DestinationPort?.ToList() }; WriteObject(networkRule); }
public override void Execute() { base.Execute(); // One of SourceAddress or SourceIpGroup must be present if ((SourceAddress == null) && (SourceIpGroup == null)) { throw new ArgumentException("Either SourceAddress or SourceIpGroup is required."); } if (DestinationFqdn != null) { foreach (string fqdn in DestinationFqdn) { ValidateIsFqdn(fqdn); } } // Only one of DestinationAddress or DestinationFqdns is allowed if ((DestinationAddress != null) && (DestinationFqdn != null)) { throw new ArgumentException("Both DestinationAddress and DestinationFqdns not allowed."); } // One of DestinationAddress or DestinationFqdns must be present if ((DestinationAddress == null) && (DestinationFqdn == null) && (DestinationIpGroup == null)) { throw new ArgumentException("DestinationAddress,DestinationIpGroup or DestinationFqdns is required."); } var networkRule = new PSAzureFirewallNetworkRule { Name = this.Name, Description = this.Description, Protocols = this.Protocol?.ToList(), SourceAddresses = this.SourceAddress?.ToList(), SourceIpGroups = this.SourceIpGroup?.ToList(), DestinationAddresses = this.DestinationAddress?.ToList(), DestinationIpGroups = this.DestinationIpGroup?.ToList(), DestinationFqdns = this.DestinationFqdn?.ToList(), DestinationPorts = this.DestinationPort?.ToList() }; WriteObject(networkRule); }