Skip to content

Commit 6ab4c3f

Browse files
Merge branch 'vnext' into mattmcg/mergebranch
2 parents dce3950 + a808b45 commit 6ab4c3f

File tree

6 files changed

+292
-35
lines changed

6 files changed

+292
-35
lines changed

Identity/AzureStack.Identity.psm1

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

29-
30-
3129
<#
3230
.Synopsis
3331
This function is used to create a Service Principal on teh AD Graph
@@ -316,7 +314,6 @@ function Register-AzsGuestDirectoryTenant {
316314
}
317315
}
318316

319-
320317
<#
321318
.Synopsis
322319
Consents to the given Azure Stack instance within the callers's Azure Directory Tenant.

Infrastructure/AzureStack.Infra.psm1

Lines changed: 183 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ function Start-AzsInfrastructureRoleInstance {
389389
[switch] $Force
390390
)
391391

392-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to start $Name ?", "")) {
392+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to start $Name ?", "")) {
393393
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/infraRoleInstances"
394394

395395
Invoke-AzsInfrastructureAction -Name $Name -Action "poweron" -Location $Location -ResourceType $resourceType
@@ -415,7 +415,7 @@ function Stop-AzsInfrastructureRoleInstance {
415415
[switch] $Force
416416
)
417417

418-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to shut down $Name ?", "")) {
418+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to shut down $Name ?", "")) {
419419
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/infraRoleInstances"
420420

421421
Invoke-AzsInfrastructureAction -Name $Name -Action "shutdown" -Location $Location -ResourceType $resourceType
@@ -441,7 +441,7 @@ function Restart-AzsInfrastructureRoleInstance {
441441
[switch] $Force
442442
)
443443

444-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to restart $Name ?", "")) {
444+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to restart $Name ?", "")) {
445445
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/infraRoleInstances"
446446

