Skip to content

Commit 2d2db82

Browse files
authored
Merge pull request #7 from Azure/master
Merge from Azure:Master
2 parents 9eaf1ef + f06324f commit 2d2db82

File tree

17 files changed

+1091
-115
lines changed

17 files changed

+1091
-115
lines changed

CanaryValidator/Canary.Tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ param (
6161
[parameter(HelpMessage="Resource group under which all the utilities need to be placed")]
6262
[Parameter(ParameterSetName="default", Mandatory=$false)] [Parameter(ParameterSetName="tenant", Mandatory=$false)]
6363
[ValidateNotNullOrEmpty()]
64-
[string]$CanaryUtilitiesRG = "cnur" + [Random]::new().Next(1,99),
64+
[string]$CanaryUtilitiesRG = "cnur" + [Random]::new().Next(1,9999),
6565
[parameter(HelpMessage="Resource group under which the virtual machines need to be placed")]
6666
[Parameter(ParameterSetName="default", Mandatory=$false)]
6767
[Parameter(ParameterSetName="tenant", Mandatory=$false)]
@@ -232,7 +232,7 @@ while ($runCount -le $NumberOfIterations)
232232
Get-AzsScaleUnit -Location $ResourceLocation
233233
}
234234

235-
Invoke-Usecase -Name 'GetAzureStackScaleUnitNode' -Description "List nodes in scale unit" -UsecaseBlock `
235+
Invoke-Usecase -Name 'GetAzureStackScaleUnitNode' -Description "List nodes in scale unit" -RetryCount 2 -RetryDelayInSec 20 -UsecaseBlock `
236236
{
237237
Get-AzsScaleUnitNode -Location $ResourceLocation
238238
}
@@ -295,7 +295,7 @@ while ($runCount -le $NumberOfIterations)
295295
}
296296
}
297297

298-
if ((Get-Volume ((Get-Item -Path $ENV:TMP).PSDrive.Name)).SizeRemaining/1GB -gt 35)
298+
if ((Get-Volume ((Get-Item -Path $ENV:TMP).PSDrive.Name) -ErrorAction SilentlyContinue).SizeRemaining/1GB -gt 35)
299299
{
300300
[boolean]$invalidUri = $false
301301
try {Invoke-WebRequest -Uri $LinuxImagePath -UseBasicParsing -DisableKeepAlive -Method Head -ErrorAction SilentlyContinue | Out-Null}

CanaryValidator/Canary.Utilities.psm1

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ function Invoke-Usecase
283283
[string]$Description,
284284
[parameter(Mandatory=$true, Position = 2)]
285285
[ValidateNotNullOrEmpty()]
286-
[ScriptBlock]$UsecaseBlock
286+
[ScriptBlock]$UsecaseBlock,
287+
[parameter(Mandatory=$false, Position = 3)]
288+
[int]$RetryCount = 0,
289+
[parameter(Mandatory=$false, Position = 4)]
290+
[int]$RetryDelayInSec = 10
287291
)
288292

289293
if ($Global:listAvailableUsecases)
@@ -324,7 +328,54 @@ function Invoke-Usecase
324328

