Skip to content

Commit a3dc6d8

Browse files
committed
merge network changes
2 parents 27097cd + 82bbfed commit a3dc6d8

File tree

72 files changed

+61025
-76
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+61025
-76
lines changed

ChangeLog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134
* Added SoftDelete feature for VM and added tests for softdelete
135135

136136
#### Az.Resources
137-
* Update dependency assemlby Microsoft.Extensions.Caching.Memory from 1.1.1 to 2.2
137+
* Update dependency assembly Microsoft.Extensions.Caching.Memory from 1.1.1 to 2.2
138138

139139
#### Az.Network
140140
* Change all cmdlets for PrivateEndpointConnection to support generic service provider.

src/Accounts/Accounts/AzureRmAlias/Mappings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,7 +1262,7 @@
12621262
"Set-AzApplicationGatewayAutoscaleConfiguration": "Set-AzureRmApplicationGatewayAutoscaleConfiguration",
12631263
"Set-AzApplicationGatewayAuthenticationCertificate": "Set-AzureRmApplicationGatewayAuthenticationCertificate",
12641264
"Get-AzApplicationGatewayAvailableWafRuleSets": "Get-AzureRmApplicationGatewayAvailableWafRuleSets",
1265-
"Get-AzApplicationGatewayAvailableServerVariableAndHeader": "Get-AzureRmApplicationGatewayAvailableServerVariableAndHeader",
1265+
"Get-AzApplicationGatewayAvailableServerVariableAndHeader": "Get-AzureRmApplicationGatewayAvailableServerVariableAndHeader",
12661266
"Get-AzApplicationGatewayAvailableSslOptions": "Get-AzureRmApplicationGatewayAvailableSslOptions",
12671267
"Add-AzApplicationGatewayBackendAddressPool": "Add-AzureRmApplicationGatewayBackendAddressPool",
12681268
"Get-AzApplicationGatewayBackendAddressPool": "Get-AzureRmApplicationGatewayBackendAddressPool",
@@ -2519,4 +2519,4 @@
25192519
"New-AzWebAppAzureStoragePath": "New-AzureRmWebAppAzureStoragePath",
25202520
"Swap-AzWebAppSlot": "Swap-AzureRmWebAppSlot"
25212521
}
2522-
}
2522+
}

src/Network/Network.Test/ScenarioTests/AzureFirewallTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,13 @@ public void TestAzureFirewallVirtualHubCRUD()
6666
TestRunner.RunTestScript("Test-AzureFirewallVirtualHubCRUD");
6767
}
6868

69+
[Fact]
70+
[Trait(Category.AcceptanceType, Category.CheckIn)]
71+
[Trait(Category.Owner, NrpTeamAlias.azurefirewall)]
72+
public void TestAzureFirewallThreatIntelWhitelistCRUD()
73+
{
74+
TestRunner.RunTestScript("Test-AzureFirewallThreatIntelWhitelistCRUD");
75+
}
76+
6977
}
7078
}