447447
Invoke-AzsInfrastructureAction -Name $Name -Action "reboot" -Location $Location -ResourceType $resourceType
@@ -479,7 +479,7 @@ function Add-AzsIpPool {
479479
ResourceType = "Microsoft.Fabric.Admin/fabricLocations/IPPools"
480480
ResourceGroupName = "system.{0}" -f $Location
481481
ApiVersion = "2016-05-01"
482-
Properties = @{
482+
Properties = @{
483483
StartIpAddress = "$StartIPAddress"
484484
EndIpAddress = "$EndIPAddress"
485485
AddressPrefix = "$AddressPrefix"
@@ -509,7 +509,7 @@ function Disable-AzsScaleUnitNode {
509509
[switch] $Force
510510
)
511511

512-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to disable scale unit node $Name ?", "")) {
512+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to disable scale unit node $Name ?", "")) {
513513
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
514514

515515
Invoke-AzsInfrastructureAction -Action "StartMaintenanceMode" -Name $Name -Location $Location -ResourceType $resourceType
@@ -537,7 +537,7 @@ function Enable-AzsScaleUnitNode {
537537
[switch] $Force
538538
)
539539

540-
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure to enable scale unit node $Name ?", "")) {
540+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to enable scale unit node $Name ?", "")) {
541541
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
542542

543543
Invoke-AzsInfrastructureAction -Action "StopMaintenanceMode" -Name $Name -Location $Location -ResourceType $resourceType
@@ -546,6 +546,94 @@ function Enable-AzsScaleUnitNode {
546546

547547
Export-ModuleMember -Function Enable-AzsScaleUnitNode
548548

549+
<#
550+
.SYNOPSIS
551+
Repairs a scale unit node by reimaging and readding a specific node
552+
#>
553+
554+
function Repair-AzsScaleUnitNode {
555+
[CmdletBinding(SupportsShouldProcess = $true)]
556+
Param(
557+
[Parameter(Mandatory = $false)]
558+
[string] $Location,
559+
560+
[Parameter(Mandatory = $true)]
561+
[ValidateNotNullorEmpty()]
562+
[string] $ScaleUnitNodeName,
563+
564+
[Parameter(Mandatory = $true)]
565+
[ValidateNotNullorEmpty()]
566+
[string] $BMCIPv4Address,
567+
568+
[switch] $Force
569+
)
570+
571+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to repair scale unit node $ScaleUnitNodeName ?", "")) {
572+
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
573+
574+
$parameters = @{
575+
bmcIPv4Address = $BMCIPv4Address
576+
}
577+
578+
Invoke-AzsInfrastructureAction -Action "Repair" -Name $ScaleUnitNodeName -Location $Location -ResourceType $resourceType -Parameters $parameters
579+
}
580+
}
581+
582+
Export-ModuleMember -Function Repair-AzsScaleUnitNode
583+
584+
<#
585+
.SYNOPSIS
586+
Powers off a scale unit node
587+
#>
588+
589+
function Stop-AzsScaleUnitNode {
590+
[CmdletBinding(SupportsShouldProcess = $true)]
591+
Param(
592+
[Parameter(Mandatory = $false)]
593+
[string] $Location,
594+
595+
[Parameter(Mandatory = $true)]
596+
[ValidateNotNullorEmpty()]
597+
[string] $ScaleUnitNodeName,
598+
599+
[switch] $Force
600+
)
601+
602+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to stop scale unit node $ScaleUnitNodeName ?", "")) {
603+
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
604+
605+
Invoke-AzsInfrastructureAction -Action "PowerOff" -Name $ScaleUnitNodeName -Location $Location -ResourceType $resourceType
606+
}
607+
}
608+
609+
Export-ModuleMember -Function Stop-AzsScaleUnitNode
610+
611+
<#
612+
.SYNOPSIS
613+
Powers on a scale unit node
614+
#>
615+
616+
function Start-AzsScaleUnitNode {
617+
[CmdletBinding(SupportsShouldProcess = $true)]
618+
Param(
619+
[Parameter(Mandatory = $false)]
620+
[string] $Location,
621+
622+
[Parameter(Mandatory = $true)]
623+
[ValidateNotNullorEmpty()]
624+
[string] $ScaleUnitNodeName,
625+
626+
[switch] $Force
627+
)
628+
629+
if ($Force.IsPresent -or $PSCmdlet.ShouldContinue("Are you sure you want to start scale unit node $ScaleUnitNodeName ?", "")) {
630+
$resourceType = "Microsoft.Fabric.Admin/fabricLocations/scaleunitnodes"
631+
632+
Invoke-AzsInfrastructureAction -Action "PowerOn" -Name $ScaleUnitNodeName -Location $Location -ResourceType $resourceType
633+
}
634+
}
635+
636+
Export-ModuleMember -Function Start-AzsScaleUnitNode
549637

550638
<#
551639
.SYNOPSIS
@@ -646,6 +734,85 @@ function Set-AzSLocationInformation {
646734
New-AzureRmResource @params -IsFullObject -Force
647735
}
648736

737+
<#
738+
.SYNOPSIS
739+
Start Infrastructure Backup
740+
#>
741+
function Start-AzsBackup {
742+
[CmdletBinding(SupportsShouldProcess = $true)]
743+
Param(
744+
[Parameter(Mandatory = $false)]
745+
[string] $Location
746+
)
747+
748+
$resourceType = "Microsoft.Backup.Admin/backupLocations"
749+
Invoke-AzsInfrastructureAction -Name $Location -Action "createbackup" -Location $Location -ResourceType $resourceType
750+
}
751+
752+
Export-ModuleMember -Function Start-AzsBackup
753+
754+
<#
755+
.SYNOPSIS
756+
Restore Infrastructure Backup
757+
#>
758+
function Restore-AzsBackup {
759+
[CmdletBinding(SupportsShouldProcess = $true)]
760+
Param(
761+
[Parameter(Mandatory = $true)]
762+
[string] $Location,
763+
764+
[Parameter(Mandatory = $true)]
765+
[string] $Name
766+
767+
)
768+
769+
$resourceType = "Microsoft.Backup.Admin/backupLocations/backups"
770+
Invoke-AzsInfrastructureAction -Name $Name -Action "restore" -Location $Location -ResourceType $resourceType
771+
}
772+
773+
Export-ModuleMember -Function Restore-AzsBackup
774+
775+
<#
776+
.SYNOPSIS
777+
List Resource Provider Healths
778+
#>
779+
780+
function Get-AzsResourceProviderHealths {
781+
Param(
782+
[Parameter(Mandatory = $true)]
783+
[string] $Location
784+
785+
)
786+
787+
$resourceType = "Microsoft.InfrastructureInsights.Admin/regionHealths/serviceHealths"
788+
789+
$rolehealth = Get-AzsInfrastructureResource -Location $Location -resourceType $resourceType
790+
$rolehealth.Properties
791+
}
792+
793+
Export-ModuleMember -Function Get-AzsResourceProviderHealths
794+
795+
<#
796+
.SYNOPSIS
797+
List Infrastructure Role Healths
798+
#>
799+
800+
function Get-AzsInfrastructureRoleHealths {
801+
Param(
802+
[Parameter(Mandatory = $true)]
803+
[string] $Location
804+
805+
)
806+
$RP=Get-AzsResourceProviderHealths -Location $location|where {$_.DisplayName -eq "Capacity"}
807+
$ID=$RP.RegistrationID
808+
$resourceType = "Microsoft.InfrastructureInsights.Admin/regionHealths/serviceHealths/$ID/resourceHealths"
809+
810+
$rolehealth = Get-AzsInfrastructureResource -Location $Location -resourceType $resourceType
811+
$rolehealth.Properties
812+
}
813+
814+
Export-ModuleMember -Function Get-AzsInfrastructureRoleHealths
815+
649816
function Get-AzsHomeLocation {
650817
param(
651818
[Parameter(Mandatory = $false)]
@@ -700,9 +867,12 @@ function Invoke-AzsInfrastructureAction {
700867
[string] $Name,
701868
[string] $Location,
702869
[string] $Action,
703-
[string] $ResourceType
870+
[string] $ResourceType,
871+
872+
[Parameter(Mandatory = $false)]
873+
[Hashtable] $Parameters = $null
704874
)
705-
875+
706876
$Location = Get-AzsHomeLocation -Location $Location
707877

708878
$params = @{
@@ -713,5 +883,10 @@ function Invoke-AzsInfrastructureAction {
713883
ResourceName = "{0}/{1}" -f $Location, $Name
714884
}
715885

886+
if ($Parameters)
887+
{
888+
$params.Parameters = $Parameters
889+
}
890+
716891
Invoke-AzureRmResourceAction @params -Force
717892
}

Infrastructure/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,72 @@ Get-AzsLocationCapacity
317317
The command does the following:
318318
- Retrieves Region Capacity information
319319

320+
### Show Resource Provider Healths
321+
322+
Does show resource provider healths
323+
324+
```powershell
325+
Get-AzsResourceProviderHealths
326+
```
327+
328+
The command does the following:
329+
- List Resource Provider and their Healths status
330+
331+
### Show Infrastrcuture Role Healths
332+
333+
Does show infrastructure role healths
334+
335+
```powershell
336+
Get-AzsInfrastructureRoleHealths
337+
```
338+
339+
The command does the following:
340+
- List Infrastructure Roles and their Healths status
341+
342+
### Show Backup Location
343+
344+
Does show Backup location
345+
346+
```powershell
347+
Get-AzsBackupLocation
348+
```
349+
350+
The command does the following:
351+
- List information about the backup location like share path
352+
353+
### Show Backup
354+
355+
Does show backups
356+
357+
```powershell
358+
Get-AzsBackup
359+
```
360+
361+
The command does the following:
362+
- List backups
363+
364+
### Start Backup
365+
366+
Does start a backup job
367+
368+
```powershell
369+
Start-AzsBackup
370+
```
371+
372+
The command does the following:
373+
- starts a backup job and does store it at configured share path
374+
375+
### Restore Backup
376+
377+
Does restore a backup job
378+
379+
```powershell
380+
Restore-AzsBackup -name ID
381+
```
382+
383+
The command does the following:
384+
- Restore a specified Backup job
385+
320386
## Scenario Command Usage
321387

322388
Demonstrates using multiple commands together for an end to end scenario.

Infrastructure/Tests/Infra.Tests.ps1

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Describe $script:ModuleName {
1212
}
1313

1414
It 'Get-AzsAlert should be exported' {
15-
Get-Command -Name Get-AzsAlert -ErrorAction SilentlyContinue |
15+
Get-Command -Name Get-AzsAlert -ErrorAction SilentlyContinue |
1616
Should Not Be $null
1717
}
1818
}
@@ -22,9 +22,9 @@ InModuleScope $script:ModuleName {
2222

2323
$HostComputer = $global:HostComputer
2424
$ArmEndpoint = $global:ArmEndpoint
25-
$natServer = $global:natServer
26-
$AdminUser = $global:AdminUser
27-
$AadServiceAdmin = $global:AadServiceAdmin
25+
$natServer = $global:natServer
26+
$AdminUser = $global:AdminUser
27+
$AadServiceAdmin = $global:AadServiceAdmin
2828

2929
$AdminPassword = $global:AdminPassword
3030
$AadServiceAdminPassword = $global:AadServiceAdminPassword
@@ -64,7 +64,6 @@ InModuleScope $script:ModuleName {
6464
{ Get-Azslogicalnetwork } |
6565
Should Not Throw
6666
}
67-
6867
It 'Get-AzsUpdateLocation should not throw' {
6968
{ Get-AzsUpdateLocation } |
7069
Should Not Throw
@@ -75,6 +74,6 @@ InModuleScope $script:ModuleName {
7574
}
7675

7776
}
78-
77+
7978

8079
}

0 commit comments

Comments
 (0)