@@ -40,11 +40,31 @@ function getPrimaryLocation
4040 return " EastUS"
4141}
4242
43+ function getLocationForEZScenario
44+ {
45+ return " eastus2euap"
46+ }
47+
48+ function getLocationForEZAzScenario
49+ {
50+ return " EastUS2"
51+ }
52+
4353function getPrimaryZoneLocation
4454{
4555 return " EastUS"
4656}
4757
58+ function getPrimaryExtendedLocation
59+ {
60+ return " microsoftrrdclab4"
61+ }
62+
63+ function getPrimaryExtendedLocationForAz
64+ {
65+ return " microsoftmiami1"
66+ }
67+
4868function getPrimaryZone
4969{
5070 return " 1"
@@ -59,6 +79,11 @@ function getRecoveryLocation{
5979 return getVaultLocation
6080}
6181
82+ function getRecoveryExtendedLocation
83+ {
84+ return " microsoftrrdclab3"
85+ }
86+
6287function getPrimaryFabric {
6388 return " a2aPrimaryFabric" + $seed
6489
@@ -123,7 +148,7 @@ function getRecoveryNetworkName{
123148}
124149
125150function getCacheStorageAccountName {
126- return " cache " + $seed ;
151+ return " asrcacheps " + $seed ;
127152}
128153
129154function getRecoveryCacheStorageAccountName {
@@ -170,13 +195,13 @@ function createAzureVm{
170195 $PasswordString = $ (Get-RandomSuffix 12 )
171196 $Password = $PasswordString | ConvertTo-SecureString - Force - AsPlainText
172197 $VMLocalAdminSecurePassword = $Password
173- $VMLocation = getPrimaryLocation
174- $VMName = getAzureVmName
198+ $VMLocation = if ( $primaryLocation ) { $primaryLocation } else { getPrimaryLocation }
199+ $VMName = getAzureVmName
175200 $domain = " domain" + $seed
176201 $password = $VMLocalAdminSecurePassword | ConvertTo-SecureString - AsPlainText - Force
177202 $Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser , $password );
178203 $vm = New-AzVM - Name $VMName - Credential $Credential - location $VMLocation - Image RHEL - DomainNameLabel $domain
179- return $vm.Id
204+ return $vm.Id
180205}
181206
182207function createAzureVmInProximityPlacementgroup {
@@ -216,25 +241,79 @@ function createAzureVmForCRG{
216241function createAzureVmInAvailabilityZone {
217242 param ([string ]$primaryLocation )
218243
219- $VMLocalAdminUser = " adminUser"
220- $PasswordString = $ (Get-RandomSuffix 12 )
244+ $VMLocalAdminUser = " adminUser"
245+ $PasswordString = $ (Get-RandomSuffix 12 )
221246 $Password = $PasswordString | ConvertTo-SecureString - Force - AsPlainText
222- $VMLocalAdminSecurePassword = $Password
223- $VMLocation = getPrimaryZoneLocation
247+ $VMLocalAdminSecurePassword = $Password
248+ $VMLocation = if ( $primaryLocation ) { $primaryLocation } else { getPrimaryZoneLocation }
224249 $VMZone = getPrimaryZone
225- $VMName = getAzureVmName
250+ $VMName = getAzureVmName
226251 $domain = " domain" + $seed
227252 $password = $VMLocalAdminSecurePassword | ConvertTo-SecureString - AsPlainText - Force
228- $Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser , $password );
253+ $Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser , $password );
229254 $vm = New-AzVM - Name $VMName - Credential $Credential - location $VMLocation - Image RHEL - DomainNameLabel $domain - Zone $VMZone
230- return $vm.Id
255+ return $vm.Id
256+ }
257+
258+ function createAzureVmInEdgeZone {
259+ param (
260+ [string ]$primaryLocation ,
261+ [string ]$primaryExtendedLocation
262+ )
263+
264+ $VMLocalAdminUser = " adminUser"
265+ $PasswordString = $ (Get-RandomSuffix 12 )
266+ $Password = $PasswordString | ConvertTo-SecureString - Force - AsPlainText
267+ $VMLocalAdminSecurePassword = $Password
268+ $VMLocation = $primaryLocation
269+ $VMExtendedLocation = $primaryExtendedLocation
270+ $VMName = getAzureVmName
271+ $ComputerName = $VMName
272+ $primaryResourceGroupName = $VMName
273+ $domain = " domain" + $seed
274+ $password = $VMLocalAdminSecurePassword | ConvertTo-SecureString - AsPlainText - Force
275+ $Credential = New-Object System.Management.Automation.PSCredential ($VMLocalAdminUser , $password );
276+
277+ $VMSize = " Standard_D2S_V3"
278+ $NetworkName = " MyVNet"
279+ $NICName = " MyNIC"
280+ $SubnetName = " MySubnet"
281+ $SubnetAddressPrefix = " 10.0.0.0/24"
282+ $VnetAddressPrefix = " 10.0.0.0/16"
283+ $ipName = ' myStdPublicIP'
284+
285+ $ip = @ {
286+ Name = $ipName
287+ ResourceGroupName = $primaryResourceGroupName
288+ Location = $VMLocation
289+ EdgeZone = $VMExtendedLocation
290+ Sku = ' Standard'
291+ AllocationMethod = ' Static'
292+ IpAddressVersion = ' IPv4'
293+ }
294+ New-AzPublicIpAddress @ip
295+
296+ $pip = Get-AzPublicIpAddress - Name $ipName - ResourceGroupName $primaryResourceGroupName
297+ $SingleSubnet = New-AzVirtualNetworkSubnetConfig - Name $SubnetName - AddressPrefix $SubnetAddressPrefix
298+ $Vnet = New-AzVirtualNetwork - Name $NetworkName - ResourceGroupName $primaryResourceGroupName - Location $VMLocation - AddressPrefix $VnetAddressPrefix - Subnet $SingleSubnet - EdgeZone $VMExtendedLocation
299+ $subnet = Get-AzVirtualNetworkSubnetConfig - Name $SubnetName - VirtualNetwork $vnet
300+ $IpConfigVm = New-AzNetworkInterfaceIpConfig - Name " IpConfigVm" - Subnet $subnet - PublicIpAddress $pip - Primary
301+ $NIC = New-AzNetworkInterface - Name $NICName - ResourceGroupName $primaryResourceGroupName - Location $VMLocation - EdgeZone $VMExtendedLocation - IpConfiguration $IpConfigVm
302+
303+ $VirtualMachine = New-AzVMConfig - VMName $VMName - VMSize $VMSize
304+ $VirtualMachine = Add-AzVMNetworkInterface - VM $VirtualMachine - Id $NIC.Id
305+ $VirtualMachine = Set-AzVMOperatingSystem - VM $VirtualMachine - Windows - ComputerName $ComputerName - Credential $Credential - ProvisionVMAgent - EnableAutoUpdate
306+ $VirtualMachine = Set-AzVMSourceImage - VM $VirtualMachine - PublisherName ' MicrosoftWindowsServer' - Offer ' WindowsServer' - Skus ' 2019-Datacenter' - Version latest
307+ $VirtualMachine | Set-AzVMBootDiagnostic - disable
308+ $vm = New-AzVM - ResourceGroupName $primaryResourceGroupName - Location $VMLocation - VM $VirtualMachine - EdgeZone $VMExtendedLocation
309+ return $vm.Id
231310}
232311
233312function createRecoveryNetworkId {
234313 param ([string ] $location , [string ] $resourceGroup )
235314
236315 $NetworkName = getRecoveryNetworkName
237- $NetworkLocation = getRecoveryLocation
316+ $NetworkLocation = if ( $location ) { $location } else { getRecoveryLocation }
238317 $ResourceGroupName = getRecoveryResourceGroupName
239318 $frontendSubnet = New-AzVirtualNetworkSubnetConfig - Name frontendSubnet - AddressPrefix " 10.0.1.0/24"
240319 $virtualNetwork = New-AzVirtualNetwork `
@@ -249,7 +328,7 @@ function createRecoveryNetworkIdForZone{
249328 param ([string ] $location , [string ] $resourceGroup )
250329
251330 $NetworkName = getRecoveryNetworkName
252- $NetworkLocation = getPrimaryZoneLocation
331+ $NetworkLocation = if ( $location ) { $location } else { getPrimaryZoneLocation }
253332 $ResourceGroupName = getRecoveryResourceGroupName
254333 $frontendSubnet = New-AzVirtualNetworkSubnetConfig - Name frontendSubnet - AddressPrefix " 10.0.1.0/24"
255334 $virtualNetwork = New-AzVirtualNetwork `
@@ -260,11 +339,27 @@ function createRecoveryNetworkIdForZone{
260339 return $virtualNetwork.Id
261340}
262341
342+ function createRecoveryNetworkIdForEdgeZone {
343+ param ([string ] $location , [string ] $resourceGroup , [string ] $edgeZone )
344+
345+ $NetworkName = getRecoveryNetworkName
346+ $NetworkLocation = if ($location ) { $location } else { getPrimaryExtendedLocation }
347+ $ResourceGroupName = if ($resourceGroup ) { $resourceGroup } else { getRecoveryResourceGroupName }
348+ $EdgeZone = if ($edgeZone ) { $edgeZone } else { getRecoveryExtendedLocation }
349+ $frontendSubnet = New-AzVirtualNetworkSubnetConfig - Name frontendSubnet - AddressPrefix " 10.0.1.0/24"
350+ $virtualNetwork = New-AzVirtualNetwork `
351+ - ResourceGroupName $ResourceGroupName `
352+ - Location $NetworkLocation `
353+ - Name $NetworkName `
354+ - AddressPrefix 10.0 .0.0 / 16 - Subnet $frontendSubnet - EdgeZone $edgeZone
355+ return $virtualNetwork.Id
356+ }
357+
263358function createCacheStorageAccount {
264359 param ([string ] $location , [string ] $resourceGroup )
265360
266361 $StorageAccountName = getCacheStorageAccountName
267- $cacheLocation = getPrimaryLocation
362+ $cacheLocation = if ( $location ) { $location } else { getPrimaryLocation }
268363 $storageRes = getAzureVmName
269364 $storageAccount = New-AzStorageAccount `
270365 - ResourceGroupName $storageRes `
0 commit comments