Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve sql azure deployment task errors handling #3263

Merged
merged 5 commits into from
Dec 22, 2016

Conversation

Ajay-MS
Copy link

@Ajay-MS Ajay-MS commented Dec 16, 2016

No description provided.

@Ajay-MS Ajay-MS added this to the dev15rtm milestone Dec 16, 2016
Copy link
Contributor

@rohit-batra rohit-batra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments shared

}
catch [System.Exception]
else
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If some Exception is raised here , We wont be returning result or exception trace in that case, right ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything during execution of command fails it will come as part of result.


param(
[string]$command,
[bool] $failOnErr = $true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit pick - we can have verbose name like failOnError

@@ -722,6 +726,9 @@ function Parse-Exception($exception){
$responseBody = $streamReader.ReadToEnd()
$streamReader.Close()
Write-Verbose "Exception message extracted from response $responseBody"
if($response.statusCode -eq 404){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do/Should We need to handle any othe rcase here like 500 etc ?

@@ -202,12 +202,12 @@ Catch [System.Management.Automation.CommandNotFoundException]
Write-Host "3. Run Import-Module SQLPS on your agent Powershell prompt. (This step is not required on Powershell 3.0 enabled machines)"
}

Write-Error ($_.Exception|Format-List -Force|Out-String)
Write-Error ($_.Exception.Message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we do like this - if exception.Message is not null and empty then write error.message but it is empty or null write full exception

@@ -664,7 +664,9 @@ function Add-AzureSqlDatabaseServerFirewallRule
$parsedException = Parse-Exception($_.Exception)
if($parsedException)
{
throw $parsedException
Write-Verbose $parsedException
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be within Parse-Exception.

$ErrorActionPreference = 'Continue'
if( $psversiontable.PSVersion.Major -le 4)
{
$result = cmd.exe /c "`"$command`"" 2>&1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be using the task lib tool runner for this.

catch [System.Exception]
else
{
$result = cmd.exe /c "$command" 2>&1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here. Use task lib.

@@ -713,6 +713,7 @@ function Remove-AzureSqlDatabaseServerFirewallRule

function Parse-Exception($exception){
if($exception) {
Write-Verbose "Exception message - $($exception.ToString())"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add L0 tests for validating various error scenarios

@Ajay-MS Ajay-MS merged commit 26a606f into master Dec 22, 2016
@bryanmacfarlane bryanmacfarlane deleted the users/ajya/improveSqlAzureErrorHandling branch January 31, 2018 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants