Skip to content

Commit 0958ee2

Browse files
author
BradleyBartlett
committed
adding logging for step: register-AzureStack
1 parent 85ccec7 commit 0958ee2

1 file changed

Lines changed: 22 additions & 10 deletions

File tree

Registration/RegisterWithAzure.ps1

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ This script must be run from the Host machine of the POC.
5555
Register-AzureRmResourceProvider -ProviderNamespace 'microsoft.azurestack'
5656
#>
5757

58+
5859
[CmdletBinding()]
5960
param(
6061
[Parameter(Mandatory=$false)]
@@ -131,6 +132,7 @@ $refreshToken = (ConvertTo-SecureString -string $tenantDetails["RefreshToken"] -
131132
# Step 1: Configure Bridge identity
132133
#
133134

135+
Write-Verbose "Calling Configure-BridgeIdentity.ps1"
134136
.\Configure-BridgeIdentity.ps1 -RefreshToken $refreshToken -AzureAccountId $azureAccountId -AzureDirectoryTenantName $azureDirectoryTenantName -AzureEnvironment $azureEnvironment -Verbose
135137
Write-Verbose "Configure Bridge identity completed"
136138

@@ -140,6 +142,8 @@ Write-Verbose "Configure Bridge identity completed"
140142

141143
$bridgeAppConfigFile = "\\SU1FileServer\SU1_Infrastructure_1\ASResourceProvider\Config\AzureBridge.IdentityApplication.Configuration.json"
142144
$registrationOutputFile = "c:\temp\registration.json"
145+
146+
Write-Verbose "Calling New-RegistrationRequest.ps1"
143147
.\New-RegistrationRequest.ps1 -BridgeAppConfigFile $bridgeAppConfigFile -RegistrationRequestOutputFile $registrationOutputFile -Verbose
144148
Write-Verbose "New registration request completed"
145149

@@ -151,10 +155,18 @@ New-Item -ItemType Directory -Force -Path "C:\temp"
151155
$registrationRequestFile = "c:\temp\registration.json"
152156
$registrationOutputFile = "c:\temp\registrationOutput.json"
153157

154-
.\Register-AzureStack.ps1 -BillingModel PayAsYouUse -EnableSyndication -ReportUsage -SubscriptionId $azureSubscriptionId -AzureAdTenantId $AzureDirectoryTenantId `
155-
-RefreshToken $refreshToken -AzureAccountId $azureAccountId -AzureEnvironmentName $azureEnvironment -RegistrationRequestFile $registrationRequestFile `
156-
-RegistrationOutputFile $registrationOutputFile -Location "westcentralus" -Verbose
157-
Write-Verbose "Register Azure Stack with Azure completed"
158+
$timestamp = [DateTime]::Now.ToString("yyyyMMdd-HHmmss")
159+
$logPath = (New-Item -Path "$env:SystemDrive\CloudDeployment\Logs\" -ItemType Directory -Force).FullName
160+
$logFile = Join-Path -Path $logPath -ChildPath "Register-AzureStack.${timestamp}.txt"
161+
try { Start-Transcript -Path $logFile -Force | Out-String | Write-Verbose -Verbose } catch { Write-Warning -Message $_.Exception.Message }
162+
163+
Write-Verbose "Calling Register-AzureStack.ps1"
164+
.\Register-AzureStack.ps1 -BillingModel PayAsYouUse -EnableSyndication -ReportUsage -SubscriptionId $azureSubscriptionId -AzureAdTenantId $AzureDirectoryTenantId `
165+
-RefreshToken $refreshToken -AzureAccountId $azureAccountId -AzureEnvironmentName $azureEnvironment -RegistrationRequestFile $registrationRequestFile `
166+
-RegistrationOutputFile $registrationOutputFile -Location "westcentralus" -Verbose
167+
Write-Verbose "Register Azure Stack with Azure completed"
168+
169+
try { Stop-Transcript -Verbose } catch { Write-Warning "$_" }
158170

159171
#
160172
# workaround to enable syndication and usage
@@ -190,14 +202,14 @@ catch
190202
{
191203
$exceptionMessage = $_.Exception.Message
192204

193-
if($exceptionMessage.Contains("Application is currently being upgraded"))
194-
{
205+
if($exceptionMessage.Contains("Application is currently being upgraded"))
206+
{
195207
Write-Warning "Activate-Bridge: Known issue with redundant service fabric upgrade call"
196-
}
197-
else
198-
{
208+
}
209+
else
210+
{
199211
Write-Error -Message "Activate-Bridge: Error : $($_.Exception)"
200-
}
212+
}
201213
}
202214

203215
Write-Verbose "Azure Stack activation completed"

0 commit comments

Comments
 (0)