Capture Azure exception message

I’m fighting with Azure and publishing via PowerShell at the moment.
It seems that powershell is problematic and does not want to play. Especially with slow deployment times – you need to wait for it to throw errors, and that usually takes 3-15 minutes depending on your internet speed.

So you would want to get error message captured:

# try publish - here I get 500 server error
New-AzureDeployment -Slot Staging -Package $package -Configuration $configuration -ServiceName $service

# capture error stream
$sr = new-object System.IO.StreamReader($Error[0].Exception.InnerException.Response.GetResponseStream())  
$txt = $sr.ReadToEnd() 

# print out the message
$txt

Hopefully this will help a bit.
Info taken from this guy