Skip to content

Commit

Permalink
Migrate StackHCI from generation to main (#26263)
Browse files Browse the repository at this point in the history
* Move StackHCI  to main

* Update ChangeLog.md

---------

Co-authored-by: azure-powershell-bot <[email protected]>
  • Loading branch information
Nickcandy and azure-powershell-bot authored Oct 10, 2024
1 parent 547f20e commit ee18261
Show file tree
Hide file tree
Showing 53 changed files with 941 additions and 124 deletions.
102 changes: 84 additions & 18 deletions src/StackHCI/StackHCI.Autorest/custom/stackhci.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,16 @@ $AzureGermanCloudPortalDomain = "https://portal.microsoftazure.de/"
$AzurePPEPortalDomain = "https://df.onecloud.azure-test.net/"
$AzureCanaryPortalDomain = "https://portal.azure.com/"

$DOMAINFQDNMACRO = "{DomainFqdn}"
$AzureLocalPortalDomain = "https://portal.$DOMAINFQDNMACRO"

$AzureCloud = "AzureCloud"
$AzureChinaCloud = "AzureChinaCloud"
$AzureUSGovernment = "AzureUSGovernment"
$AzureGermanCloud = "AzureGermanCloud"
$AzurePPE = "AzurePPE"
$AzureCanary = "AzureCanary"
$AzureLocal = "Azure.local"

$PortalCanarySuffix = '?feature.armendpointprefix={0}'
$PortalHCIResourceUrl = '#@{0}/resource/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.AzureStackHCI/clusters/{3}/overview'
Expand Down Expand Up @@ -196,6 +200,11 @@ $AuthorityAzureGermanCloud = "https://login.microsoftonline.de"
$BillingServiceApiScopeAzureGermanCloud = "https://azurestackhci-usage.azurewebsites.de/.default"
$GraphServiceApiScopeAzureGermanCloud = "https://graph.cloudapi.de/.default"

$ServiceEndpointAzureLocal = "https://dp.aszrp.$DOMAINFQDNMACRO"
$AuthorityAzureLocal = "https://login.$DOMAINFQDNMACRO"
$BillingServiceApiScopeAzureLocal = "https://dp.aszrp.$DOMAINFQDNMACRO/.default"
$GraphServiceApiScopeAzureLocal = "https://graph.$DOMAINFQDNMACRO"

$RPAPIVersion = "2022-12-01";
$HCIArcAPIVersion = "2023-03-01"
$HCIArcExtensionAPIVersion = "2021-09-01"
Expand Down Expand Up @@ -1029,6 +1038,10 @@ param(
$PortalCanarySuffixWithRegion = $PortalCanarySuffix -f $Region
return ($AzureCanaryPortalDomain + $PortalCanarySuffixWithRegion);
}
elseif($EnvironmentName -eq $AzureLocal)
{
return $AzureLocalPortalDomain;
}
}

function Get-DefaultRegion{
Expand Down Expand Up @@ -1063,6 +1076,10 @@ param(
{
$defaultRegion = "eastus2euap"
}
elseif($EnvironmentName -eq $AzureLocal)
{
$defaultRegion = "autonomous"
}

return $defaultRegion
}
Expand Down Expand Up @@ -1130,6 +1147,13 @@ param(
$BillingServiceApiScope.Value = $BillingServiceApiScopeAzurePPE
$GraphServiceApiScope.Value = $GraphServiceApiScopeAzurePPE
}
elseif($EnvironmentName -eq $AzureLocal)
{
$ServiceEndpoint.Value = $ServiceEndpointAzureLocal
$Authority.Value = $AuthorityAzureLocal
$BillingServiceApiScope.Value = $BillingServiceApiScopeAzureLocal
$GraphServiceApiScope.Value = $GraphServiceApiScopeAzureLocal
}
}


Expand Down Expand Up @@ -1409,6 +1433,39 @@ param(
return $regionName
}

