@@ -84,13 +84,13 @@ This example registers your AzureStack account with Azure, enables syndication,
8484
8585This example registers your AzureStack account with Azure, enables syndication and usage and gives a specific name to the resource group and registration resource.
8686
87- .\RegisterWithAzure.ps1 -CloudAdminCredential $CloudAdminCredential -AzureSubscriptionId $SubscriptionId -JeaComputername "Prefix -ERCS01" -ResourceGroupName "ContosoStackRegistrations" -RegistrationName "Registration01"
87+ .\RegisterWithAzure.ps1 -CloudAdminCredential $CloudAdminCredential -AzureSubscriptionId $SubscriptionId -JeaComputername "<PreFix> -ERCS01" -ResourceGroupName "ContosoStackRegistrations" -RegistrationName "Registration01"
8888
8989. EXAMPLE
9090
9191This example un-Registers by disabling syndication and stopping usage push to Azure. Note that usage will still be collected, just not pushed to Azure.
9292
93- .\RegisterWithAzure.ps1 -CloudAdminCredential $CloudAdminCredential -AzureSubscriptionId $SubscriptionId -JeaComputername "Azs -ERC01" -MarketplaceSyndicationEnabled:$false -UsageReportingEnabled:$false
93+ .\RegisterWithAzure.ps1 -CloudAdminCredential $CloudAdminCredential -AzureSubscriptionId $SubscriptionId -JeaComputername "<Prefix> -ERC01" -MarketplaceSyndicationEnabled:$false -UsageReportingEnabled:$false
9494
9595. NOTES
9696
@@ -235,10 +235,55 @@ try
235235 $tenantId = $connection.TenantId
236236 Write-Verbose " Creating Azure Active Directory service principal in tenant: $tenantId ." - Verbose
237237 $refreshToken = $connection.Token.RefreshToken
238- $servicePrincipal = Invoke-Command - Session $session - ScriptBlock { New-AzureBridgeServicePrincipal - RefreshToken $using :refreshToken - AzureEnvironment $using :AzureEnvironmentName - TenantId $using :tenantId }
238+
239+ $currentAttempt = 0
240+ $maxAttempts = 3
241+ $opSuccessful = $false
242+ $sleepSeconds = 10
243+ do {
244+ try
245+ {
246+ $servicePrincipal = Invoke-Command - Session $session - ScriptBlock { New-AzureBridgeServicePrincipal - RefreshToken $using :refreshToken - AzureEnvironment $using :AzureEnvironmentName - TenantId $using :tenantId }
247+ $opSuccessful = $true
248+ }
249+ catch
250+ {
251+ Write-Verbose " Creation of service principal failed:`r`n $ ( $_.Exception.Message ) "
252+ Write-Verbose " Waiting $sleepSeconds seconds and trying again..."
253+ $currentAttempt ++
254+ Start-Sleep - Seconds $sleepSeconds
255+ if ($currentAttempt -eq $maxAttempts )
256+ {
257+ throw $_.Exception
258+ }
259+ }
260+ }while ((-not $opSuccessful ) -and ($currentAttempt -lt $maxAttempts ))
261+
239262
240263 Write-Verbose " Creating registration token." - Verbose
241- $registrationToken = Invoke-Command - Session $session - ScriptBlock { New-RegistrationToken - BillingModel $using :BillingModel - MarketplaceSyndicationEnabled:$using :MarketplaceSyndicationEnabled - UsageReportingEnabled:$using :UsageReportingEnabled - AgreementNumber $using :AgreementNumber }
264+ $currentAttempt = 0
265+ $maxAttempts = 3
266+ $opSuccessful = $false
267+ $sleepSeconds = 10
268+ do {
269+ try
270+ {
271+ $registrationToken = Invoke-Command - Session $session - ScriptBlock { New-RegistrationToken - BillingModel $using :BillingModel - MarketplaceSyndicationEnabled:$using :MarketplaceSyndicationEnabled - UsageReportingEnabled:$using :UsageReportingEnabled - AgreementNumber $using :AgreementNumber }
272+ $opSuccessful = $true
273+ }
274+ catch
275+ {
276+ Write-Verbose " Creation of service principal failed:`r`n $ ( $_.Exception.Message ) "
277+ Write-Verbose " Waiting $sleepSeconds seconds and trying again..."
278+ $currentAttempt ++
279+ Start-Sleep - Seconds $sleepSeconds
280+ if ($currentAttempt -eq $maxAttempts )
281+ {
282+ throw $_.Exception
283+ }
284+ }
285+ }while ((-not $opSuccessful ) -and ($currentAttempt -lt $maxAttempts ))
286+
242287
243288 Write-Verbose " Creating resource group '$ResourceGroupName ' in location $ResourceGroupLocation ." - Verbose
244289 $resourceGroup = New-AzureRmResourceGroup - Name $ResourceGroupName - Location $ResourceGroupLocation - Force
0 commit comments