Skip to content

Commit c8912d6

Browse files
vimalchaYanaXu
andauthored
Added Support for Network Profile in Virtual Appliance (#24866)
* Added Support for Network Profile in Virtual Appliance * Added online version in md files * Minor fixes in md files and splitting the cmdlets in separate files * Added network profile in test * Fixed CI Signature Issues * Minor fix in example --------- Co-authored-by: Yan Xu <[email protected]>
1 parent 1425b11 commit c8912d6

15 files changed

+686
-5
lines changed

src/Network/Network.Test/ScenarioTests/NetworkVirtualApplianceTests.ps1

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,17 @@ function Test-NetworkVirtualApplianceCRUD
5151

5252
$wan = New-AzVirtualWan -ResourceGroupName $rgname -Name $wanname -Location $location
5353
$hub = New-AzVirtualHub -ResourceGroupName $rgname -Name $hubname -Location $location -VirtualWan $wan -AddressPrefix $prefix
54-
$nva = New-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Location $location -VirtualApplianceAsn $asn -VirtualHubId $hub.Id -Sku $sku -CloudInitConfiguration "echo hi"
54+
55+
$ipConfig1 = New-AzVirtualApplianceIpConfiguration -Name "publicnicipconfig" -Primary $true
56+
$ipConfig2 = New-AzVirtualApplianceIpConfiguration -Name "publicnicipconfig-2" -Primary $false
57+
$nicConfig1 = New-AzVirtualApplianceNetworkInterfaceConfiguration -NicType "PublicNic" -IpConfiguration $ipConfig1, $ipConfig2
58+
$ipConfig3 = New-AzVirtualApplianceIpConfiguration -Name "privatenicipconfig" -Primary $true
59+
$ipConfig4 = New-AzVirtualApplianceIpConfiguration -Name "privatenicipconfig-2" -Primary $false
60+
$nicConfig2 = New-AzVirtualApplianceNetworkInterfaceConfiguration -NicType "PrivateNic" -IpConfiguration $ipConfig3, $ipConfig4
61+
$networkProfile = New-AzVirtualApplianceNetworkProfile -NetworkInterfaceConfiguration $nicConfig1, $nicConfig2
62+
63+
$nva = New-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname -Location $location -VirtualApplianceAsn $asn -VirtualHubId $hub.Id -Sku $sku -CloudInitConfiguration "echo hi" -NetworkProfile $networkProfile
64+
5565
Assert-NotNull $nva
5666

5767
$getnva = Get-AzNetworkVirtualAppliance -ResourceGroupName $rgname -Name $nvaname

src/Network/Network/Az.Network.psd1

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,10 @@ CmdletsToExport = 'Add-AzApplicationGatewayAuthenticationCertificate',
638638
'Test-AzPrivateIPAddressAvailability',
639639
'Test-AzPrivateLinkServiceVisibility', 'Update-AzCustomIpPrefix',
640640
'Update-AzNetworkVirtualApplianceConnection',
641-
'New-AzVirtualApplianceInternetIngressIpsProperty',
641+
'New-AzVirtualApplianceInternetIngressIpsProperty',
642+
'New-AzVirtualApplianceNetworkProfile',
643+
'New-AzVirtualApplianceNetworkInterfaceConfiguration',
644+
'New-AzVirtualApplianceIpConfiguration',
642645
'New-AzVirtualApplianceInboundSecurityRulesProperty',
643646
'Update-AzVirtualApplianceInboundSecurityRule',
644647
'New-AzFirewallPacketCaptureRule',

src/Network/Network/ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
--->
2020

2121
## Upcoming Release
22+
* Added cmdlet `New-AzVirtualApplianceNetworkProfile` to build network profile for network virtual appliance and pass as a parameter.
23+
* Added cmdlet `New-AzVirtualApplianceNetworkInterfaceConfiguration` and `New-AzVirtualApplianceIpConfiguration` to build `New-AzVirtualApplianceNetworkProfile`.
2224
* Added support for ApplicationGatewaySkuFamily
2325
* Updated cmdlet to add the property of JSChallengeCookieExpirationInMins
2426
- `New-AzApplicationGatewayFirewallPolicySetting`

src/Network/Network/Common/NetworkResourceManagerProfile.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2222,6 +2222,7 @@ private static void Initialize()
22222222
cfg.CreateMap<CNM.PSInboundSecurityRulesProperty, MNM.InboundSecurityRules>();
22232223
cfg.CreateMap<CNM.PSNetworkVirtualApplianceConnection, MNM.NetworkVirtualApplianceConnection>();
22242224
cfg.CreateMap<CNM.PSVirtualApplianceInternetIngressIpsProperties, MNM.InternetIngressPublicIpsProperties>();
2225+
cfg.CreateMap<CNM.PSVirtualApplianceNetworkProfile, MNM.NetworkVirtualAppliancePropertiesFormatNetworkProfile>();
22252226
cfg.CreateMap<CNM.PSNetworkVirtualApplianceDelegationProperties, MNM.DelegationProperties>();
22262227

22272228
// MNM to CNM
@@ -2247,6 +2248,7 @@ private static void Initialize()
22472248
cfg.CreateMap<MNM.InboundSecurityRules, CNM.PSInboundSecurityRulesProperty>();
22482249
cfg.CreateMap<MNM.VirtualApplianceAdditionalNicProperties, CNM.PSVirtualApplianceAdditionalNicProperties>();
22492250
cfg.CreateMap<MNM.InternetIngressPublicIpsProperties, CNM.PSVirtualApplianceInternetIngressIpsProperties>();
2251+
cfg.CreateMap<MNM.NetworkVirtualAppliancePropertiesFormatNetworkProfile, CNM.PSVirtualApplianceNetworkProfile>();
22502252
cfg.CreateMap<MNM.NetworkVirtualApplianceConnection,CNM.PSNetworkVirtualApplianceConnection>();
22512253
cfg.CreateMap<MNM.DelegationProperties, CNM.PSNetworkVirtualApplianceDelegationProperties>();
22522254

src/Network/Network/Models/PSNetworkVirtualAppliance.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,7 @@ public class PSNetworkVirtualAppliance : PSTopLevelResource
5050
public PSNetworkVirtualApplianceDelegationProperties Delegation { get; set; }
5151

5252
public IList<PSVirtualApplianceInternetIngressIpsProperties> InternetIngressPublicIps { get; set; }
53+
54+
public PSVirtualApplianceNetworkProfile NetworkProfile { get; set; }
5355
}
5456
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
16+
using System;
17+
using System.Collections.Generic;
18+
using System.Globalization;
19+
using System.Text;
20+
21+
namespace Microsoft.Azure.Commands.Network.Models
22+
{
23+
public class PSVirtualApplianceNetworkProfile
24+
{
25+
public List<PSVirtualApplianceNetworkInterfaceConfiguration> NetworkInterfaceConfigurations { get; set; }
26+
}
27+
28+
public class PSVirtualApplianceNetworkInterfaceConfiguration
29+
{
30+
public string NicType { get; set; }
31+
public PSVirtualApplianceNetworkInterfaceConfigurationProperties Properties { get; set; }
32+
}
33+
34+
public class PSVirtualApplianceNetworkInterfaceConfigurationProperties
35+
{
36+
public List<PSVirtualApplianceIpConfiguration> IpConfigurations { get; set; }
37+
}
38+
39+
public class PSVirtualApplianceIpConfiguration
40+
{
41+
public string Name { get; set; }
42+
public PSVirtualApplianceIpConfigurationProperties Properties { get; set; }
43+
}
44+
45+
public class PSVirtualApplianceIpConfigurationProperties
46+
{
47+
public bool Primary { get; set; }
48+
}
49+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using System.Text;
19+
using System.Linq;
20+
using Microsoft.Azure.Commands.Network.Models;
21+
22+
namespace Microsoft.Azure.Commands.Network
23+
{
24+
[Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualApplianceIpConfiguration",
25+
SupportsShouldProcess = true),
26+
OutputType(typeof(PSVirtualApplianceIpConfiguration))]
27+
public class NewVirtualApplianceIpConfigurationCommand : VirtualApplianceNetworkProfileBaseCmdlet
28+
{
29+
[Parameter(
30+
Mandatory = true,
31+
ValueFromPipelineByPropertyName = false,
32+
HelpMessage = "The name of the IP configuration.")]
33+
[ValidateNotNullOrEmpty]
34+
public string Name { get; set; }
35+
36+
[Parameter(
37+
Mandatory = true,
38+
ValueFromPipelineByPropertyName = false,
39+
HelpMessage = "Indicates whether this IP configuration is the primary one.")]
40+
[ValidateNotNullOrEmpty]
41+
public bool Primary { get; set; }
42+
43+
public override void ExecuteCmdlet()
44+
{
45+
var ipConfiguration = new PSVirtualApplianceIpConfiguration
46+
{
47+
Name = this.Name,
48+
Properties = new PSVirtualApplianceIpConfigurationProperties
49+
{
50+
Primary = this.Primary
51+
}
52+
};
53+
54+
WriteObject(ipConfiguration);
55+
}
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using System.Text;
19+
using System.Linq;
20+
using Microsoft.Azure.Commands.Network.Models;
21+
22+
namespace Microsoft.Azure.Commands.Network
23+
{
24+
[Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualApplianceNetworkInterfaceConfiguration",
25+
SupportsShouldProcess = true),
26+
OutputType(typeof(PSVirtualApplianceNetworkInterfaceConfiguration))]
27+
public class NewVirtualApplianceNetworkInterfaceConfigurationCommand : VirtualApplianceNetworkProfileBaseCmdlet
28+
{
29+
[Parameter(
30+
Mandatory = true,
31+
ValueFromPipelineByPropertyName = false,
32+
HelpMessage = "The type of the network interface e.g., PublicNic or PrivateNic")]
33+
[ValidateNotNullOrEmpty]
34+
public string NicType { get; set; }
35+
36+
[Parameter(
37+
Mandatory = true,
38+
ValueFromPipelineByPropertyName = false,
39+
HelpMessage = "The IP configurations of the network interface configuration.")]
40+
[ValidateNotNullOrEmpty]
41+
public PSVirtualApplianceIpConfiguration[] IpConfiguration { get; set; }
42+
43+
public override void ExecuteCmdlet()
44+
{
45+
var networkInterfaceConfiguration = new PSVirtualApplianceNetworkInterfaceConfiguration
46+
{
47+
NicType = this.NicType,
48+
Properties = new PSVirtualApplianceNetworkInterfaceConfigurationProperties
49+
{
50+
IpConfigurations = this.IpConfiguration.ToList()
51+
}
52+
};
53+
54+
WriteObject(networkInterfaceConfiguration);
55+
}
56+
}
57+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
using System;
16+
using System.Collections.Generic;
17+
using System.Management.Automation;
18+
using System.Text;
19+
using System.Linq;
20+
using Microsoft.Azure.Commands.Network.Models;
21+
22+
namespace Microsoft.Azure.Commands.Network
23+
{
24+
[Cmdlet(VerbsCommon.New, ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "VirtualApplianceNetworkProfile",
25+
SupportsShouldProcess = true),
26+
OutputType(typeof(PSVirtualApplianceNetworkProfile))]
27+
public class NewVirtualApplianceNetworkProfileCommand : VirtualApplianceNetworkProfileBaseCmdlet
28+
{
29+
[Parameter(
30+
Mandatory = true,
31+
ValueFromPipelineByPropertyName = false,
32+
HelpMessage = "The network interface configurations of the network profile.")]
33+
[ValidateNotNullOrEmpty]
34+
public PSVirtualApplianceNetworkInterfaceConfiguration[] NetworkInterfaceConfiguration { get; set; }
35+
36+
public override void ExecuteCmdlet()
37+
{
38+
var networkProfile = new PSVirtualApplianceNetworkProfile
39+
{
40+
NetworkInterfaceConfigurations = this.NetworkInterfaceConfiguration.ToList()
41+
};
42+
43+
WriteObject(networkProfile);
44+
}
45+
}
46+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ----------------------------------------------------------------------------------
2+
//
3+
// Copyright Microsoft Corporation
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
// Unless required by applicable law or agreed to in writing, software
9+
// distributed under the License is distributed on an "AS IS" BASIS,
10+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
// See the License for the specific language governing permissions and
12+
// limitations under the License.
13+
// ----------------------------------------------------------------------------------
14+
15+
16+
using System;
17+
using System.Collections.Generic;
18+
using System.Text;
19+
20+
namespace Microsoft.Azure.Commands.Network
21+
{
22+
public class VirtualApplianceNetworkProfileBaseCmdlet : NetworkBaseCmdlet
23+
{
24+
// Empty class for future development of Get/Set/Update commands.
25+
}
26+
}

0 commit comments

Comments
 (0)