function Initialize-AzureLocalConfig {
$endpoints = Retry-Command -ScriptBlock { (Invoke-WebRequest -Uri "http://localhost:40342/metadata/endpoints?api-version=2020-06-01" -Headers @{"metadata"="true"; "UseDefaultCredentials"="true" } -UseBasicParsing).Content | ConvertFrom-Json}

# Extract domain FQDN from storage suffix.
$domainFQDN=$endpoints.Suffixes.Storage

# Update default configurations based on the domain FQDN.
$script:AzureLocalPortalDomain = $script:AzureLocalPortalDomain.Replace($DOMAINFQDNMACRO, $domainFQDN)
$script:ServiceEndpointAzureLocal = $script:ServiceEndpointAzureLocal.Replace($DOMAINFQDNMACRO, $domainFQDN)
$script:AuthorityAzureLocal = $script:AuthorityAzureLocal.Replace($DOMAINFQDNMACRO, $domainFQDN)
$script:BillingServiceApiScopeAzureLocal = $script:BillingServiceApiScopeAzureLocal.Replace($DOMAINFQDNMACRO, $domainFQDN)
$script:GraphServiceApiScopeAzureLocal = $script:GraphServiceApiScopeAzureLocal.Replace($DOMAINFQDNMACRO, $domainFQDN)

Write-VerboseLog "Default Azure Local configurations - Portal: $AzureLocalPortalDomain, ServiceEndpoint: $ServiceEndpointAzureLocal, Authority: $AuthorityAzureLocal, BillingServiceApiScope: $BillingServiceApiScopeAzureLocal, GraphServiceApiScope: $GraphServiceApiScopeAzureLocal"

# Over write the default configurations if the endpoint is available as part of the metadata.
if ($endpoints.portal) {
$script:AzureLocalPortal = $endpoints.portal
}
if ($endpoints.dataplaneEndpoints.hciDataplaneServiceEndpoint) {
$script:ServiceEndpointAzureLocal = $endpoints.dataplaneEndpoints.hciDataplaneServiceEndpoint
$script:BillingServiceApiScopeAzureLocal = "$($endpoints.dataplaneEndpoints.hciDataplaneServiceEndpoint)/.default"
}
if ($endpoints.authentication.loginEndpoint) {
$script:AuthorityAzureLocal = $endpoints.authentication.loginEndpoint
}
if ($endpoints.graph) {
$script:GraphServiceApiScopeAzureLocal = $endpoints.graph
}

Write-VerboseLog "Azure Local configurations after override - Portal: $AzureLocalPortalDomain, ServiceEndpoint: $ServiceEndpointAzureLocal, Authority: $AuthorityAzureLocal, BillingServiceApiScope: $BillingServiceApiScopeAzureLocal, GraphServiceApiScope: $GraphServiceApiScopeAzureLocal"
}