src/Network/Network.Test/ScenarioTests/AzureFirewallTests.ps1

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,3 +1156,52 @@ function Test-AzureFirewallVirtualHubCRUD {
11561156
Clean-ResourceGroup $rgname
11571157
}
11581158
}
1159+
1160+
<#
1161+
.SYNOPSIS
1162+
Tests AzureFirewall ThreatIntelWhitelist
1163+
#>
1164+
function Test-AzureFirewallThreatIntelWhitelistCRUD {
1165+
$rgname = Get-ResourceGroupName
1166+
$azureFirewallName = Get-ResourceName
1167+
$resourceTypeParent = "Microsoft.Network/AzureFirewalls"
1168+
$location = Get-ProviderLocation $resourceTypeParent "eastus2euap"
1169+
1170+
$vnetName = Get-ResourceName
1171+
$subnetName = "AzureFirewallSubnet"
1172+
$publicIpName = Get-ResourceName
1173+
1174+
$threatIntelWhitelist1 = New-AzFirewallThreatIntelWhitelist -FQDN @("*.microsoft.com", "microsoft.com") -IpAddress @("8.8.8.8", "1.1.1.1")
1175+
$threatIntelWhitelist2 = New-AzFirewallThreatIntelWhitelist -IpAddress @(" 2.2.2.2 "," 3.3.3.3 ") -FQDN @(" bing.com ", "yammer.com ")
1176+
1177+
try {
1178+
# Create the resource group
1179+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $location
1180+
1181+
# Create the Virtual Network
1182+
$subnet = New-AzVirtualNetworkSubnetConfig -Name $subnetName -AddressPrefix 10.0.0.0/24
1183+
$vnet = New-AzVirtualNetwork -Name $vnetName -ResourceGroupName $rgname -Location $location -AddressPrefix 10.0.0.0/16 -Subnet $subnet
1184+
1185+
# Create public ip
1186+
$publicip = New-AzPublicIpAddress -ResourceGroupName $rgname -name $publicIpName -location $location -AllocationMethod Static -Sku Standard
1187+
1188+
# Create AzureFirewall
1189+
$azureFirewall = New-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname -Location $location -ThreatIntelWhitelist $threatIntelWhitelist1
1190+
1191+
# Verify
1192+
$getAzureFirewall = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
1193+
Assert-AreEqualArray $threatIntelWhitelist1.FQDNs $getAzureFirewall.ThreatIntelWhitelist.FQDNs
1194+
Assert-AreEqualArray $threatIntelWhitelist1.IpAddresses $getAzureFirewall.ThreatIntelWhitelist.IpAddresses
1195+
1196+
# Modify
1197+
$azureFirewall.ThreatIntelWhitelist = $threatIntelWhitelist2
1198+
Set-AzFirewall -AzureFirewall $azureFirewall
1199+
$getAzureFirewall = Get-AzFirewall -Name $azureFirewallName -ResourceGroupName $rgname
1200+
Assert-AreEqualArray $threatIntelWhitelist2.FQDNs $getAzureFirewall.ThreatIntelWhitelist.FQDNs
1201+
Assert-AreEqualArray $threatIntelWhitelist2.IpAddresses $getAzureFirewall.ThreatIntelWhitelist.IpAddresses
1202+
}
1203+
finally {
1204+
# Cleanup
1205+
Clean-ResourceGroup $rgname
1206+
}
1207+
}

src/Network/Network.Test/ScenarioTests/CortexTests.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,13 @@ public void TestCortexDownloadConfig()
5050
{
5151
TestRunner.RunTestScript("Test-CortexDownloadConfig");
5252
}
53+
54+
[Fact]
55+
[Trait(Category.AcceptanceType, Category.LiveOnly)]
56+
[Trait(Category.Owner, NrpTeamAlias.brooklynft)]
57+
public void TestP2SCortexCRUD()
58+
{
59+
TestRunner.RunTestScript("Test-P2SCortexCRUD");
60+
}
5361
}
5462
}

