Skip to content

Commit

Permalink
Merge pull request #1766 from Microsoft/users/anaggar/ConnectionTypeT…
Browse files Browse the repository at this point in the history
…oImproveErrorMessage

using connection type to improve error message
  • Loading branch information
anaggar committed May 20, 2016
2 parents 86e50ff + 29329db commit c902bb8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopy/AzureFileCopy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ try
-storageAccountName $storageAccount -containerName $containerName -containerSasToken $containerSasToken -targetPath $targetPath -azCopyLocation $azCopyLocation `
-resourceGroupName $environmentName -azureVMResourcesProperties $azureVMResourcesProperties -azureVMsCredentials $azureVMsCredentials `
-cleanTargetBeforeCopy $cleanTargetBeforeCopy -communicationProtocol $useHttpsProtocolOption -skipCACheckOption $skipCACheckOption `
-enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -copyFilesInParallel $copyFilesInParallel
-enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -copyFilesInParallel $copyFilesInParallel -connectionType $connectionType
}
catch
{
Expand Down
28 changes: 20 additions & 8 deletions Tasks/AzureFileCopy/Utility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,8 @@ function Copy-FilesSequentiallyToAzureVMs
[string]$communicationProtocol,
[string][Parameter(Mandatory=$true)]$skipCACheckOption,
[string][Parameter(Mandatory=$true)]$enableDetailedLoggingString,
[string]$additionalArguments)
[string]$additionalArguments,
[string][Parameter(Mandatory=$true)]$connectionType)

foreach ($resource in $azureVMResourcesProperties.Keys)
{
Expand All @@ -924,7 +925,12 @@ function Copy-FilesSequentiallyToAzureVMs
if ($status -ne "Passed")
{
$winrmHelpMsg = Get-LocalizedString -Key "TofixWinRMconnectionrelatedissuesselectthe"
$copyErrorMessage = $copyResponse.Error.Message + $winrmHelpMsg
$copyErrorMessage = $copyResponse.Error.Message
if($connectionType -eq 'ServicePrincipal')
{
$copyErrorMessage = $copyErrorMessage + $winrmHelpMsg
}

Write-Verbose "CopyErrorMessage: $copyErrorMessage" -Verbose

Write-TaskSpecificTelemetry "UNKNOWNDEP_Error"
Expand All @@ -946,7 +952,8 @@ function Copy-FilesParallellyToAzureVMs
[string]$communicationProtocol,
[string][Parameter(Mandatory=$true)]$skipCACheckOption,
[string][Parameter(Mandatory=$true)]$enableDetailedLoggingString,
[string]$additionalArguments)
[string]$additionalArguments,
[string][Parameter(Mandatory=$true)]$connectionType)

[hashtable]$Jobs = @{}
foreach ($resource in $azureVMResourcesProperties.Keys)
Expand All @@ -973,7 +980,7 @@ function Copy-FilesParallellyToAzureVMs
if ($Jobs.ContainsKey($job.Id) -and $job.State -ne "Running")
{
$output = Receive-Job -Id $job.Id
Remove-Job $Job
Remove-Job $Job

$status = $output.Status
$resourceName = $Jobs.Item($job.Id).Name
Expand All @@ -988,7 +995,11 @@ function Copy-FilesParallellyToAzureVMs
if($output.Error -ne $null)
{
$winrmHelpMsg = Get-LocalizedString -Key "TofixWinRMconnectionrelatedissuesselectthe"
$errorMessage = $output.Error.Message + $winrmHelpMsg
$errorMessage = $output.Error.Message
if($connectionType -eq 'ServicePrincipal')
{
$errorMessage = $errorMessage + $winrmHelpMsg
}
}

Write-Output (Get-LocalizedString -Key "Copy failed on machine '{0}' with following message : '{1}'" -ArgumentList $resourceName, $errorMessage)
Expand Down Expand Up @@ -1022,7 +1033,8 @@ function Copy-FilesToAzureVMsFromStorageContainer
[string][Parameter(Mandatory=$true)]$skipCACheckOption,
[string][Parameter(Mandatory=$true)]$enableDetailedLoggingString,
[string]$additionalArguments,
[string][Parameter(Mandatory=$true)]$copyFilesInParallel)
[string][Parameter(Mandatory=$true)]$copyFilesInParallel,
[string][Parameter(Mandatory=$true)]$connectionType)

# copies files sequentially
if ($copyFilesInParallel -eq "false" -or ( $azureVMResourcesProperties.Count -eq 1 ))
Expand All @@ -1032,7 +1044,7 @@ function Copy-FilesToAzureVMsFromStorageContainer
-storageAccountName $storageAccountName -containerName $containerName -containerSasToken $containerSasToken -targetPath $targetPath -azCopyLocation $azCopyLocation `
-azureVMResourcesProperties $azureVMResourcesProperties -azureVMsCredentials $azureVMsCredentials `
-cleanTargetBeforeCopy $cleanTargetBeforeCopy -communicationProtocol $communicationProtocol -skipCACheckOption $skipCACheckOption `
-enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments
-enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -connectionType $connectionType
}
# copies files parallelly
else
Expand All @@ -1041,7 +1053,7 @@ function Copy-FilesToAzureVMsFromStorageContainer
-storageAccountName $storageAccountName -containerName $containerName -containerSasToken $containerSasToken -targetPath $targetPath -azCopyLocation $azCopyLocation `
-azureVMResourcesProperties $azureVMResourcesProperties -azureVMsCredentials $azureVMsCredentials `
-cleanTargetBeforeCopy $cleanTargetBeforeCopy -communicationProtocol $communicationProtocol -skipCACheckOption $skipCACheckOption `
-enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments
-enableDetailedLoggingString $enableDetailedLoggingString -additionalArguments $additionalArguments -connectionType $connectionType
}

# if no error thrown, copy successfully succeeded
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopy/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 55
"Patch": 56
},
"demands": [
"azureps"
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopy/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 55
"Patch": 56
},
"demands": [
"azureps"
Expand Down

0 comments on commit c902bb8

Please sign in to comment.