function Validate-RegionName{
[Microsoft.Azure.PowerShell.Cmdlets.StackHCI.DoNotExportAttribute()]
param(
Expand Down Expand Up @@ -2895,6 +2952,12 @@ param(
Write-VerboseLog ("Cloud Management Infra supported: {0}" -f $isCloudManagementInfraSupported)
Write-VerboseLog ("Installing Mandatory extensions supported: {0}" -f $isDefaultExtensionSupported)

if ($EnvironmentName -eq $AzureLocal)
{
Write-VerboseLog ("Registering in Azure Local. Initiliazing Azure.local configurations")
Initialize-AzureLocalConfig
}

if(-Not ([string]::IsNullOrEmpty($RegContext.AzureResourceUri)))
{
if([string]::IsNullOrEmpty($ResourceName))
Expand Down Expand Up @@ -4181,31 +4244,34 @@ param(
$TenantId = Azure-Login -SubscriptionId $SubscriptionId -TenantId $TenantId -ArmAccessToken $ArmAccessToken -GraphAccessToken $GraphAccessToken -AccountId $AccountId -EnvironmentName $EnvironmentName -ProgressActivityName $UnregisterProgressActivityName -UseDeviceAuthentication $UseDeviceAuthentication -Region $Region

Write-Progress -Id $MainProgressBarId -activity $UnregisterProgressActivityName -status $UnregisterArcMessage -percentcomplete 40

$arcUnregisterRes = Unregister-ArcForServers -IsManagementNode $IsManagementNode -ComputerName $ComputerName -Credential $Credential -ResourceId $resourceId -Force:$Force -ClusterDNSSuffix $clusterDNSSuffix

if($arcUnregisterRes -eq $false)
{
$resultValue = [OperationStatus]::Failed
$unregisterArcForServersWacErrorCode = 9117
$unregistrationOutput | Add-Member -MemberType NoteProperty -Name $OutputPropertyResult -Value $resultValue
Set-WacOutputProperty -IsWAC $IsWAC -PropertyName $OutputPropertyWacResult -PropertyValue $resultValue.ToString() -Output $unregistrationOutput
Set-WacOutputProperty -IsWAC $IsWAC -PropertyName $OutputPropertyWacErrorCode -PropertyValue $unregisterArcForServersWacErrorCode -Output $unregistrationOutput
Write-Output $unregistrationOutput | Format-List
Write-NodeEventLog -Message "ARC unregistration failed" -EventID 9117 -IsManagementNode $IsManagementNode -credentials $Credential -ComputerName $ComputerName -Level Warning
return
}
else

if ($EnvironmentName -ne $AzureLocal)
{
if ($DisableOnlyAzureArcServer -eq $true)
$arcUnregisterRes = Unregister-ArcForServers -IsManagementNode $IsManagementNode -ComputerName $ComputerName -Credential $Credential -ResourceId $resourceId -Force:$Force -ClusterDNSSuffix $clusterDNSSuffix

if($arcUnregisterRes -eq $false)
{
$resultValue = [OperationStatus]::Success
$resultValue = [OperationStatus]::Failed
$unregisterArcForServersWacErrorCode = 9117
$unregistrationOutput | Add-Member -MemberType NoteProperty -Name $OutputPropertyResult -Value $resultValue
Set-WacOutputProperty -IsWAC $IsWAC -PropertyName $OutputPropertyWacResult -PropertyValue $resultValue.ToString() -Output $unregistrationOutput
Set-WacOutputProperty -IsWAC $IsWAC -PropertyName $OutputPropertyWacErrorCode -PropertyValue $unregisterArcForServersWacErrorCode -Output $unregistrationOutput
Write-Output $unregistrationOutput | Format-List
Write-NodeEventLog -Message "Disabling only ARC for Servers. UnRegistration completed successfully" -EventID 9008 -IsManagementNode $IsManagementNode -credentials $Credential -ComputerName $ComputerName
Write-NodeEventLog -Message "ARC unregistration failed" -EventID 9117 -IsManagementNode $IsManagementNode -credentials $Credential -ComputerName $ComputerName -Level Warning
return
}
else
{
if ($DisableOnlyAzureArcServer -eq $true)
{
$resultValue = [OperationStatus]::Success
$unregistrationOutput | Add-Member -MemberType NoteProperty -Name $OutputPropertyResult -Value $resultValue
Set-WacOutputProperty -IsWAC $IsWAC -PropertyName $OutputPropertyWacResult -PropertyValue $resultValue.ToString() -Output $unregistrationOutput
Write-Output $unregistrationOutput | Format-List
Write-NodeEventLog -Message "Disabling only ARC for Servers. UnRegistration completed successfully" -EventID 9008 -IsManagementNode $IsManagementNode -credentials $Credential -ComputerName $ComputerName
return
}
}
}

Write-Progress -Id $MainProgressBarId -activity $UnregisterProgressActivityName -status $UnregisterHCIUsageMessage -percentcomplete 45
Expand Down
12 changes: 6 additions & 6 deletions src/StackHCI/StackHCI/Az.StackHCI.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Microsoft Corporation
#
# Generated on: 7/31/2024
# Generated on: 10/10/2024
#

@{
Expand Down Expand Up @@ -51,16 +51,16 @@ DotNetFrameworkVersion = '4.7.2'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '3.0.3'; })
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '3.0.4'; })

# Assemblies that must be loaded prior to importing this module
RequiredAssemblies = 'StackHCI.Autorest/bin/Az.StackHCI.private.dll'

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
FormatsToProcess = 'StackHCI.Autorest/Az.StackHCI.format.ps1xml'
Expand Down Expand Up @@ -121,7 +121,7 @@ PrivateData = @{
PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'Azure','ResourceManager','ARM','PSModule','StackHci'
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'StackHci'

# A URL to the license for this module.
LicenseUri = 'https://aka.ms/azps-license'
Expand All @@ -147,7 +147,7 @@ PrivateData = @{

} # End of PSData hashtable

} # End of PrivateData hashtable
} # End of PrivateData hashtable

# HelpInfo URI of this module
# HelpInfoURI = ''
Expand Down
1 change: 1 addition & 0 deletions src/StackHCI/StackHCI/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* added support for new environment

## Version 2.4.0
* Upgraded API version to 2024-04-01
Expand Down
21 changes: 18 additions & 3 deletions src/StackHCI/StackHCI/help/Add-AzStackHCIVMAttestation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ Add-AzStackHCIVMAttestation configures guests for AzureStack HCI IMDS Attestatio

### VMName (Default)
```
Add-AzStackHCIVMAttestation [-VMName] <String[]> [-Force] [-WhatIf]
Add-AzStackHCIVMAttestation [-VMName] <String[]> [-Force] [-ProgressAction <ActionPreference>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### VMObject
```
Add-AzStackHCIVMAttestation [-Force] [-VM] <Object[]> [-WhatIf] [-Confirm]
Add-AzStackHCIVMAttestation [-Force] [-VM] <Object[]> [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### AddAll
```
Add-AzStackHCIVMAttestation [-Force] [-AddAll] [-WhatIf] [-Confirm]
Add-AzStackHCIVMAttestation [-Force] [-AddAll] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

Expand Down Expand Up @@ -107,6 +107,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -VM
Specifies an array of VM objects from Get-VM.
Expand Down
17 changes: 16 additions & 1 deletion src/StackHCI/StackHCI/help/Disable-AzStackHCIAttestation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Disable-AzStackHCIAttestation disables IMDS Attestation on the host

```
Disable-AzStackHCIAttestation [[-ComputerName] <String>] [-Credential <PSCredential>] [-RemoveVM] [-Force]
[-WhatIf] [-Confirm] [<CommonParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -83,6 +83,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -RemoveVM
Specifies the guests on each node should be removed from IMDS Attestation before disabling on cluster.
Disable cannot continue before guests are removed.
Expand Down
17 changes: 16 additions & 1 deletion src/StackHCI/StackHCI/help/Disable-AzStackHCIRemoteSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Disables Remote Support.
## SYNTAX

```
Disable-AzStackHCIRemoteSupport [-WhatIf] [-Confirm] [<CommonParameters>]
Disable-AzStackHCIRemoteSupport [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand All @@ -37,6 +37,21 @@ Disabling Remort support

## PARAMETERS

### -ProgressAction
{{ Fill ProgressAction Description }}

```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
Expand Down
17 changes: 16 additions & 1 deletion src/StackHCI/StackHCI/help/Enable-AzStackHCIAttestation.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Enable-AzStackHCIAttestation configures the host and enables specified guests fo

```
Enable-AzStackHCIAttestation [[-ComputerName] <String>] [-Credential <PSCredential>] [-AddVM] [-Force]
[-WhatIf] [-Confirm] [<CommonParameters>]
[-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -99,6 +99,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Confirm
Prompts you for confirmation before running the cmdlet.
Expand Down
17 changes: 16 additions & 1 deletion src/StackHCI/StackHCI/help/Enable-AzStackHCIRemoteSupport.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Enables Remote Support.

```
Enable-AzStackHCIRemoteSupport [-AccessLevel] <String> [[-ExpireInMinutes] <Int32>] [[-SasCredential] <String>]
[-AgreeToRemoteSupportConsent] [-WhatIf] [-Confirm] [<CommonParameters>]
[-AgreeToRemoteSupportConsent] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -118,6 +118,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -ProgressAction
{{ Fill ProgressAction Description }}
```yaml
Type: System.Management.Automation.ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -SasCredential
Hybrid Connection SAS Credential.
Expand Down
Loading

0 comments on commit ee18261

Please sign in to comment.