src/Network/Network.Test/ScenarioTests/CortexTests.ps1

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,4 +481,208 @@ function Test-CortexExpressRouteCRUD
481481
{
482482
Clean-ResourceGroup $rgname
483483
}
484+
}
485+
486+
<# .SYNOPSIS
487+
Point to site Cortex feature tests
488+
#>
489+
function Test-P2SCortexCRUD
490+
{
491+
param
492+
(
493+
$basedir = ".\"
494+
)
495+
496+
# Setup
497+
$rgname = Get-ResourceGroupName
498+
$rglocation = Get-ProviderLocation "Microsoft.Network/VirtualWans"
499+
500+
$virtualWanName = Get-ResourceName
501+
$virtualHubName = Get-ResourceName
502+
$VpnServerConfiguration1Name = Get-ResourceName
503+
$VpnServerConfiguration2Name = Get-ResourceName
504+
$P2SVpnGatewayName = Get-ResourceName
505+
$vpnclientAuthMethod = "EAPTLS"
506+
507+
$storeName = 'blob' + $rgName
508+
509+
try
510+
{
511+
# Create the resource group
512+
$resourceGroup = New-AzResourceGroup -Name $rgname -Location $rglocation
513+
514+
# Create the Virtual Wan
515+
$createdVirtualWan = New-AzVirtualWan -ResourceGroupName $rgName -Name $virtualWanName -Location $rglocation
516+
$virtualWan = Get-AzVirtualWan -ResourceGroupName $rgName -Name $virtualWanName
517+
Assert-AreEqual $rgName $virtualWan.ResourceGroupName
518+
Assert-AreEqual $virtualWanName $virtualWan.Name
519+
520+
# Create the Virtual Hub
521+
$createdVirtualHub = New-AzVirtualHub -ResourceGroupName $rgName -Name $virtualHubName -Location $rglocation -AddressPrefix "192.168.1.0/24" -VirtualWan $virtualWan
522+
$virtualHub = Get-AzVirtualHub -ResourceGroupName $rgName -Name $virtualHubName
523+
Assert-AreEqual $rgName $virtualHub.ResourceGroupName
524+
Assert-AreEqual $virtualHubName $virtualHub.Name
525+
Assert-AreEqual $virtualWan.Id $virtualhub.VirtualWan.Id
526+
527+
# Create the VpnServerConfiguration1 with VpnClient settings using New-AzVpnServerConfiguration
528+
$VpnServerConfigCertFilePath = Join-Path -Path $basedir -ChildPath "\ScenarioTests\Data\ApplicationGatewayAuthCert.cer"
529+
$listOfCerts = New-Object "System.Collections.Generic.List[String]"
530+
$listOfCerts.Add($VpnServerConfigCertFilePath)
531+
$vpnclientipsecpolicy1 = New-AzVpnClientIpsecPolicy -IpsecEncryption AES256 -IpsecIntegrity SHA256 -SALifeTime 86471 -SADataSize 429496 -IkeEncryption AES256 -IkeIntegrity SHA384 -DhGroup DHGroup14 -PfsGroup PFS14
532+
New-AzVpnServerConfiguration -Name $VpnServerConfiguration1Name -ResourceGroupName $rgName -VpnProtocol IkeV2 -VpnAuthenticationType Certificate -VpnClientRootCertificateFilesList $listOfCerts -VpnClientRevokedCertificateFilesList $listOfCerts -VpnClientIpsecPolicy $vpnclientipsecpolicy1 -Location $rglocation
533+
534+
# Get created VpnServerConfiguration using Get-AzVpnServerConfiguration
535+
$vpnServerConfig1 = Get-AzVpnServerConfiguration -ResourceGroupName $rgName -Name $VpnServerConfiguration1Name
536+
Assert-NotNull $vpnServerConfig1
537+
Assert-AreEqual $rgName $vpnServerConfig1.ResourceGroupName
538+
Assert-AreEqual $VpnServerConfiguration1Name $vpnServerConfig1.Name
539+
$protocols = $vpnServerConfig1.VpnProtocols
540+
Assert-AreEqual 1 @($protocols).Count
541+
Assert-AreEqual "IkeV2" $protocols[0]
542+
$authenticationTypes = $vpnServerConfig1.VpnAuthenticationTypes
543+
Assert-AreEqual 1 @($authenticationTypes).Count
544+
Assert-AreEqual "Certificate" $authenticationTypes[0]
545+
546+
# Create the P2SVpnGateway using New-AzP2sVpnGateway
547+
$vpnClientAddressSpaces = New-Object string[] 2
548+
$vpnClientAddressSpaces[0] = "192.168.2.0/24"
549+
$vpnClientAddressSpaces[1] = "192.168.3.0/24"
550+
$createdP2SVpnGateway = New-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName -VirtualHub $virtualHub -VpnGatewayScaleUnit 1 -VpnClientAddressPool $vpnClientAddressSpaces -VpnServerConfiguration $vpnServerConfig1
551+
Assert-AreEqual "Succeeded" $createdP2SVpnGateway.ProvisioningState
552+
553+
# Get the created P2SVpnGateway using Get-AzP2sVpnGateway
554+
$P2SVpnGateway = Get-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName
555+
Assert-AreEqual $rgName $P2SVpnGateway.ResourceGroupName
556+
Assert-AreEqual $P2SvpnGatewayName $P2SVpnGateway.Name
557+
Assert-AreEqual $vpnServerConfig1.Id $P2SVpnGateway.VpnServerConfiguration.Id
558+
Assert-AreEqual "Succeeded" $P2SVpnGateway.ProvisioningState
559+
560+
# Get all associated VpnServerConfigurations at Wan level using Get-AzVirtualWanVpnServerConfiguration
561+
$associatedVpnServerConfigs = Get-AzVirtualWanVpnServerConfiguration -Name $virtualWanName -ResourceGroupName $rgName
562+
Assert-NotNull $associatedVpnServerConfigs
563+
Assert-AreEqual 1 @($associatedVpnServerConfigs.VpnServerConfigurationResourceIds).Count
564+
Assert-AreEqual $vpnServerConfig1.Id $associatedVpnServerConfigs.VpnServerConfigurationResourceIds[0]
565+
566+
# Get VpnServerConfiguration1 and see that it shows as attached to P2SVpnGateway created.
567+
$vpnServerConfig1 = Get-AzVpnServerConfiguration -ResourceGroupName $rgName -Name $VpnServerConfiguration1Name
568+
Assert-NotNull $vpnServerConfig1
569+
Assert-AreEqual $vpnServerConfig1.P2sVpnGateways[0].Id $P2SVpnGateway.Id
570+
571+
# List all VpnServerConfigurations under Resource group
572+
$vpnServerConfigs = Get-AzVpnServerConfiguration -ResourceGroupName $rgName
573+
Assert-NotNull $vpnServerConfigs
574+
Assert-AreEqual 1 @($vpnServerConfigs).Count
575+
576+
# Generate vpn profile at Hub/P2SVpnGateway level using Get-AzP2sVpnGatewayVpnProfile
577+
$vpnProfileResponse = Get-AzP2sVpnGatewayVpnProfile -Name $P2SVpnGatewayName -ResourceGroupName $rgName -AuthenticationMethod $vpnclientAuthMethod
578+
Assert-NotNull $vpnProfileResponse.ProfileUrl
579+
Assert-AreEqual True ($vpnProfileResponse.ProfileUrl -Match "zip")
580+
581+
# Generate vpn profile at Wan-VpnServerConfiguration combination level using Get-AzP2sVpnGatewayVpnProfile
582+
$vpnProfileWanResponse = Get-AzVirtualWanVpnServerConfigurationVpnProfile -Name $virtualWanName -ResourceGroupName $rgName -AuthenticationMethod $vpnclientAuthMethod -VpnServerConfiguration $vpnServerConfig1
583+
Assert-NotNull $vpnProfileWanResponse.ProfileUrl
584+
Assert-AreEqual True ($vpnProfileWanResponse.ProfileUrl -Match "zip")
585+
586+
# Create the VpnServerConfiguration2 with RadiusClient settings using New-AzVpnServerConfiguration
587+
#[SuppressMessage("Microsoft.Security", "CS002:SecretInNextLine", Justification="Test passwords only valid for the duration of the test")]
588+
$Secure_String_Pwd = ConvertTo-SecureString "TestRadiusServerPassword" -AsPlainText -Force
589+
New-AzVpnServerConfiguration -Name $VpnServerConfiguration2Name -ResourceGroupName $rgName -VpnProtocol IkeV2 -VpnAuthenticationType Radius -RadiusServerAddress "TestRadiusServer" -RadiusServerSecret $Secure_String_Pwd -RadiusServerRootCertificateFilesList $listOfCerts -RadiusClientRootCertificateFilesList $listOfCerts -Location $rglocation
590+
591+
$vpnServerConfig2 = Get-AzVpnServerConfiguration -ResourceGroupName $rgName -Name $VpnServerConfiguration2Name
592+
Assert-AreEqual "Succeeded" $vpnServerConfig2.ProvisioningState
593+
Assert-AreEqual "TestRadiusServer" $vpnServerConfig2.RadiusServerAddress
594+
595+
# List all VpnServerConfigurations under Resource group
596+
$vpnServerConfigs = Get-AzVpnServerConfiguration -ResourceGroupName $rgName
597+
Assert-NotNull $vpnServerConfigs
598+
Assert-AreEqual 2 @($vpnServerConfigs).Count
599+
600+
# Update existing VpnServerConfiguration2 using Update-AzVpnServerConfiguration
601+
Update-AzVpnServerConfiguration -Name $VpnServerConfiguration2Name -ResourceGroupName $rgName -RadiusServerAddress "TestRadiusServer1"
602+
$VpnServerConfig2 = Get-AzVpnServerConfiguration -Name $VpnServerConfiguration2Name -ResourceGroupName $rgName
603+
Assert-AreEqual $VpnServerConfiguration2Name $VpnServerConfig2.Name
604+
Assert-AreEqual "TestRadiusServer1" $VpnServerConfig2.RadiusServerAddress
605+
606+
Update-AzVpnServerConfiguration -ResourceId $VpnServerConfig2.Id -RadiusServerAddress "TestRadiusServer2"
607+
$VpnServerConfig2Get = Get-AzVpnServerConfiguration -ResourceGroupName $rgName -Name $VpnServerConfiguration2Name
608+
Assert-AreEqual "TestRadiusServer2" $VpnServerConfig2Get.RadiusServerAddress
609+
610+
Update-AzVpnServerConfiguration -InputObject $VpnServerConfig2Get -RadiusServerAddress "TestRadiusServer3"
611+
$VpnServerConfig2Get = Get-AzVpnServerConfiguration -ResourceGroupName $rgName -Name $VpnServerConfiguration2Name
612+
Assert-AreEqual "TestRadiusServer3" $VpnServerConfig2Get.RadiusServerAddress
613+
614+
# Update existing P2SVpnGateway with new VpnClientAddressPool using Update-AzP2sVpnGateway
615+
$vpnClientAddressSpaces[1] = "192.168.4.0/24"
616+
$updatedP2SVpnGateway = Update-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName -VpnClientAddressPool $vpnClientAddressSpaces
617+
618+
$P2SVpnGateway = Get-AzP2sVpnGateway -ResourceGroupName $rgName -Name $P2SvpnGatewayName
619+
Assert-AreEqual $P2SvpnGatewayName $P2SVpnGateway.Name
620+
Assert-AreEqual "Succeeded" $P2SVpnGateway.ProvisioningState
621+
Assert-AreEqual $vpnServerConfig1.Id $P2SVpnGateway.VpnServerConfiguration.Id
622+
$setVpnClientAddressSpacesString = [system.String]::Join(" ", $vpnClientAddressSpaces)
623+
Assert-AreEqual $setVpnClientAddressSpacesString $P2SVpnGateway.P2SConnectionConfigurations[0].VpnClientAddressPool.AddressPrefixes
624+
625+
$associatedVpnServerConfigs = Get-AzVirtualWanVpnServerConfiguration -ResourceId $virtualWan.Id
626+
Assert-NotNull $associatedVpnServerConfigs
627+
Assert-AreEqual 1 @($associatedVpnServerConfigs.VpnServerConfigurationResourceIds).Count
628+
Assert-AreEqual $vpnServerConfig1.Id $associatedVpnServerConfigs.VpnServerConfigurationResourceIds[0]
629+
630+
# Delete VpnServerConfiguration2 using Remove-AzVirtualWanVpnServerConfiguration
631+
$delete = Remove-AzVpnServerConfiguration -InputObject $VpnServerConfig2Get -Force -PassThru
632+
Assert-AreEqual $True $delete
633+
634+
$vpnServerConfigs = Get-AzVpnServerConfiguration -ResourceGroupName $rgName
635+
Assert-NotNull $vpnServerConfigs
636+
Assert-AreEqual 1 @($vpnServerConfigs).Count
637+
638+
# Get aggreagated point to site connections health from P2SVpnGateway
639+
#$aggregatedConnectionHealth = Get-AzP2sVpnGatewayConnectionHealth -Name $P2SvpnGatewayName -ResourceGroupName $rgName
640+
#Assert-NotNull $aggregatedConnectionHealth
641+
#Assert-NotNull $aggregatedConnectionHealth.VpnClientConnectionHealth
642+
#Assert-AreEqual 0 $aggregatedConnectionHealth.VpnClientConnectionHealth.VpnClientConnectionsCount
643+
644+
# Get a SAS url for getting detained point to site connections health details.
645+
$storetype = 'Standard_GRS'
646+
$containerName = "cont$($rgName)"
647+
New-AzStorageAccount -ResourceGroupName $rgName -Name $storeName -Location $rglocation -Type $storetype
648+
$key = Get-AzStorageAccountKey -ResourceGroupName $rgName -Name $storeName
649+
$context = New-AzStorageContext -StorageAccountName $storeName -StorageAccountKey $key[0].Value
650+
New-AzStorageContainer -Name $containerName -Context $context
651+
$container = Get-AzStorageContainer -Name $containerName -Context $context
652+
New-Item -Name EmptyFile.txt -ItemType File -Force
653+
Set-AzStorageBlobContent -File "EmptyFile.txt" -Container $containerName -Blob "emptyfile.txt" -Context $context
654+
$now=get-date
655+
$blobSasUrl = New-AzStorageBlobSASToken -Container $containerName -Blob emptyfile.txt -Context $context -Permission "rwd" -StartTime $now.AddHours(-1) -ExpiryTime $now.AddDays(1) -FullUri
656+
657+
# Get detailed point to site connections health from P2SVpnGateway
658+
$detailedConnectionHealth = Get-AzP2sVpnGatewayDetailedConnectionHealth -Name $P2SvpnGatewayName -ResourceGroupName $rgName -OutputBlobSasUrl $blobSasUrl
659+
Assert-NotNull $detailedConnectionHealth
660+
Assert-NotNull $detailedConnectionHealth.SasUrl
661+
Assert-AreEqual $blobSasUrl $detailedConnectionHealth.SasUrl
662+
}
663+
finally
664+
{
665+
# Delete P2SVpnGateway using Remove-AzP2sVpnGateway
666+
$delete = Remove-AzP2sVpnGateway -Name $P2SVpnGatewayName -ResourceGroupName $rgName -Force -PassThru
667+
Assert-AreEqual $True $delete
668+
669+
# Verify that there are no associated VpnServerConfigurations to Virtual wan anymore
670+
$associatedVpnServerConfigs = Get-AzVirtualWanVpnServerConfiguration -Name $virtualWanName -ResourceGroupName $rgName
671+
Assert-NotNull $associatedVpnServerConfigs
672+
Assert-AreEqual 0 @($associatedVpnServerConfigs.VpnServerConfigurationResourceIds).Count
673+
674+
# Delete VpnServerConfiguration1 using Remove-AzVpnServerConfiguration
675+
$delete = Remove-AzVpnServerConfiguration -ResourceGroupName $rgName -Name $VpnServerConfiguration1Name -Force -PassThru
676+
Assert-AreEqual $True $delete
677+
678+
# Delete Virtual hub
679+
$delete = Remove-AzVirtualHub -ResourceGroupName $rgname -Name $virtualHubName -Force -PassThru
680+
Assert-AreEqual $True $delete
681+
682+
# Delete Virtual wan
683+
$delete = Remove-AzVirtualWan -InputObject $virtualWan -Force -PassThru
684+
Assert-AreEqual $True $delete
685+
686+
Clean-ResourceGroup $rgname
687+
}
484688
}

src/Network/Network.Test/SessionRecords/Commands.Network.Test.ScenarioTests.AzureFirewallTests/TestAzureFirewallThreatIntelWhitelistCRUD.json

Lines changed: 2381 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)