Skip to content

Commit c11b7a0

Browse files
author
BradleyBartlett
committed
registering to azurestack rp part of script
1 parent 8dc66a3 commit c11b7a0

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Registration/RegisterWithAzure.ps1

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ This example registers your AzureStack account with Azure, enables syndication,
7070
Namespace can be registered with the following command:
7171
Register-AzureRmResourceProvider -ProviderNamespace 'microsoft.azurestack'
7272
73-
If you would like to un-Register with you azure by turning off marketplace syndication and usage reporting you can run this script again with both enableSyndication
73+
If you would like to un-Register with azure by turning off marketplace syndication and usage reporting you can run this script again with both enableSyndication
7474
and reportUsage set to false. This will unconfigure usage bridge so that syndication isn't possible and usage data is not reported.
7575
#>
7676

@@ -143,6 +143,29 @@ else {
143143

144144
$refreshToken = (ConvertTo-SecureString -string $tenantDetails["RefreshToken"] -AsPlainText -Force)
145145

146+
$maxAttempts = 3
147+
$currentAttempt = 0
148+
$registerRPsuccessful = $false
149+
do{
150+
151+
try {
152+
Register-AzureRmResourceProvider -ProviderNamespace 'Microsoft.AzureStack'-Force -Verbose
153+
$registerRPsuccessful = $true
154+
}
155+
catch {
156+
$currentAttempt++
157+
if ($currentAttempt -gt $maxAttempts)
158+
{
159+
$exceptionMessage = $_.Exception.Message
160+
Write-Warning "Failed to register the Azure resource provider 'Microsoft.AzureStack' on attempt # $currentAttempt. Cancelling RegisterWithAzure.ps1"
161+
throw $exceptionMessage
162+
}
163+
Write-Verbose "Failed to register Azure resource provider 'Microsoft.AzureStack'. Trying again in 10 seconds"
164+
Start-Sleep -Seconds 10
165+
}
166+
}while ((-not $registerRPsuccessful) -and ($currentAttempt -le $maxAttempts))
167+
168+
146169
#
147170
# Step 1: Configure Bridge identity
148171
#

0 commit comments

Comments
 (0)