Skip to content

Commit 3a34fce

Browse files
Merge pull request #96 from rupisure/patch-5
Add support for multiple TP3 builds
2 parents 2451ae0 + 49dc52c commit 3a34fce

1 file changed

Lines changed: 38 additions & 11 deletions

File tree

Registration/RegisterWithAzure.ps1

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
.SYNOPSIS
77
88
This script can be used to register Azure Stack POC with Azure. To run this script, you must have a public Azure subscription of any type.
9-
The owner of the subscription cannot be an MSA or 2FA account.
9+
There must also be an account that is an owner or contributor of the subscription. This account cannot be an MSA (i.e. cannot be live.com or hotmail.com) or 2FA account.
1010
1111
.DESCRIPTION
1212
1313
RegisterToAzure runs local scripts to connect your Azure Stack to Azure. After connecting with Azure, you can test marketplace syndication.
1414
1515
The script will follow four steps:
16-
Configure local identity: configures local Azure Stack so that it can call to Azure via your Azure subscription
17-
Get registration request: get local environment information to create a registration for this azure stack in azure
16+
Configure bridge identity: configures Azure Stack so that it can call to Azure via your Azure subscription
17+
Get registration request: get Azure Stack environment information to create a registration for this azure stack in azure
1818
Register with Azure: uses Azure powershell to create an "Azure Stack Registration" resource on your Azure subscription
1919
Activate Azure Stack: final step in connecting Azure Stack to be able to call out to Azure
2020
@@ -28,7 +28,7 @@ Name of your AAD Tenant which your Azure subscription is a part of. This paramet
2828
2929
.PARAMETER azureSubscriptionOwner
3030
31-
Username for the owner of the azure subscription. This user must not be an MSA or 2FA account. This parameter is mandatory.
31+
Username for an owner/contributor of the azure subscription. This user must not be an MSA or 2FA account. This parameter is mandatory.
3232
3333
.PARAMETER azureSubscriptionPassword
3434
@@ -53,7 +53,6 @@ This script must be run from the Host machine of the POC.
5353
Ensure that you have an Azure subscription
5454
#>
5555

56-
5756
[CmdletBinding()]
5857
Param (
5958
[Parameter(Mandatory = $true)]
@@ -86,6 +85,24 @@ cd C:\CloudDeployment\Setup\Activation\Bridge
8685

8786
Read-Host "This script will turn marketplace syndication $marketplaceSyndication and usage reporting $reportUsage. You can change this by running the script using different flags. Press Enter to continue."
8887

88+
# Determine version of TP3 and set values accordingly
89+
$versionInfo = [xml] (Get-Content -Path C:\CloudDeployment\Configuration\Version\version.xml)
90+
if($versionInfo.Version -ge "1.0.170308.2")
91+
{
92+
Write-Verbose -Message "Using TP3.N release" -Verbose
93+
$bridgeAppConfigFile = "\\SU1FileServer\SU1_Infrastructure_1\ASResourceProvider\Config\AzureBridge.IdentityApplication.Configuration.json"
94+
}
95+
elseif($versionInfo.Version -eq "1.0.170225.2")
96+
{
97+
Write-Verbose -Message "Using TP3.O release" -Verbose
98+
$bridgeAppConfigFile = "\\SU1FileServer\SU1_Infrastructure_1\ASResourceProvider\Config\ConnectionAzureArm.IdentityApplication.Configuration.json"
99+
}
100+
else
101+
{
102+
Write-Error -Message "Unsupported TP3 release" -Verbose
103+
}
104+
105+
89106
#
90107
# Step 1: Configure Bridge identity
91108
#
@@ -98,10 +115,9 @@ Write-Host "STEP 1: Configure local identity completed"
98115
# Step 2: Create new registration request
99116
#
100117

101-
$bridgeAppConfigFile = "\\SU1FileServer\SU1_Infrastructure_1\ASResourceProvider\Config\ConnectionAzureArm.IdentityApplication.Configuration.json"
102118
$registrationOutputFile = "c:\temp\registration.json"
103119
.\New-RegistrationRequest.ps1 -BridgeAppConfigFile $bridgeAppConfigFile -RegistrationRequestOutputFile $registrationOutputFile -Verbose
104-
Read-Host "STEP 2: Registration request completed. Re-enter your Azure subscription credentials in the next step. Press Enter to continue."
120+
Read-Host "STEP 2: Registration request completed. Re-enter your Azure subscription credentials in the next step. Note: Step 3 can be run from a different machine that is connected to Azure. Press Enter to continue and run step 3 from this machine."
105121

106122
#
107123
# Step 3: Register Azure Stack with Azure
@@ -158,9 +174,20 @@ $reg.properties = $newProps
158174
$reg | ConvertTo-Json -Depth 4 | Out-File -FilePath $registrationOutputFile
159175

160176
$regResponse = Get-Content -path $registrationOutputFile
161-
$bytes = [System.Text.Encoding]::Unicode.GetBytes($regResponse)
162-
$activationCode = [Convert]::ToBase64String($bytes)
177+
$AzureResourceManagerEndpoint = "https://management.azure.com"
178+
179+
if($versionInfo.Version -ge "1.0.170308.2")
180+
{
181+
$bytes = [System.Text.Encoding]::UTF8.GetBytes($regResponse)
182+
$activationCode = [Convert]::ToBase64String($bytes)
183+
.\Activate-Bridge.ps1 -activationCode $activationCode -AzureResourceManagerEndpoint $AzureResourceManagerEndpoint -Verbose
184+
}
185+
elseif($versionInfo.Version -eq "1.0.170225.2")
186+
{
187+
$bytes = [System.Text.Encoding]::Unicode.GetBytes($regResponse)
188+
$activationCode = [Convert]::ToBase64String($bytes)
189+
.\Activate-Bridge.ps1 -activationCode $activationCode -Verbose
190+
}
163191

164-
.\Activate-Bridge.ps1 -activationCode $activationCode -Verbose
165192
Write-Host "STEP 4: Activate Azure Stack completed"
166-
Write-Host "Registration complete. You may now access Marketplace Management in the Admin UI"
193+
Write-Host "Registration complete. Close and re-open the Marketplace Management blade in the admin portal."

0 commit comments

Comments
 (0)