325329
try
326330
{
327-
$result = Invoke-Command -ScriptBlock $UsecaseBlock
331+
$currentRetryCount = 0
332+
333+
do
334+
{
335+
$useCaseError = $null
336+
337+
try
338+
{
339+
$result = Invoke-Command -ScriptBlock $UsecaseBlock
340+
}
341+
catch
342+
{
343+
$useCaseError = $_
344+
}
345+
346+
# Dont retry or log errors on the parent cases
347+
if ($UsecaseBlock.ToString().Contains("Invoke-Usecase"))
348+
{
349+
$useCaseError = $null
350+
break;
351+
}
352+
353+
if ($useCaseError)
354+
{
355+
$currentRetryCount++
356+
357+
if($currentRetryCount -gt $retryCount)
358+
{
359+
break
360+
}
361+
else
362+
{
363+
Start-Sleep -Seconds $RetryDelayInSec
364+
}
365+
}
366+
}
367+
while($useCaseError)
368+
369+
if ($useCaseError -and $RetryCount -gt 0)
370+
{
371+
throw "Test '$Name' failed and retried '$RetryCount' times. The last exception was: $useCaseError"
372+
}
373+
374+
if ($useCaseError)
375+
{
376+
throw $useCaseError
377+
}
378+
328379
if ($result -and (-not $UsecaseBlock.ToString().Contains("Invoke-Usecase")))
329380
{
330381
Log-Info ($result)
@@ -483,6 +534,8 @@ function NewComputeQuota
483534
$memoryLimitMB = 102400
484535
$coresLimit = 100
485536
$ApiVersion = "2015-12-01-preview"
537+
$availabilitySetCount = 10
538+
$vmScaleSetCount = 100
486539

487540
$uri = "{0}/subscriptions/{1}/providers/Microsoft.Compute.Admin/locations/{2}/quotas/{3}?api-version={4}" -f $AdminUri, $SubscriptionId, $ArmLocation, $quotaName, $ApiVersion
488541
$RequestBody = @"
@@ -493,7 +546,9 @@ function NewComputeQuota
493546
"properties":{
494547
"virtualMachineCount":$vmCount,
495548
"memoryLimitMB":$memoryLimitMB,
496-
"coresLimit":$coresLimit
549+
"coresLimit":$coresLimit,
550+
"availabilitySetCount":$availabilitySetCount,
551+
"vmScaleSetCount":$vmScaleSetCount
497552
}
498553
}
499554
"@

ComputeAdmin/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ VM Scale Set allows deployment of multi-VM collections. To add a gallery item wi
116116
$Arm = "<AzureStack administrative Azure Resource Manager endpoint URL>"
117117
$Location = "<The location name of your AzureStack Environment>"
118118
119-
Add-AzsEnvironment -Name AzureStackAdmin -ArmEndpoint $Arm
119+
Add-AzureRMEnvironment -Name AzureStackAdmin -ArmEndpoint $Arm
120120
121121
$Password = ConvertTo-SecureString -AsPlainText -Force "<your AzureStack admin user password>"
122122
$User = "<your AzureStack admin user name>"

Connect/AzureStack.Connect.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function Add-AzsVpnConnection {
3737
$connection = Add-VpnConnection -Name $ConnectionName -ServerAddress $ServerAddress -TunnelType L2tp -EncryptionLevel Required -AuthenticationMethod MSChapv2 -L2tpPsk $PlainPassword -Force -RememberCredential -PassThru -SplitTunneling
3838

3939
Write-Verbose "Adding routes to Azure Stack VPN connection named $ConnectionName" -Verbose
40-
Add-VpnConnectionRoute -ConnectionName $ConnectionName -DestinationPrefix 192.168.102.0/27 -RouteMetric 2 -PassThru | Out-Null
40+
Add-VpnConnectionRoute -ConnectionName $ConnectionName -DestinationPrefix 192.168.102.0/24 -RouteMetric 2 -PassThru | Out-Null
4141
Add-VpnConnectionRoute -ConnectionName $ConnectionName -DestinationPrefix 192.168.105.0/27 -RouteMetric 2 -PassThru | Out-Null
4242

4343
return $connection

Deployment/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ The Azure Stack Development Kit installer provides a UI with the following featu
77
- Rerun and Gather Logs
88
- Reboot to SafeOS
99

10+
![](https://github.com/1RedOne/AzureStack-Tools/blob/master/Deployment/ScreenShot.png?raw=true)
11+
1012
To install the Azure Stack Development Kit you require
1113

1214
- A physical server that meets the requirements

Deployment/ScreenShot.png

27 KB
Loading

Deployment/asdk-installer.ps1

Lines changed: 61 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The Azure Stack Development Kit installer UI script is based on PowerShell and t
2828

2929
#region Text
3030
$Text_Generic = @{}
31+
$Text_Generic.Version = "1.0.06"
3132
$Text_Generic.Password_NotMatch = "Passwords do not match"
3233
$Text_Generic.Regex_Fqdn = "<yourtenant.onmicrosoft.com> can only contain A-Z, a-z, 0-9, dots and a hyphen"
3334
$Text_Generic.Regex_Computername = "Computername must be 15 characters or less and can only contain A-Z, a-z, 0-9 and a hyphen"
@@ -543,7 +544,11 @@ $Xaml = @'
543544
<Grid>
544545
<DockPanel LastChildFill="True" >
545546
<StackPanel DockPanel.Dock="Left" Width="550" HorizontalAlignment="Left" Margin="50,0,0,0" >
546-
<TextBlock FontSize="24" FontFamily="Segoe UI Light" Foreground="#EBEBEB" Margin="0,25,0,0" Text="Microsoft Azure Stack" />
547+
<StackPanel Orientation="Horizontal" Margin="0,25,0,0">
548+
<TextBlock FontSize="24" FontFamily="Segoe UI Light" Foreground="#EBEBEB" Text="Microsoft Azure Stack" />
549+
<TextBlock FontSize="11.5" FontFamily="Segoe UI Light" Foreground="#EBEBEB" Margin="210,3,0,0" Text="Installer UI version: " />
550+
<TextBlock x:Name="Control_Header_Tbl_Version" FontSize="11.5" FontFamily="Segoe UI Light" Foreground="#FF4590CE" Margin="0,3,0,0" />
551+
</StackPanel>
547552
<TextBlock FontSize="44" FontFamily="Segoe UI Light" Foreground="#EBEBEB" Text="Development Kit" />
548553
<TextBlock x:Name="Control_Header_Tbl_Title" FontSize="20" FontFamily="Segoe UI" Foreground="#EBEBEB" Margin="0,50,0,30" Text="Title" />
549554
<!--#region Mode-->
@@ -836,6 +841,10 @@ $xaml.SelectNodes("//*[@*[contains(translate(name(.),'n','N'),'Name')]]") | Wher
836841
#endregion
837842

838843
#region Data
844+
#region Version
845+
$syncHash.Control_Header_Tbl_Version.Text = $Text_Generic.Version
846+
#endregion
847+
839848
#region AuthEndpoints
840849
$AuthEndpoints = @{
841850
'Azure Cloud'= @{
@@ -1301,66 +1310,64 @@ Write-Host "." -NoNewline -ForegroundColor Cyan
13011310

13021311
# Get environment details
13031312
# CloudBuilder
1304-
if (test-path "C:\CloudDeployment\Setup\InstallAzureStackPOC.ps1") {
1305-
1306-
if(!(test-path "C:\CloudDeployment\ECEngine\EnterpriseCloudEngine.psd1")){
1307-
# Deployment not initialized
1308-
$Script:Initialized="CloudBuilder_Install"
1309-
$syncHash.Control_Header_Tbl_Title.Text = $Text_Install.Mode_Title
1310-
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Install.Mode_LeftTitle
1311-
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Install.Mode_LeftContent
1312-
}
1313-
else{
1314-
# Import module to check current deployment status
1315-
Import-Module "C:\CloudDeployment\ECEngine\EnterpriseCloudEngine.psd1" -Force -Verbose:$false
1316-
$actionProgress = Get-ActionProgress -ActionType Deployment
1317-
# Deployment not started
1318-
if (!($actionProgress)){
1313+
if (test-path "C:\CloudDeployment\Setup\InstallAzureStackPOC.ps1") {
1314+
if(!(test-path "C:\CloudDeployment\ECEngine\EnterpriseCloudEngine.psd1")){
1315+
# Deployment not initialized
13191316
$Script:Initialized="CloudBuilder_Install"
13201317
$syncHash.Control_Header_Tbl_Title.Text = $Text_Install.Mode_Title
13211318
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Install.Mode_LeftTitle
13221319
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Install.Mode_LeftContent
13231320
}
1324-
# Deployment in progress
1325-
elseif($actionProgress.LastAttribute.Value -eq 'InProgress'){
1326-
# Not deployed with deployment UI
1327-
if(!(test-path "C:\CloudDeployment\Rerun\config.xml")){
1328-
New-Item C:\CloudDeployment\Rerun -type directory -Force
1329-
'<config status="rerun" run="0"/>' | Out-File C:\CloudDeployment\Rerun\config.xml
1330-
$Script:Initialized="CloudBuilder_Rerun"
1331-
$syncHash.Control_Header_Tbl_Title.Text = $Text_Rerun.Mode_Title
1332-
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Rerun.Mode_LeftTitle
1333-
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Rerun.Mode_LeftContent
1334-
}
1335-
# Deployed with deployment UI
1336-
else {
1337-
$Status = [XML](Get-Content "C:\CloudDeployment\Rerun\config.xml")
1338-
# Contains only 1 or 2 deployment logs
1339-
if ($status.config.status -eq "Rerun" -and [int]$status.config.run -le 2){
1321+
else{
1322+
# Import module to check current deployment status
1323+
Import-Module "C:\CloudDeployment\ECEngine\EnterpriseCloudEngine.psd1" -Force -Verbose:$false
1324+
$actionProgress = Get-ActionProgress -ActionType Deployment
1325+
# Deployment not started
1326+
if (!($actionProgress)){
1327+
$Script:Initialized="CloudBuilder_Install"
1328+
$syncHash.Control_Header_Tbl_Title.Text = $Text_Install.Mode_Title
1329+
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Install.Mode_LeftTitle
1330+
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Install.Mode_LeftContent
1331+
}
1332+
# Deployment completed successfully
1333+
elseif($actionProgress.Attribute("Status").Value -eq 'Success'){
1334+
$Script:Initialized="CloudBuilder_Completed_GatherLogs"
1335+
$syncHash.Control_Header_Tbl_Title.Text = $Text_Completed.Mode_Title
1336+
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Completed.Mode_LeftTitle
1337+
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Completed.Mode_LeftContent
1338+
}
1339+
# Deployment in progress or stopped
1340+
else{
1341+
# Not deployed with deployment UI
1342+
if(!(test-path "C:\CloudDeployment\Rerun\config.xml")){
1343+
New-Item C:\CloudDeployment\Rerun -type directory -Force
1344+
'<config status="rerun" run="0"/>' | Out-File C:\CloudDeployment\Rerun\config.xml
13401345
$Script:Initialized="CloudBuilder_Rerun"
13411346
$syncHash.Control_Header_Tbl_Title.Text = $Text_Rerun.Mode_Title
13421347
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Rerun.Mode_LeftTitle
13431348
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Rerun.Mode_LeftContent
1344-
}
1345-
# Contains 2 or more deplployment logs
1349+
}
1350+
# Deployed with deployment UI
13461351
else {
1347-
$Script:Initialized="CloudBuilder_Rerun_GatherLogs"
1348-
$syncHash.Control_Header_Tbl_Title.Text = $Text_Rerun.Mode_Title_Logs
1349-
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Rerun.Mode_LeftTitle_Logs
1350-
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Rerun.Mode_LeftContent_Logs
1352+
$Status = [XML](Get-Content "C:\CloudDeployment\Rerun\config.xml")
1353+
# Contains only 1 or 2 deployment logs
1354+
if ($status.config.status -eq "Rerun" -and [int]$status.config.run -le 2){
1355+
$Script:Initialized="CloudBuilder_Rerun"
1356+
$syncHash.Control_Header_Tbl_Title.Text = $Text_Rerun.Mode_Title
1357+
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Rerun.Mode_LeftTitle
1358+
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Rerun.Mode_LeftContent
1359+
}
1360+
# Contains 2 or more deployment logs
1361+
else {
1362+
$Script:Initialized="CloudBuilder_Rerun_GatherLogs"
1363+
$syncHash.Control_Header_Tbl_Title.Text = $Text_Rerun.Mode_Title_Logs
1364+
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Rerun.Mode_LeftTitle_Logs
1365+
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Rerun.Mode_LeftContent_Logs
13511366
}
13521367
}
13531368
}
1354-
else{
1355-
# Deployment completed
1356-
$Script:Initialized="CloudBuilder_Completed_GatherLogs"
1357-
$syncHash.Control_Header_Tbl_Title.Text = $Text_Completed.Mode_Title
1358-
$syncHash.Control_Mode_Tbl_LeftTitle.Text = $Text_Completed.Mode_LeftTitle
1359-
$syncHash.Control_Mode_Tbl_LeftContent.Text = $Text_Completed.Mode_LeftContent
13601369
}
13611370

1362-
}
1363-
13641371
# Reboot options
13651372
F_Reboot_Options
13661373
$syncHash.Control_Mode_Tbl_RightTitle.Text = $Text_Install.Mode_RightTitle
@@ -1679,6 +1686,10 @@ If ($synchash.Control_NetConfig_Tbx_TimeServer.Text.Length -gt 0){
16791686
$InstallScript += " -TimeServer "
16801687
$InstallScript += $synchash.Control_NetConfig_Tbx_TimeServer.Text
16811688
}
1689+
Else {
1690+
$InstallScript += " -TimeServer "
1691+
$InstallScript += "pool.ntp.org"
1692+
}
16821693

16831694
$syncHash.Control_Summary_Tbx_Content1.Text = $InstallScript
16841695

@@ -1753,6 +1764,9 @@ Function F_Install {
17531764
If ($synchash.Control_NetConfig_Tbx_TimeServer.Text.Length -gt 0){
17541765
' -TimeServer "' + $synchash.Control_NetConfig_Tbx_TimeServer.Text + '"' | Add-Content $filepath -NoNewline
17551766
}
1767+
Else {
1768+
' -TimeServer "' + 'pool.ntp.org' + '"' | Add-Content $filepath -NoNewline
1769+
}
17561770

17571771
#endregion
17581772

@@ -1764,7 +1778,7 @@ Function F_Install {
17641778
#endregion Rerun Count
17651779

17661780
#region Install
1767-
Start-Process powershell $filepath
1781+
Start-Process powershell -ArgumentList "-noexit", "-file $filepath"
17681782
#endregion
17691783

17701784
}

Identity/AzureStack.Identity.psm1

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ function Get-AzsDirectoryTenantidentifier {
2626
return $(Invoke-RestMethod $("{0}/.well-known/openid-configuration" -f $authority.TrimEnd('/'))).issuer.TrimEnd('/').Split('/')[-1]
2727
}
2828

29-
Export-ModuleMember -Function 'Get-AzsDirectoryTenantidentifier'
29+
3030

3131
<#
3232
.Synopsis
@@ -280,7 +280,7 @@ function Register-AzsGuestDirectoryTenant {
280280

281281
[Parameter()]
282282
[ValidateNotNullOrEmpty()]
283-
[string] $ResourceGroupName = 'system',
283+
[string] $ResourceGroupName = 'system.local',
284284

285285
# Optional: A credential used to authenticate with Azure Stack. Must support a non-interactive authentication flow. If not provided, the script will prompt for user credentials.
286286
[Parameter()]
@@ -316,7 +316,6 @@ function Register-AzsGuestDirectoryTenant {
316316
}
317317
}
318318

319-
Export-ModuleMember -Function 'Publish-AzsApplicationsToARM'
320319

321320
<#
322321
.Synopsis
@@ -346,11 +345,6 @@ function Register-AzsWithMyDirectoryTenant {
346345
[ValidateNotNullOrEmpty()]
347346
[string] $DirectoryTenantName,
348347

349-
# Optional: The identifier (GUID) of the Resource Manager application. Pass this parameter to skip the need to complete the guest signup flow via the portal.
350-
[Parameter(Mandatory=$false)]
351-
[ValidateNotNullOrEmpty()]
352-
[string] $ResourceManagerApplicationId,
353-
354348
# Optional: A credential used to authenticate with Azure Stack. Must support a non-interactive authentication flow. If not provided, the script will prompt for user credentials.
355349
[Parameter()]
356350
[ValidateNotNull()]
@@ -360,6 +354,9 @@ function Register-AzsWithMyDirectoryTenant {
360354
$ErrorActionPreference = 'Stop'
361355
$VerbosePreference = 'Continue'
362356

357+
# Get the Application of Resource Manager
358+
$ResourceManagerApplicationId = $(Invoke-RestMethod "$TenantResourceManagerEndpoint/metadata/identity?api-version=2015-01-01").applicationId
359+
363360
# Install-Module AzureRm -RequiredVersion '1.2.8'
364361
Import-Module 'AzureRm.Profile' -Force -Verbose:$false 4> $null
365362
Import-Module "$PSScriptRoot\GraphAPI\GraphAPI.psm1" -Force -Verbose:$false 4> $null
@@ -370,7 +367,7 @@ function Register-AzsWithMyDirectoryTenant {
370367
$refreshToken = Get-AzureRmUserRefreshToken -azureEnvironment $azureEnvironment -directoryTenantId $azureStackEnvironment.AdTenant -AutomationCredential $AutomationCredential
371368

372369
# Initialize the Graph PowerShell module to communicate with the correct graph service
373-
$graphEnvironment = ResolveGraphEnvironment $azureEnvironment
370+
$graphEnvironment = Resolve-GraphEnvironment $azureEnvironment
374371
Initialize-GraphEnvironment -Environment $graphEnvironment -DirectoryTenantId $DirectoryTenantName -RefreshToken $refreshToken
375372

376373
# Initialize the service principal for the Azure Stack Resource Manager application (allows us to acquire a token to ARM). If not specified, the sign-up flow must be completed via the Azure Stack portal first.
@@ -406,7 +403,7 @@ function Register-AzsWithMyDirectoryTenant {
406403
# Initialize the necessary tags for the registered application
407404
if ($applicationRegistration.tags)
408405
{
409-
Update-GraphApplicationServicePrincipalTags -ApplicationId $applicationRegistration.appId -Tags $applicationRegistration.tags
406+
Update-GraphApplicationServicePrincipalTag -ApplicationId $applicationRegistration.appId -Tags $applicationRegistration.tags
410407
}
411408

412409
# Lookup the permission consent status for the application permissions (either to or from) that the registered application requires
@@ -451,8 +448,9 @@ function Register-AzsWithMyDirectoryTenant {
451448
}
452449

453450
Export-ModuleMember -Function @(
454-
"Register-AzureStackWithMyDirectoryTenant",
455-
"Register-GuestDirectoryTenantToAzureStack",
456-
"Get-DirectoryTenantIdentifier",
451+
"Register-AzsGuestDirectoryTenant",
452+
"Register-AzsWithMyDirectoryTenant",
453+
"Get-AzsDirectoryTenantidentifier",
457454
"New-AzsADGraphServicePrincipal"
458-
)
455+
456+
)

0 commit comments

Comments
 (0)