@@ -34,7 +34,15 @@ param (
3434 [Parameter (ParameterSetName = " default" , Mandatory = $false )]
3535 [Parameter (ParameterSetName = " tenant" , Mandatory = $false )]
3636 [ValidateScript ({Test-Path - Path $_ })]
37- [string ]$WindowsVHDPath ,
37+ [string ]$WindowsVHDPath ,
38+ [parameter (HelpMessage = " Path for Linux VHD" )]
39+ [Parameter (ParameterSetName = " default" , Mandatory = $false )]
40+ [Parameter (ParameterSetName = " tenant" , Mandatory = $false )]
41+ [string ] $LinuxImagePath = " https://partner-images.canonical.com/azure/azure_stack/ubuntu-14.04-LTS-microsoft_azure_stack-20161208-9.vhd.zip" ,
42+ [parameter (HelpMessage = " Linux OS sku" )]
43+ [Parameter (ParameterSetName = " default" , Mandatory = $false )]
44+ [Parameter (ParameterSetName = " tenant" , Mandatory = $false )]
45+ [string ] $LinuxOSSku = " 14.04.3-LTS" ,
3846 [parameter (HelpMessage = " Fully qualified domain name of the azure stack environment. Ex: contoso.com" )]
3947 [Parameter (ParameterSetName = " default" , Mandatory = $false )]
4048 [Parameter (ParameterSetName = " tenant" , Mandatory = $false )]
@@ -92,21 +100,17 @@ Import-Module -Name $PSScriptRoot\..\Connect\AzureStack.Connect.psm1 -Force
92100Import-Module - Name $PSScriptRoot \..\Infrastructure\AzureStack.Infra.psm1 - Force
93101Import-Module - Name $PSScriptRoot \..\ComputeAdmin\AzureStack.ComputeAdmin.psm1 - Force
94102
95- $storageAccName = $CanaryUtilitiesRG + " sa"
96- $storageCtrName = $CanaryUtilitiesRG + " sc"
97- $keyvaultName = $CanaryUtilitiesRG + " kv"
98- $keyvaultCertName = " ASCanaryVMCertificate"
99- $kvSecretName = $keyvaultName.ToLowerInvariant () + " secret"
100- $VMAdminUserName = " CanaryAdmin"
101- $VMAdminUserPass = " CanaryAdmin@123"
102- $canaryUtilPath = Join-Path - Path $env: TEMP - ChildPath " CanaryUtilities$ ( (Get-Date ).ToString(" -yyMMdd-hhmmss" )) "
103-
104- if (-not $EnvironmentDomainFQDN )
105- {
106- $endptres = Invoke-RestMethod " ${AdminArmEndpoint} /metadata/endpoints?api-version=1.0" - ErrorAction Stop
107- $EnvironmentDomainFQDN = $endptres.portalEndpoint
108- $EnvironmentDomainFQDN = $EnvironmentDomainFQDN.Replace ($EnvironmentDomainFQDN.Split (" ." )[0 ], " " ).TrimEnd(" /" ).TrimStart(" ." )
109- }
103+ $storageAccName = $CanaryUtilitiesRG + " sa"
104+ $storageCtrName = $CanaryUtilitiesRG + " sc"
105+ $keyvaultName = $CanaryUtilitiesRG + " kv"
106+ $keyvaultCertName = " ASCanaryVMCertificate"
107+ $kvSecretName = $keyvaultName.ToLowerInvariant () + " secret"
108+ $VMAdminUserName = " CanaryAdmin"
109+ $VMAdminUserPass = " CanaryAdmin@123"
110+ $canaryUtilPath = Join-Path - Path $env: TEMP - ChildPath " CanaryUtilities$ ( (Get-Date ).ToString(" -yyMMdd-hhmmss" )) "
111+ $linuxImagePublisher = " Canonical"
112+ $linuxImageOffer = " UbuntuServer"
113+ $linuxImageVersion = " 1.0.0"
110114
111115$runCount = 1
112116while ($runCount -le $NumberOfIterations )
@@ -127,6 +131,13 @@ while ($runCount -le $NumberOfIterations)
127131 $SvcAdminEnvironmentName = $EnvironmentName + " -SVCAdmin"
128132 $TntAdminEnvironmentName = $EnvironmentName + " -Tenant"
129133
134+ if (-not $EnvironmentDomainFQDN )
135+ {
136+ $endptres = Invoke-RestMethod " ${AdminArmEndpoint} /metadata/endpoints?api-version=1.0" - ErrorAction Stop
137+ $EnvironmentDomainFQDN = $endptres.portalEndpoint
138+ $EnvironmentDomainFQDN = $EnvironmentDomainFQDN.Replace ($EnvironmentDomainFQDN.Split (" ." )[0 ], " " ).TrimEnd(" /" ).TrimStart(" ." )
139+ }
140+
130141 Invoke-Usecase - Name ' CreateAdminAzureStackEnv' - Description " Create Azure Stack environment $SvcAdminEnvironmentName " - UsecaseBlock `
131142 {
132143 $asEndpoints = GetAzureStackEndpoints - EnvironmentDomainFQDN $EnvironmentDomainFQDN - ArmEndpoint $AdminArmEndpoint
@@ -144,7 +155,7 @@ while ($runCount -le $NumberOfIterations)
144155
145156 Invoke-Usecase - Name ' LoginToAzureStackEnvAsSvcAdmin' - Description " Login to $SvcAdminEnvironmentName as service administrator" - UsecaseBlock `
146157 {
147- Add-AzureRmAccount - EnvironmentName $SvcAdminEnvironmentName - Credential $ServiceAdminCredentials - TenantId $AADTenantID - ErrorAction Stop
158+ Add-AzureRmAccount - EnvironmentName $SvcAdminEnvironmentName - Credential $ServiceAdminCredentials - TenantId $TenantID - ErrorAction Stop
148159 }
149160
150161 Invoke-Usecase - Name ' SelectDefaultProviderSubscription' - Description " Select the Default Provider Subscription" - UsecaseBlock `
@@ -154,19 +165,35 @@ while ($runCount -le $NumberOfIterations)
154165 {
155166 $defaultSubscription | Select-AzureRmSubscription
156167 }
157- }
158-
168+ }
169+
159170 if ($WindowsISOPath )
160171 {
161172 Invoke-Usecase - Name ' UploadWindows2016ImageToPIR' - Description " Uploads a windows server 2016 image to the PIR" - UsecaseBlock `
162173 {
163174 if (-not (Get-AzureRmVMImage - Location $ResourceLocation - PublisherName " MicrosoftWindowsServer" - Offer " WindowsServer" - Sku " 2016-Datacenter-Core" - ErrorAction SilentlyContinue))
164175 {
165- New-Server2016VMImage - ISOPath $WindowsISOPath - TenantId $AADTenantID - ArmEndpoint $AdminArmEndpoint - Version Core - AzureStackCredentials $ServiceAdminCredentials - CreateGalleryItem $false
176+ New-Server2016VMImage - ISOPath $WindowsISOPath - TenantId $TenantID - ArmEndpoint $AdminArmEndpoint - Version Core - AzureStackCredentials $ServiceAdminCredentials - CreateGalleryItem $false
177+ }
178+ }
179+ }
180+
181+ Invoke-Usecase - Name ' UploadLinuxImageToPIR' - Description " Uploads Linux image to the PIR" - UsecaseBlock `
182+ {
183+ if (-not (Get-AzureRmVMImage - Location $ResourceLocation - PublisherName $linuxImagePublisher - Offer $linuxImageOffer - Sku $LinuxOSSku - ErrorAction SilentlyContinue))
184+ {
185+ $CanaryCustomImageFolder = Join-Path - Path $env: TMP - childPath " CanaryCustomImage$ ( (Get-Date ).ToString(" -yyMMdd-hhmmss" )) "
186+ if (Test-Path - Path $CanaryCustomImageFolder )
187+ {
188+ Remove-Item - Path $CanaryCustomImageFolder - Force - Recurse
166189 }
190+ New-Item - Path $CanaryCustomImageFolder - ItemType Directory
191+ $CustomVHDPath = CopyImage - ImagePath $LinuxImagePath - OutputFolder $CanaryCustomImageFolder
192+ Add-VMImage - publisher $linuxImagePublisher - offer $linuxImageOffer - sku $LinuxOSSku - version $linuxImageVersion - osDiskLocalPath $CustomVHDPath - osType Linux - tenantID $TenantID - azureStackCredentials $ServiceAdminCredentials - CreateGalleryItem $false - ArmEndpoint $AdminArmEndpoint
193+ Remove-Item $CanaryCustomImageFolder - Recurse
167194 }
168195 }
169-
196+
170197 if ($TenantAdminCredentials )
171198 {
172199 $subscriptionRGName = " ascansubscrrg" + [Random ]::new().Next(1 , 999 )
@@ -205,9 +232,9 @@ while ($runCount -le $NumberOfIterations)
205232
206233 Invoke-Usecase - Name ' CreateTenantPlan' - Description " Create a tenant plan" - UsecaseBlock `
207234 {
208- $asToken = NewAzureStackToken - AADTenantId $AADTenantId - EnvironmentDomainFQDN $EnvironmentDomainFQDN - Credentials $ServiceAdminCredentials - ArmEndPoint $AdminArmEndpoint
235+ $asToken = NewAzureStackToken - AADTenantId $TenantID - EnvironmentDomainFQDN $EnvironmentDomainFQDN - Credentials $ServiceAdminCredentials - ArmEndPoint $AdminArmEndpoint
209236 $defaultSubscription = Get-AzureRmSubscription - SubscriptionName " Default Provider Subscription" - ErrorAction Stop
210- $asCanaryQuotas = NewAzureStackDefaultQuotas - ResourceLocation $ResourceLocation - SubscriptionId $defaultSubscription.SubscriptionId - AADTenantID $AADTenantID - EnvironmentDomainFQDN $EnvironmentDomainFQDN - Credentials $ServiceAdminCredentials - ArmEndPoint $AdminArmEndPoint
237+ $asCanaryQuotas = NewAzureStackDefaultQuotas - ResourceLocation $ResourceLocation - SubscriptionId $defaultSubscription.SubscriptionId - AADTenantID $TenantID - EnvironmentDomainFQDN $EnvironmentDomainFQDN - Credentials $ServiceAdminCredentials - ArmEndPoint $AdminArmEndPoint
211238 New-AzureRMPlan - Name $tenantPlanName - DisplayName $tenantPlanName - ArmLocation $ResourceLocation - ResourceGroup $subscriptionRGName - QuotaIds $asCanaryQuotas - ErrorAction Stop
212239
213240 }
@@ -232,7 +259,7 @@ while ($runCount -le $NumberOfIterations)
232259
233260 Invoke-Usecase - Name ' LoginToAzureStackEnvAsTenantAdmin' - Description " Login to $TntAdminEnvironmentName as tenant administrator" - UsecaseBlock `
234261 {
235- Add-AzureRmAccount - EnvironmentName $TntAdminEnvironmentName - Credential $TenantAdminCredentials - TenantId $AADTenantID - ErrorAction Stop
262+ Add-AzureRmAccount - EnvironmentName $TntAdminEnvironmentName - Credential $TenantAdminCredentials - TenantId $TenantID - ErrorAction Stop
236263 }
237264
238265 Invoke-Usecase - Name ' CreateTenantSubscription' - Description " Create a subcsription for the tenant and select it as the current subscription" - UsecaseBlock `
@@ -404,14 +431,17 @@ while ($runCount -le $NumberOfIterations)
404431 }
405432
406433 $templateDeploymentName = " CanaryVMDeployment"
407- $parameters = @ {" VMAdminUserName" = $VMAdminUserName ;
408- " VMAdminUserPassword" = $VMAdminUserPass ;
409- " ASCanaryUtilRG" = $CanaryUtilitiesRG ;
410- " ASCanaryUtilSA" = $storageAccName ;
411- " ASCanaryUtilSC" = $storageCtrName ;
412- " vaultName" = $keyvaultName ;
413- " windowsOSVersion" = $osVersion ;
414- " secretUrlWithVersion" = $kvSecretId }
434+ $parameters = @ {" VMAdminUserName" = $VMAdminUserName ;
435+ " VMAdminUserPassword" = $VMAdminUserPass ;
436+ " ASCanaryUtilRG" = $CanaryUtilitiesRG ;
437+ " ASCanaryUtilSA" = $storageAccName ;
438+ " ASCanaryUtilSC" = $storageCtrName ;
439+ " vaultName" = $keyvaultName ;
440+ " windowsOSVersion" = $osVersion ;
441+ " secretUrlWithVersion" = $kvSecretId ;
442+ " LinuxImagePublisher" = $linuxImagePublisher ;
443+ " LinuxImageOffer" = $linuxImageOffer ;
444+ " LinuxImageSku" = $LinuxOSSku }
415445 $templateError = Test-AzureRmResourceGroupDeployment - ResourceGroupName $CanaryVMRG - TemplateFile .\azuredeploy.json - TemplateParameterObject $parameters
416446 if (-not $templateError )
417447 {
@@ -423,11 +453,12 @@ while ($runCount -le $NumberOfIterations)
423453 }
424454 }
425455
426- $canaryVMList = @ ()
427- $canaryVMList = Invoke-Usecase - Name ' QueryTheVMsDeployed' - Description " Queries for the VMs that were deployed using the ARM template" - UsecaseBlock `
456+ $canaryWindowsVMList = @ ()
457+ $canaryWindowsVMList = Invoke-Usecase - Name ' QueryTheVMsDeployed' - Description " Queries for the VMs that were deployed using the ARM template" - UsecaseBlock `
428458 {
429- $canaryVMList = @ ()
459+ $canaryWindowsVMList = @ ()
430460 $vmList = Get-AzureRmVm - ResourceGroupName $CanaryVMRG - ErrorAction Stop
461+ $vmList = $vmList | Where-Object {$_.OSProfile.WindowsConfiguration }
431462 foreach ($vm in $vmList )
432463 {
433464 $vmObject = New-Object - TypeName System.Object
@@ -455,21 +486,21 @@ while ($runCount -le $NumberOfIterations)
455486 }
456487 $vmObject | Add-Member - Type NoteProperty - Name VMPrivateIP - Value $privateIP - Force
457488 $vmObject | Add-Member - Type NoteProperty - Name VMPublicIP - Value $publicIP - Force
458- $canaryVMList += $vmObject
489+ $canaryWindowsVMList += $vmObject
459490 }
460- $canaryVMList
491+ $canaryWindowsVMList
461492 }
462- if ($canaryVMList )
493+ if ($canaryWindowsVMList )
463494 {
464- $canaryVMList | Format-Table - AutoSize
465- foreach ($vm in $canaryVMList )
495+ $canaryWindowsVMList | Format-Table - AutoSize
496+ foreach ($vm in $canaryWindowsVMList )
466497 {
467- if ($vm.VMPublicIP )
498+ if ($vm.VMPublicIP -and $vm .VMName.EndsWith ( " VM1 " , ' CurrentCultureIgnoreCase ' ) )
468499 {
469500 $publicVMName = $vm.VMName
470501 $publicVMIP = $vm.VMPublicIP [0 ]
471502 }
472- if ((-not ($vm.VMPublicIP )) -and ($vm.VMPrivateIP ))
503+ if ((-not ($vm.VMPublicIP )) -and ($vm.VMPrivateIP ) -and ( $vm .VMName.EndsWith ( " VM2 " , ' CurrentCultureIgnoreCase ' )) )
473504 {
474505 $privateVMName = $vm.VMName
475506 $privateVMIP = $vm.VMPrivateIP [0 ]
@@ -698,7 +729,7 @@ while ($runCount -le $NumberOfIterations)
698729
699730 Invoke-Usecase - Name ' LoginToAzureStackEnvAsSvcAdminForCleanup' - Description " Login to $SvcAdminEnvironmentName as service administrator to remove the subscription resource group" - UsecaseBlock `
700731 {
701- Add-AzureRmAccount - EnvironmentName $SvcAdminEnvironmentName - Credential $ServiceAdminCredentials - TenantId $AADTenantID - ErrorAction Stop
732+ Add-AzureRmAccount - EnvironmentName $SvcAdminEnvironmentName - Credential $ServiceAdminCredentials - TenantId $TenantID - ErrorAction Stop
702733 }
703734
704735 Invoke-Usecase - Name ' DeleteSubscriptionResourceGroup' - Description " Delete the resource group that contains subscription resources" - UsecaseBlock `
0 commit comments