Skip to content

Commit 0f6a3a4

Browse files
author
BradleyBartlett
committed
typo and type corrections
1 parent 0c762ec commit 0f6a3a4

File tree

1 file changed

+26
-35
lines changed

1 file changed

+26
-35
lines changed

Registration/RegisterWithAzure.ps1

Lines changed: 26 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ You must also have access to an account that is an owner or contributor to that
1010
1111
.DESCRIPTION
1212
13-
RegisterWithAzure runs scripts already present in Azure Stack (path: $root\CloudDeployment\Setup\Activation\Bridge)to connect your Azure Stack to Azure.
13+
RegisterWithAzure runs scripts already present in Azure Stack (path: $env:HOMEDRIVE\CloudDeployment\Setup\Activation\Bridge)to connect your Azure Stack to Azure.
1414
After connecting with Azure, you can download products from the marketplace (See the documentation for more information: https://docs.microsoft.com/en-us/azure/azure-stack/azure-stack-download-azure-marketplace-item).
1515
Running this script with default parameters will enable marketplace syndication and usage data will default to being reported to Azure.
1616
To turn these features off see examples below.
1717
18-
This script will create several resources by default:
19-
- A registration resource group and resource in Azure Stack
18+
This script will create the following resources by default:
19+
- An activation resource group and resource in Azure Stack
2020
- A resource group in Azure
2121
- A registration resource in the created resource group in Azure
2222
2323
See documentation for more detail: https://docs.microsoft.com/en-us/azure/azure-stack/azure-stack-register
2424
2525
.PARAMETER CloudAdminCredential
2626
27-
Powershell object that contains credential information such as user name and password.The CloudADmin has access to the JEA Computer (also known as Emergency Console).
27+
Powershell object that contains credential information i.e. user name and password.The CloudAdmin has access to the JEA Computer (also known as Emergency Console) to call whitelisted cmdlets and scripts.
2828
If not supplied script will request manual input of username and password
2929
3030
.PARAMETER AzureSubscriptionId
3131
32-
The subscription Id that will be used for marketplace syndication and usage. The Azure Account Id used during registration must have access to this subscription.
32+
The subscription Id that will be used for marketplace syndication and usage. The Azure Account Id used during registration must have resource creation access to this subscription.
3333
3434
.PARAMETER JeaComputerName
3535
@@ -45,15 +45,15 @@ The location where the resource group will be created. Defaults to "westcentralu
4545
4646
.PARAMETER RegistrationName
4747
48-
The name of the registration resource that will be created in Azure. If none is supplied, defaults to "AzureStack-<CloudId>" where <CloudId> is the CloudId associated with the azure Stack environment
48+
The name of the registration resource that will be created in Azure. If none is supplied, defaults to "AzureStack-<CloudId>" where <CloudId> is the CloudId associated with the Azure Stack environment
4949
5050
.PARAMETER AzureEnvironmentName
5151
5252
The name of the Azure Environment where resources will be created. Defaults to "AzureCloud"
5353
5454
.PARAMETER BillingModel
5555
56-
The billing model that the subscription uses. Select from "Capacity","PayAsYouUse", and "Development". Defaults to "Development"
56+
The billing model that the subscription uses. Select from "Capacity","PayAsYouUse", and "Development". Defaults to "Development". Pleas see documentation for more information: https://docs.microsoft.com/en-us/azure/azure-stack/azure-stack-billing-and-chargeback
5757
5858
.PARAMETER MarketplaceSyndicationEnabled
5959
@@ -69,26 +69,25 @@ Used when the billing model is set to capacity. If this is the case you will nee
6969
7070
.EXAMPLE
7171
72-
This example registers your AzureStack account with Azure, enables syndication, and enables usage reporting to Azure.
73-
This script must be run from the Host machine of the POC.
72+
This example registers your AzureStack environment with Azure, enables syndication, and enables usage reporting to Azure.
7473
7574
.\RegisterWithAzure.ps1 -CloudAdminCredential $CloudAdminCredential -AzureSubscriptionId $SubscriptionId -JeaComputername "Azs-ERC01"
7675
7776
.EXAMPLE
7877
79-
This example registers your AzureStack account with Azure, enables syndication, and disables usage reporting to Azure.
78+
This example registers your AzureStack environment with Azure, enables syndication, and disables usage reporting to Azure.
8079
8180
.\RegisterWithAzure.ps1 -CloudAdminCredential $CloudAdminCredential -AzureSubscriptionId $SubscriptionId -JeaComputername "Azs-ERC01" -UsageReportingEnabled:$false
8281
8382
.EXAMPLE
8483
85-
This example registers your AzureStack account with Azure, enables syndication and usage and gives a specific name to the resource group and registration resource.
84+
This example registers your AzureStack environment with Azure, enables syndication and usage and gives a specific name to the resource group and registration resource.
8685
8786
.\RegisterWithAzure.ps1 -CloudAdminCredential $CloudAdminCredential -AzureSubscriptionId $SubscriptionId -JeaComputername "<PreFix>-ERCS01" -ResourceGroupName "ContosoStackRegistrations" -RegistrationName "Registration01"
8887
8988
.EXAMPLE
9089
91-
This example un-Registers by disabling syndication and stopping usage push to Azure. Note that usage will still be collected, just not pushed to Azure.
90+
This example un-registers by disabling syndication and stopping usage sent to Azure. Note that usage will still be collected, just not sent to Azure.
9291
9392
.\RegisterWithAzure.ps1 -CloudAdminCredential $CloudAdminCredential -AzureSubscriptionId $SubscriptionId -JeaComputername "<Prefix>-ERC01" -MarketplaceSyndicationEnabled:$false -UsageReportingEnabled:$false
9493
@@ -139,21 +138,13 @@ param(
139138
)
140139

141140

142-
#requires -Module AzureRM.Profile
143-
#requires -Module AzureRM.Resources
141+
#requires -Version 4.0
142+
#requires -Modules @{ModuleName = "AzureRM.Profile" ; ModuleVersion = "2.7"}
143+
#requires -Modules @{ModuleName = "AzureRM.Resources" ; ModuleVersion = "3.7"}
144144

145145
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
146146
$VerbosePreference = [System.Management.Automation.ActionPreference]::Continue
147147

148-
$profileVersion = [Version](Get-Module -Name AzureRM.Profile).Version
149-
$resourcesVersion = [Version](Get-Module -Name AzureRM.Resources).Version
150-
$maxVersion = [Version]"1.0.4.4"
151-
152-
if (($profileVersion -gt $maxVersion) -or ($resourcesVersion -gt $maxVersion))
153-
{
154-
Write-Error "You are using an incompatible version of Powershell Module: AzureRm. Please use the version outlined here: `r`n https://docs.microsoft.com/en-us/azure/azure-stack/azure-stack-powershell-install"
155-
}
156-
157148
function Connect-AzureAccount
158149
{
159150
param(
@@ -215,25 +206,25 @@ function Connect-AzureAccount
215206
}
216207
}
217208

218-
Write-Verbose "Logging in to Azure." -Verbose
209+
Write-Verbose "Logging in to Azure."
219210
$connection = Connect-AzureAccount -SubscriptionId $AzureSubscriptionId -AzureEnvironment $AzureEnvironmentName
220211

221-
Write-Verbose "Initializing privileged JEA session." -Verbose
212+
Write-Verbose "Initializing privileged JEA session."
222213
$session = New-PSSession -ComputerName $JeaComputerName -ConfigurationName PrivilegedEndpoint -Credential $CloudAdminCredential
223214

224215
try
225216
{
226-
Write-Verbose "Verifying stamp version." -Verbose
217+
Write-Verbose "Verifying stamp version."
227218
$stampInfo = Invoke-Command -Session $session -ScriptBlock { Get-AzureStackStampInformation -WarningAction SilentlyContinue }
228-
$minVersion = "1.0.170626.1"
229-
if ($stampInfo.StampVersion -lt $minVersion) {
219+
$minVersion = [Version]"1.0.170626.1"
220+
if ([Version]$stampInfo.StampVersion -lt $minVersion) {
230221
Write-Error -Message "Script only applicable for Azure Stack builds $minVersion or later."
231222
}
232223

233-
Write-Verbose -Message "Running registration on build $($stampInfo.StampVersion). Cloud Id: $($stampInfo.CloudID), Deployment Id: $($stampInfo.DeploymentID)" -Verbose
224+
Write-Verbose -Message "Running registration on build $($stampInfo.StampVersion). Cloud Id: $($stampInfo.CloudID), Deployment Id: $($stampInfo.DeploymentID)"
234225

235226
$tenantId = $connection.TenantId
236-
Write-Verbose "Creating Azure Active Directory service principal in tenant: $tenantId." -Verbose
227+
Write-Verbose "Creating Azure Active Directory service principal in tenant: $tenantId."
237228
$refreshToken = $connection.Token.RefreshToken
238229

239230
$currentAttempt = 0
@@ -260,7 +251,7 @@ try
260251
}while ((-not $opSuccessful) -and ($currentAttempt -lt $maxAttempts))
261252

262253

263-
Write-Verbose "Creating registration token." -Verbose
254+
Write-Verbose "Creating registration token."
264255
$currentAttempt = 0
265256
$maxAttempts = 3
266257
$opSuccessful = $false
@@ -285,7 +276,7 @@ try
285276
}while ((-not $opSuccessful) -and ($currentAttempt -lt $maxAttempts))
286277

287278

288-
Write-Verbose "Creating resource group '$ResourceGroupName' in location $ResourceGroupLocation." -Verbose
279+
Write-Verbose "Creating resource group '$ResourceGroupName' in location $ResourceGroupLocation."
289280
$resourceGroup = New-AzureRmResourceGroup -Name $ResourceGroupName -Location $ResourceGroupLocation -Force
290281

291282
Write-Verbose "Registering Azure Stack resource provider."
@@ -314,7 +305,7 @@ try
314305
-ApiVersion "2017-06-01" `
315306
-Force
316307

317-
Write-Verbose "Setting Registration Reader role on '$($registrationResource.ResourceId)' for service principal $($servicePrincipal.ObjectId)." -Verbose
308+
Write-Verbose "Setting Registration Reader role on '$($registrationResource.ResourceId)' for service principal $($servicePrincipal.ObjectId)."
318309
$customRoleAssigned = $false
319310
$customRoleName = "Registration Reader"
320311
$roleAssignments = Get-AzureRmRoleAssignment -Scope "/subscriptions/$($registrationResource.SubscriptionId)/resourceGroups/$($registrationResource.ResourceGroupName)/providers/Microsoft.AzureStack/registrations/$($RegistrationName)" -ObjectId $servicePrincipal.ObjectId -ErrorAction SilentlyContinue
@@ -346,10 +337,10 @@ try
346337
New-AzureRmRoleAssignment -Scope "/subscriptions/$($registrationResource.SubscriptionId)/resourceGroups/$($registrationResource.ResourceGroupName)/providers/Microsoft.AzureStack/registrations/$($RegistrationName)" -RoleDefinitionName $customRoleName -ObjectId $servicePrincipal.ObjectId
347338
}
348339

349-
Write-Verbose "Activating Azure Stack (this may take several minutes to complete)." -Verbose
340+
Write-Verbose "Activating Azure Stack (this may take several minutes to complete)."
350341
$activation = Invoke-Command -Session $session -ScriptBlock { New-AzureStackActivation -ActivationKey $using:actionResponse.ActivationKey }
351342

352-
Write-Verbose "Azure Stack registration and activation completed successfully." -Verbose
343+
Write-Verbose "Azure Stack registration and activation completed successfully."
353344
}
354345
finally
355346
{

0 commit comments

Comments
 (0)