@@ -151,12 +151,16 @@ $AzureGermanCloudPortalDomain = "https://portal.microsoftazure.de/"
151151$AzurePPEPortalDomain = " https://df.onecloud.azure-test.net/"
152152$AzureCanaryPortalDomain = " https://portal.azure.com/"
153153
154+ $DOMAINFQDNMACRO = " {DomainFqdn}"
155+ $AzureLocalPortalDomain = " https://portal.$DOMAINFQDNMACRO "
156+
154157$AzureCloud = " AzureCloud"
155158$AzureChinaCloud = " AzureChinaCloud"
156159$AzureUSGovernment = " AzureUSGovernment"
157160$AzureGermanCloud = " AzureGermanCloud"
158161$AzurePPE = " AzurePPE"
159162$AzureCanary = " AzureCanary"
163+ $AzureLocal = " Azure.local"
160164
161165$PortalCanarySuffix = ' ?feature.armendpointprefix={0}'
162166$PortalHCIResourceUrl = ' #@{0}/resource/subscriptions/{1}/resourceGroups/{2}/providers/Microsoft.AzureStackHCI/clusters/{3}/overview'
@@ -196,6 +200,11 @@ $AuthorityAzureGermanCloud = "https://login.microsoftonline.de"
196200$BillingServiceApiScopeAzureGermanCloud = " https://azurestackhci-usage.azurewebsites.de/.default"
197201$GraphServiceApiScopeAzureGermanCloud = " https://graph.cloudapi.de/.default"
198202
203+ $ServiceEndpointAzureLocal = " https://dp.aszrp.$DOMAINFQDNMACRO "
204+ $AuthorityAzureLocal = " https://login.$DOMAINFQDNMACRO "
205+ $BillingServiceApiScopeAzureLocal = " https://dp.aszrp.$DOMAINFQDNMACRO /.default"
206+ $GraphServiceApiScopeAzureLocal = " https://graph.$DOMAINFQDNMACRO "
207+
199208$RPAPIVersion = " 2022-12-01" ;
200209$HCIArcAPIVersion = " 2023-03-01"
201210$HCIArcExtensionAPIVersion = " 2021-09-01"
@@ -1029,6 +1038,10 @@ param(
10291038 $PortalCanarySuffixWithRegion = $PortalCanarySuffix -f $Region
10301039 return ($AzureCanaryPortalDomain + $PortalCanarySuffixWithRegion );
10311040 }
1041+ elseif ($EnvironmentName -eq $AzureLocal )
1042+ {
1043+ return $AzureLocalPortalDomain ;
1044+ }
10321045}
10331046
10341047function Get-DefaultRegion {
@@ -1063,6 +1076,10 @@ param(
10631076 {
10641077 $defaultRegion = " eastus2euap"
10651078 }
1079+ elseif ($EnvironmentName -eq $AzureLocal )
1080+ {
1081+ $defaultRegion = " autonomous"
1082+ }
10661083
10671084 return $defaultRegion
10681085}
@@ -1130,6 +1147,13 @@ param(
11301147 $BillingServiceApiScope.Value = $BillingServiceApiScopeAzurePPE
11311148 $GraphServiceApiScope.Value = $GraphServiceApiScopeAzurePPE
11321149 }
1150+ elseif ($EnvironmentName -eq $AzureLocal )
1151+ {
1152+ $ServiceEndpoint.Value = $ServiceEndpointAzureLocal
1153+ $Authority.Value = $AuthorityAzureLocal
1154+ $BillingServiceApiScope.Value = $BillingServiceApiScopeAzureLocal
1155+ $GraphServiceApiScope.Value = $GraphServiceApiScopeAzureLocal
1156+ }
11331157}
11341158
11351159
@@ -1409,6 +1433,39 @@ param(
14091433 return $regionName
14101434}
14111435
1436+ function Initialize-AzureLocalConfig {
1437+ $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 }
1438+
1439+ # Extract domain FQDN from storage suffix.
1440+ $domainFQDN = $endpoints.Suffixes.Storage
1441+
1442+ # Update default configurations based on the domain FQDN.
1443+ $script :AzureLocalPortalDomain = $script :AzureLocalPortalDomain.Replace ($DOMAINFQDNMACRO , $domainFQDN )
1444+ $script :ServiceEndpointAzureLocal = $script :ServiceEndpointAzureLocal.Replace ($DOMAINFQDNMACRO , $domainFQDN )
1445+ $script :AuthorityAzureLocal = $script :AuthorityAzureLocal.Replace ($DOMAINFQDNMACRO , $domainFQDN )
1446+ $script :BillingServiceApiScopeAzureLocal = $script :BillingServiceApiScopeAzureLocal.Replace ($DOMAINFQDNMACRO , $domainFQDN )
1447+ $script :GraphServiceApiScopeAzureLocal = $script :GraphServiceApiScopeAzureLocal.Replace ($DOMAINFQDNMACRO , $domainFQDN )
1448+
1449+ Write-VerboseLog " Default Azure Local configurations - Portal: $AzureLocalPortalDomain , ServiceEndpoint: $ServiceEndpointAzureLocal , Authority: $AuthorityAzureLocal , BillingServiceApiScope: $BillingServiceApiScopeAzureLocal , GraphServiceApiScope: $GraphServiceApiScopeAzureLocal "
1450+
1451+ # Over write the default configurations if the endpoint is available as part of the metadata.
1452+ if ($endpoints.portal ) {
1453+ $script :AzureLocalPortal = $endpoints.portal
1454+ }
1455+ if ($endpoints.dataplaneEndpoints.hciDataplaneServiceEndpoint ) {
1456+ $script :ServiceEndpointAzureLocal = $endpoints.dataplaneEndpoints.hciDataplaneServiceEndpoint
1457+ $script :BillingServiceApiScopeAzureLocal = " $ ( $endpoints.dataplaneEndpoints.hciDataplaneServiceEndpoint ) /.default"
1458+ }
1459+ if ($endpoints.authentication.loginEndpoint ) {
1460+ $script :AuthorityAzureLocal = $endpoints.authentication.loginEndpoint
1461+ }
1462+ if ($endpoints.graph ) {
1463+ $script :GraphServiceApiScopeAzureLocal = $endpoints.graph
1464+ }
1465+
1466+ Write-VerboseLog " Azure Local configurations after override - Portal: $AzureLocalPortalDomain , ServiceEndpoint: $ServiceEndpointAzureLocal , Authority: $AuthorityAzureLocal , BillingServiceApiScope: $BillingServiceApiScopeAzureLocal , GraphServiceApiScope: $GraphServiceApiScopeAzureLocal "
1467+ }
1468+
14121469function Validate-RegionName {
14131470 [Microsoft.Azure.PowerShell.Cmdlets.StackHCI.DoNotExportAttribute ()]
14141471param (
@@ -2895,6 +2952,12 @@ param(
28952952 Write-VerboseLog (" Cloud Management Infra supported: {0}" -f $isCloudManagementInfraSupported )
28962953 Write-VerboseLog (" Installing Mandatory extensions supported: {0}" -f $isDefaultExtensionSupported )
28972954
2955+ if ($EnvironmentName -eq $AzureLocal )
2956+ {
2957+ Write-VerboseLog (" Registering in Azure Local. Initiliazing Azure.local configurations" )
2958+ Initialize-AzureLocalConfig
2959+ }
2960+
28982961 if (-Not ([string ]::IsNullOrEmpty($RegContext.AzureResourceUri )))
28992962 {
29002963 if ([string ]::IsNullOrEmpty($ResourceName ))
@@ -4181,31 +4244,34 @@ param(
41814244 $TenantId = Azure- Login - SubscriptionId $SubscriptionId - TenantId $TenantId - ArmAccessToken $ArmAccessToken - GraphAccessToken $GraphAccessToken - AccountId $AccountId - EnvironmentName $EnvironmentName - ProgressActivityName $UnregisterProgressActivityName - UseDeviceAuthentication $UseDeviceAuthentication - Region $Region
41824245
41834246 Write-Progress - Id $MainProgressBarId - activity $UnregisterProgressActivityName - status $UnregisterArcMessage - percentcomplete 40
4184-
4185- $arcUnregisterRes = Unregister-ArcForServers - IsManagementNode $IsManagementNode - ComputerName $ComputerName - Credential $Credential - ResourceId $resourceId - Force:$Force - ClusterDNSSuffix $clusterDNSSuffix
4186-
4187- if ($arcUnregisterRes -eq $false )
4188- {
4189- $resultValue = [OperationStatus ]::Failed
4190- $unregisterArcForServersWacErrorCode = 9117
4191- $unregistrationOutput | Add-Member - MemberType NoteProperty - Name $OutputPropertyResult - Value $resultValue
4192- Set-WacOutputProperty - IsWAC $IsWAC - PropertyName $OutputPropertyWacResult - PropertyValue $resultValue.ToString () - Output $unregistrationOutput
4193- Set-WacOutputProperty - IsWAC $IsWAC - PropertyName $OutputPropertyWacErrorCode - PropertyValue $unregisterArcForServersWacErrorCode - Output $unregistrationOutput
4194- Write-Output $unregistrationOutput | Format-List
4195- Write-NodeEventLog - Message " ARC unregistration failed" - EventID 9117 - IsManagementNode $IsManagementNode - credentials $Credential - ComputerName $ComputerName - Level Warning
4196- return
4197- }
4198- else
4247+
4248+ if ($EnvironmentName -ne $AzureLocal )
41994249 {
4200- if ($DisableOnlyAzureArcServer -eq $true )
4250+ $arcUnregisterRes = Unregister-ArcForServers - IsManagementNode $IsManagementNode - ComputerName $ComputerName - Credential $Credential - ResourceId $resourceId - Force:$Force - ClusterDNSSuffix $clusterDNSSuffix
4251+
4252+ if ($arcUnregisterRes -eq $false )
42014253 {
4202- $resultValue = [OperationStatus ]::Success
4254+ $resultValue = [OperationStatus ]::Failed
4255+ $unregisterArcForServersWacErrorCode = 9117
42034256 $unregistrationOutput | Add-Member - MemberType NoteProperty - Name $OutputPropertyResult - Value $resultValue
42044257 Set-WacOutputProperty - IsWAC $IsWAC - PropertyName $OutputPropertyWacResult - PropertyValue $resultValue.ToString () - Output $unregistrationOutput
4258+ Set-WacOutputProperty - IsWAC $IsWAC - PropertyName $OutputPropertyWacErrorCode - PropertyValue $unregisterArcForServersWacErrorCode - Output $unregistrationOutput
42054259 Write-Output $unregistrationOutput | Format-List
4206- Write-NodeEventLog - Message " Disabling only ARC for Servers. UnRegistration completed successfully " - EventID 9008 - IsManagementNode $IsManagementNode - credentials $Credential - ComputerName $ComputerName
4260+ Write-NodeEventLog - Message " ARC unregistration failed " - EventID 9117 - IsManagementNode $IsManagementNode - credentials $Credential - ComputerName $ComputerName - Level Warning
42074261 return
42084262 }
4263+ else
4264+ {
4265+ if ($DisableOnlyAzureArcServer -eq $true )
4266+ {
4267+ $resultValue = [OperationStatus ]::Success
4268+ $unregistrationOutput | Add-Member - MemberType NoteProperty - Name $OutputPropertyResult - Value $resultValue
4269+ Set-WacOutputProperty - IsWAC $IsWAC - PropertyName $OutputPropertyWacResult - PropertyValue $resultValue.ToString () - Output $unregistrationOutput
4270+ Write-Output $unregistrationOutput | Format-List
4271+ Write-NodeEventLog - Message " Disabling only ARC for Servers. UnRegistration completed successfully" - EventID 9008 - IsManagementNode $IsManagementNode - credentials $Credential - ComputerName $ComputerName
4272+ return
4273+ }
4274+ }
42094275 }
42104276
42114277 Write-Progress - Id $MainProgressBarId - activity $UnregisterProgressActivityName - status $UnregisterHCIUsageMessage - percentcomplete 45
0 commit comments