diff --git a/src/Accounts/Authentication/Authentication - Backup.csproj b/src/Accounts/Authentication/Authentication - Backup.csproj new file mode 100644 index 000000000000..bc7ac863b12d --- /dev/null +++ b/src/Accounts/Authentication/Authentication - Backup.csproj @@ -0,0 +1,33 @@ + + + + Accounts + + + + + + Microsoft.Azure.PowerShell.Authentication + $(LegacyAssemblyPrefix)Common.Authentication + + + + + + + + + True + True + Resources.resx + + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + \ No newline at end of file diff --git a/src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.cs b/src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.cs index 473889cf9f88..a22bc5efcbcd 100644 --- a/src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.cs +++ b/src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.cs @@ -26,6 +26,13 @@ public VirtualNetworkGatewayTests(Xunit.Abstractions.ITestOutputHelper output) { } + [Fact] + [Trait(Category.AcceptanceType, Category.CheckIn)] + [Trait(Category.Owner, NrpTeamAlias.brooklynft_subset2)] + public void TestVirtualNetworkLocalGatewayCRUD() + { + TestRunner.RunTestScript("Test-VirtualNetworkLocalGatewayCRUD"); + } [Fact] [Trait(Category.AcceptanceType, Category.CheckIn)] diff --git a/src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.ps1 b/src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.ps1 index 35a08b54479c..1d5578f929bf 100644 --- a/src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.ps1 +++ b/src/Network/Network.Test/ScenarioTests/VirtualNetworkGatewayTests.ps1 @@ -12,6 +12,65 @@ # limitations under the License. # ---------------------------------------------------------------------------------- +<# +.SYNOPSIS +Virtual network type local gateway tests +#> +function Test-VirtualNetworkLocalGatewayCRUD +{ + # Setup + $rgname = Get-ResourceGroupName + $rname = Get-ResourceName + $vnetName = Get-ResourceName + $rglocation = Get-ProviderLocation ResourceManagement "West Central US" + $resourceTypeParent = "Microsoft.Network/virtualNetworkGateways" + $location = Get-ProviderLocation $resourceTypeParent "West Central US" + $extendedLocationType = "EdgeZone" + $extendedLocationName = Get-ResourceName + + try + { + # Create the resource group + $resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation -Tags @{ testtag = "testval" } + + # Create the Virtual Network + $subnet = New-AzVirtualNetworkSubnetConfig -Name "GatewaySubnet" -AddressPrefix 10.0.0.0/24 + $vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet + $vnet = Get-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname + + $actual = New-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname -location $location -GatewayType LocalGateway -VirtualNetworkResourceId $vnet.Id -ExtendedLocationType $extendedLocationType -ExtendedLocationName $extendedLocationName -Force + $expected = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -name $rname + Assert-AreEqual $expected.ResourceGroupName $actual.ResourceGroupName + Assert-AreEqual $expected.Name $actual.Name + Assert-AreEqual "LocalGateway" $expected.GatewayType + Assert-AreEqual "EdgeZone" $expected.ExtendedLocationType + Assert-AreEqual $extendedLocationName $expected.ExtendedLocationName + + # List virtualNetworkGateways + $list = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname + Assert-AreEqual 1 @($list).Count + Assert-AreEqual $list[0].ResourceGroupName $actual.ResourceGroupName + Assert-AreEqual $list[0].Name $actual.Name + Assert-AreEqual $list[0].Location $actual.Location + + $list = Get-AzVirtualNetworkGateway -ResourceGroupName $rgname -Name "*" + Assert-True { $list.Count -ge 0 } + + # Delete virtualNetworkGateway + $delete = Remove-AzVirtualNetworkGateway -ResourceGroupName $actual.ResourceGroupName -name $rname -PassThru -Force + Assert-AreEqual true $delete + + $list = Get-AzVirtualNetworkGateway -ResourceGroupName $actual.ResourceGroupName + Assert-AreEqual 0 @($list).Count + + } + finally + { + # Cleanup + Clean-ResourceGroup $rgname + } +} + <# .SYNOPSIS Virtual network express route gateway tests diff --git a/src/Network/Network/ChangeLog.md b/src/Network/Network/ChangeLog.md index 159d09062dd2..d31231330c20 100644 --- a/src/Network/Network/ChangeLog.md +++ b/src/Network/Network/ChangeLog.md @@ -19,6 +19,9 @@ ---> ## Upcoming Release +* Added warning messages for upcoming breaking change for Virtual Router Peer Routes + - `Get-AzVirtualRouterPeerLearnedRoute` + - `Get-AzVirtualRouterPeerAdvertisedRoute` * Added new cmdlet for virtual router - `Update-AzVirtualRouter`: to allow branch to branch traffic * [Breaking Change] Removed parameter `HostedSubnet` and add `Subnet` instead diff --git a/src/Network/Network/Models/PSExtendedLocation.cs b/src/Network/Network/Models/PSExtendedLocation.cs new file mode 100644 index 000000000000..5a97f748c81a --- /dev/null +++ b/src/Network/Network/Models/PSExtendedLocation.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace Microsoft.Azure.Commands.Network.Models +{ + public class PSExtendedLocation + { + public string Name { get; set; } + public string Type { get; set; } + } +} diff --git a/src/Network/Network/Models/PSVirtualNetworkGateway.cs b/src/Network/Network/Models/PSVirtualNetworkGateway.cs index 4c22ef6ff17d..d01c8af415b0 100644 --- a/src/Network/Network/Models/PSVirtualNetworkGateway.cs +++ b/src/Network/Network/Models/PSVirtualNetworkGateway.cs @@ -52,6 +52,10 @@ public class PSVirtualNetworkGateway : PSTopLevelResource public string VpnGatewayGeneration { get; set; } + public string VirtualNetworkExtendedLocationResourceId { get; set; } + + public PSExtendedLocation ExtendedLocation { get; set; } + [JsonIgnore] public string IpConfigurationsText { diff --git a/src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs b/src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs index 521fe10ea8d9..4cbea671d9cb 100644 --- a/src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs +++ b/src/Network/Network/VirtualNetworkGateway/NewAzureVirtualNetworkGatewayCommand.cs @@ -48,6 +48,11 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd ValueFromPipelineByPropertyName = true, ParameterSetName = VirtualNetworkGatewayParameterSets.AadAuthenticationConfiguration, HelpMessage = "The resource name.")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = VirtualNetworkGatewayParameterSets.TypeLocalGatewayConfiguration, + HelpMessage = "The resource name.")] [Parameter( Mandatory = true, ValueFromPipelineByPropertyName = true, @@ -71,6 +76,11 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd ValueFromPipelineByPropertyName = true, ParameterSetName = VirtualNetworkGatewayParameterSets.AadAuthenticationConfiguration, HelpMessage = "The resource group name.")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = VirtualNetworkGatewayParameterSets.TypeLocalGatewayConfiguration, + HelpMessage = "The resource group name.")] [Parameter( Mandatory = true, ValueFromPipelineByPropertyName = true, @@ -95,6 +105,11 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd ValueFromPipelineByPropertyName = true, ParameterSetName = VirtualNetworkGatewayParameterSets.AadAuthenticationConfiguration, HelpMessage = "location.")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = VirtualNetworkGatewayParameterSets.TypeLocalGatewayConfiguration, + HelpMessage = "location.")] [Parameter( Mandatory = true, ValueFromPipelineByPropertyName = true, @@ -114,10 +129,16 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd [Parameter( Mandatory = false, ValueFromPipelineByPropertyName = true, - HelpMessage = "The type of this virtual network gateway: Vpn, ExoressRoute")] + HelpMessage = "The type of this virtual network gateway: Vpn, ExpressRoute, LocalGateway")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = VirtualNetworkGatewayParameterSets.TypeLocalGatewayConfiguration, + HelpMessage = "The type of this virtual network gateway: Vpn, ExpressRoute, LocalGateway")] [ValidateSet( MNM.VirtualNetworkGatewayType.Vpn, MNM.VirtualNetworkGatewayType.ExpressRoute, + MNM.VirtualNetworkGatewayType.LocalGateway, IgnoreCase = true)] public string GatewayType { get; set; } @@ -307,6 +328,31 @@ public class NewAzureVirtualNetworkGatewayCommand : VirtualNetworkGatewayBaseCmd MNM.VpnGatewayGeneration.Generation2)] public string VpnGatewayGeneration { get; set; } + [Alias("VirtualNetworkResourceId")] + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = VirtualNetworkGatewayParameterSets.TypeLocalGatewayConfiguration, + HelpMessage = "MAS FIJI customer vnet resource id.VirtualNetworkGateway of type local gateway is associated with the customer vnet.")] + public string virtualNetworkExtendedLocationResourceId { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = VirtualNetworkGatewayParameterSets.TypeLocalGatewayConfiguration, + HelpMessage = "The type of extended location")] + [ValidateSet( + MNM.ExtendedLocationType.EgdeZone, + IgnoreCase = true)] + public string ExtendedLocationType { get; set; } + + [Parameter( + Mandatory = true, + ValueFromPipelineByPropertyName = true, + ParameterSetName = VirtualNetworkGatewayParameterSets.TypeLocalGatewayConfiguration, + HelpMessage = "The name of extended location")] + public string ExtendedLocationName { get; set; } + [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] public SwitchParameter AsJob { get; set; } @@ -339,20 +385,67 @@ public override void Execute() Name, () => { - var virtualNetworkGateway = CreateVirtualNetworkGateway(); - WriteObject(virtualNetworkGateway); + var vnetGateway = new PSVirtualNetworkGateway(); + vnetGateway.Name = this.Name; + vnetGateway.ResourceGroupName = this.ResourceGroupName; + vnetGateway.Location = this.Location; + + if (this.ParameterSetName.Equals(VirtualNetworkGatewayParameterSets.TypeLocalGatewayConfiguration)) + { + if (!this.GatewayType.Equals(MNM.VirtualNetworkGatewayType.LocalGateway)) + { + throw new ArgumentException("ExtendedLocation and VirtualNetworkResourceId are required only if Virtual Network Gateway Type is " + MNM.VirtualNetworkGatewayType.LocalGateway); + } + else if (this.VpnGatewayGeneration != null || this.CustomRoute != null || + this.IpConfigurationBgpPeeringAddresses != null || this.PeerWeight > 0 || + this.Asn > 0 || this.VpnClientIpsecPolicy != null || + this.VpnClientRevokedCertificates != null || this.VpnClientRootCertificates != null || + this.VpnClientProtocol != null || this.VpnClientAddressPool != null || + this.GatewayDefaultSite != null || this.GatewaySku != null || + this.EnablePrivateIpAddress != null || this.EnableActiveActiveFeature != null || + this.EnableBgp == true || this.VpnType != null || + this.IpConfigurations != null) + { + throw new ArgumentException("Only parameters ExtendedLocation and VirtualNetworkResourceId are allowed for type " + MNM.VirtualNetworkGatewayType.LocalGateway); + } + else + { + vnetGateway.ExtendedLocation = new PSExtendedLocation(); + vnetGateway.ExtendedLocation.Name = this.ExtendedLocationName; + vnetGateway.ExtendedLocation.Type = this.ExtendedLocationType; + vnetGateway.VirtualNetworkExtendedLocationResourceId = this.virtualNetworkExtendedLocationResourceId; + } + } + else + { + if (this.GatewayType.Equals(MNM.VirtualNetworkGatewayType.LocalGateway)) + { + throw new ArgumentException("ExtendedLocation and VirtualNetworkResourceId are required when Virtual Network Gateway Type is " + MNM.VirtualNetworkGatewayType.LocalGateway); + } + else + { + CreateVirtualNetworkGateway(vnetGateway); + } + } + + // Map to the sdk object + var vnetGatewayModel = NetworkResourceManagerProfile.Mapper.Map(vnetGateway); + + vnetGatewayModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); + + // Execute the Create VirtualNetwork call + this.VirtualNetworkGatewayClient.CreateOrUpdate(this.ResourceGroupName, this.Name, vnetGatewayModel); + + var getVirtualNetworkGateway = this.GetVirtualNetworkGateway(this.ResourceGroupName, this.Name); + + WriteObject(getVirtualNetworkGateway); }, - () => present); + () => present); } - private PSVirtualNetworkGateway CreateVirtualNetworkGateway() - { - var vnetGateway = new PSVirtualNetworkGateway(); - vnetGateway.Name = this.Name; - vnetGateway.ResourceGroupName = this.ResourceGroupName; - vnetGateway.Location = this.Location; - + private void CreateVirtualNetworkGateway(PSVirtualNetworkGateway vnetGateway) + { if (this.GatewaySku != null) { vnetGateway.Sku = new PSVirtualNetworkGatewaySku(); @@ -546,17 +639,6 @@ private PSVirtualNetworkGateway CreateVirtualNetworkGateway() vnetGateway.VpnGatewayGeneration = this.VpnGatewayGeneration; } - - // Map to the sdk object - var vnetGatewayModel = NetworkResourceManagerProfile.Mapper.Map(vnetGateway); - vnetGatewayModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); - - // Execute the Create VirtualNetwork call - this.VirtualNetworkGatewayClient.CreateOrUpdate(this.ResourceGroupName, this.Name, vnetGatewayModel); - - var getVirtualNetworkGateway = this.GetVirtualNetworkGateway(this.ResourceGroupName, this.Name); - - return getVirtualNetworkGateway; } } } diff --git a/src/Network/Network/VirtualNetworkGateway/VirtualNetworkGatewayParameterSets.cs b/src/Network/Network/VirtualNetworkGateway/VirtualNetworkGatewayParameterSets.cs index c1e09ef4fdc1..df213e661a75 100644 --- a/src/Network/Network/VirtualNetworkGateway/VirtualNetworkGatewayParameterSets.cs +++ b/src/Network/Network/VirtualNetworkGateway/VirtualNetworkGatewayParameterSets.cs @@ -17,5 +17,7 @@ public class VirtualNetworkGatewayParameterSets public const string AadAuthenticationConfiguration = @"AadAuthenticationConfiguration"; public const string UpdateResourceWithTags = @"UpdateResourceWithTags"; + + public const string TypeLocalGatewayConfiguration = @"TypeLocalGatewayConfiguration"; } } diff --git a/src/Network/Network/VirtualRouterPeer/GetAzVirtualRouterPeerAdvertisedRouteCommand.cs b/src/Network/Network/VirtualRouterPeer/GetAzVirtualRouterPeerAdvertisedRouteCommand.cs index 34a05239c2c0..0b1a8a07b91d 100644 --- a/src/Network/Network/VirtualRouterPeer/GetAzVirtualRouterPeerAdvertisedRouteCommand.cs +++ b/src/Network/Network/VirtualRouterPeer/GetAzVirtualRouterPeerAdvertisedRouteCommand.cs @@ -72,6 +72,10 @@ private IAzureRestClient ServiceClient public override void Execute() { + WriteWarningWithTimestamp("Upcoming breaking changes in the cmdlet 'Get-AzVirtualRouterAdvertisedRoutes': " + + "The output type 'Microsoft.Azure.Commands.Network.Models.PSVirtualRouterLearnedRoutes' is changing. " + + "Note: Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell."); + base.Execute(); context = DefaultContext; diff --git a/src/Network/Network/VirtualRouterPeer/GetAzVirtualRouterPeerLearnedRouteCommand.cs b/src/Network/Network/VirtualRouterPeer/GetAzVirtualRouterPeerLearnedRouteCommand.cs index 45595a31a921..85c2547aeb42 100644 --- a/src/Network/Network/VirtualRouterPeer/GetAzVirtualRouterPeerLearnedRouteCommand.cs +++ b/src/Network/Network/VirtualRouterPeer/GetAzVirtualRouterPeerLearnedRouteCommand.cs @@ -72,6 +72,10 @@ private IAzureRestClient ServiceClient public override void Execute() { + WriteWarningWithTimestamp("Upcoming breaking changes in the cmdlet 'Get-AzVirtualRouterLearnedRoutes': " + + "The output type 'Microsoft.Azure.Commands.Network.Models.PSVirtualRouterLearnedRoutes' is changing. " + + "Note: Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell."); + base.Execute(); context = DefaultContext; diff --git a/tools/LocalFeed/Microsoft.Azure.Management.Network.1021.533.55418.nupkg b/tools/LocalFeed/Microsoft.Azure.Management.Network.1021.533.55418.nupkg new file mode 100644 index 000000000000..75fd1d858f4b Binary files /dev/null and b/tools/LocalFeed/Microsoft.Azure.Management.Network.1021.533.55418.nupkg differ diff --git a/tools/LocalFeed/Microsoft.Azure.Management.Network.1021.533.55418.snupkg b/tools/LocalFeed/Microsoft.Azure.Management.Network.1021.533.55418.snupkg new file mode 100644 index 000000000000..82c4c58c6a0c Binary files /dev/null and b/tools/LocalFeed/Microsoft.Azure.Management.Network.1021.533.55418.snupkg differ