-
Notifications
You must be signed in to change notification settings - Fork 4k
Show OperationID from CloudException thrown by Compute Cmdlets #546
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
Changes from all commits
7a280cf
7d4cfda
c59fb5f
285f13b
bdb3985
b686007
e5b1ae3
b1693f5
4fc5a79
0b02e14
f33010d
8564936
6df726d
97b0d36
17fa11b
7385b7d
6d9910d
e016ebd
ff2a772
e7d36d8
1eb17b6
5b31531
607100d
8dcfc83
bd3fd32
e68d101
422520e
23a4517
b25048a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Hyak.Common; | ||
using System; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Microsoft.WindowsAzure.Commands.Common | ||
{ | ||
public class ComputeCloudException : CloudException | ||
{ | ||
protected const string RequestIdHeaderInResponse = "x-ms-request-id"; | ||
|
||
public ComputeCloudException(CloudException ex) | ||
: base(GetErrorMessageWithRequestIdInfo(ex), ex) | ||
{ | ||
} | ||
|
||
protected static string GetErrorMessageWithRequestIdInfo(CloudException cloudException) | ||
{ | ||
if (cloudException == null) | ||
{ | ||
throw new ArgumentNullException("cloudException"); | ||
} | ||
|
||
var sb = new StringBuilder(); | ||
|
||
if (!string.IsNullOrEmpty(cloudException.Message)) | ||
{ | ||
sb.Append(cloudException.Message); | ||
} | ||
|
||
if (cloudException.Response != null && | ||
cloudException.Response.Headers != null) | ||
{ | ||
var headers = cloudException.Response.Headers; | ||
if (headers.ContainsKey(RequestIdHeaderInResponse)) | ||
{ | ||
sb.AppendLine().AppendFormat( | ||
Properties.Resources.ComputeCloudExceptionOperationIdMessage, | ||
headers[RequestIdHeaderInResponse].FirstOrDefault()); | ||
} | ||
} | ||
|
||
return sb.ToString(); | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,3 +88,4 @@ function Cleanup-Storage | |
Write-Warning "Cannot Remove the Storage Account" | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,19 +21,16 @@ | |
|
||
namespace Microsoft.WindowsAzure.Commands.ScenarioTest | ||
{ | ||
public partial class AzureVMTests | ||
public partial class ServiceManagementTests | ||
{ | ||
private EnvironmentSetupHelper helper = new EnvironmentSetupHelper(); | ||
|
||
#region Get-AzureVM Scenario Tests | ||
|
||
[Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test takes 151.519s which is too much. since you are working with these tests, could you take a look why it is soo long? Consider removing it from CheckIn category if it is too complex and there is no way to make it run shorter. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests related to VM usually take some time. Can we create a separate items to track and fix it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ~3 minutes it too much for recorded tests but I'm ok to track it as a separate item. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test is not run in the PR test, but in the post-check-in test, right? |
||
public void TestGetAzureVM() | ||
{ | ||
this.RunPowerShellTest("Test-GetAzureVM"); | ||
} | ||
#endregion | ||
|
||
protected void SetupManagementClients() | ||
{ | ||
|
@@ -48,7 +45,7 @@ protected void RunPowerShellTest(params string[] scripts) | |
|
||
SetupManagementClients(); | ||
|
||
List<string> modules = Directory.GetFiles("Resources\\ServiceManagement", "*.ps1").ToList(); | ||
List<string> modules = Directory.GetFiles(@"Resources\ServiceManagement", "*.ps1").ToList(); | ||
modules.Add("Common.ps1"); | ||
modules.Add(@"..\..\..\..\Package\Debug\ServiceManagement\Azure\Azure.psd1"); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
{ | ||
"Entries": [ | ||
{ | ||
"RequestUri": "/4d368445-cbb1-42a7-97a6-6850ab99f48e/services/hostedservices/*", | ||
"EncodedRequestUri": "LzRkMzY4NDQ1LWNiYjEtNDJhNy05N2E2LTY4NTBhYjk5ZjQ4ZS9zZXJ2aWNlcy9ob3N0ZWRzZXJ2aWNlcy8lMkE=", | ||
"RequestMethod": "GET", | ||
"RequestBody": "", | ||
"RequestHeaders": { | ||
"x-ms-version": [ | ||
"2015-04-01" | ||
], | ||
"User-Agent": [ | ||
"Microsoft.WindowsAzure.Management.Compute.ComputeManagementClient/12.0.0.0" | ||
] | ||
}, | ||
"ResponseBody": "<Error xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <Code>BadRequest</Code>\r\n <Message>The hosted service name is invalid.</Message>\r\n</Error>", | ||
"ResponseHeaders": { | ||
"Content-Length": [ | ||
"194" | ||
], | ||
"Content-Type": [ | ||
"application/xml; charset=utf-8" | ||
], | ||
"x-ms-servedbyregion": [ | ||
"ussouth3" | ||
], | ||
"Strict-Transport-Security": [ | ||
"max-age=31536000; includeSubDomains" | ||
], | ||
"x-ms-request-id": [ | ||
"8fbc1c1bfd26be549be7ac6edfe8fd67" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 24 Jun 2015 21:52:37 GMT" | ||
], | ||
"Server": [ | ||
"1.0.6198.243", | ||
"(rd_rdfe_stable.150618-1025)", | ||
"Microsoft-HTTPAPI/2.0" | ||
] | ||
}, | ||
"StatusCode": 400 | ||
}, | ||
{ | ||
"RequestUri": "/4d368445-cbb1-42a7-97a6-6850ab99f48e/services/hostedservices/*/deploymentslots/Production", | ||
"EncodedRequestUri": "LzRkMzY4NDQ1LWNiYjEtNDJhNy05N2E2LTY4NTBhYjk5ZjQ4ZS9zZXJ2aWNlcy9ob3N0ZWRzZXJ2aWNlcy8lMkEvZGVwbG95bWVudHNsb3RzL1Byb2R1Y3Rpb24=", | ||
"RequestMethod": "GET", | ||
"RequestBody": "", | ||
"RequestHeaders": { | ||
"x-ms-version": [ | ||
"2015-04-01" | ||
], | ||
"User-Agent": [ | ||
"Microsoft.WindowsAzure.Management.Compute.ComputeManagementClient/12.0.0.0" | ||
] | ||
}, | ||
"ResponseBody": "<Error xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <Code>BadRequest</Code>\r\n <Message>The hosted service name is invalid.</Message>\r\n</Error>", | ||
"ResponseHeaders": { | ||
"Content-Length": [ | ||
"194" | ||
], | ||
"Content-Type": [ | ||
"application/xml; charset=utf-8" | ||
], | ||
"x-ms-servedbyregion": [ | ||
"ussouth3" | ||
], | ||
"Strict-Transport-Security": [ | ||
"max-age=31536000; includeSubDomains" | ||
], | ||
"x-ms-request-id": [ | ||
"235043d87cdfbdbea385a799a177dbeb" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 24 Jun 2015 21:52:37 GMT" | ||
], | ||
"Server": [ | ||
"1.0.6198.243", | ||
"(rd_rdfe_stable.150618-1025)", | ||
"Microsoft-HTTPAPI/2.0" | ||
] | ||
}, | ||
"StatusCode": 400 | ||
}, | ||
{ | ||
"RequestUri": "/4d368445-cbb1-42a7-97a6-6850ab99f48e/affinitygroups/*", | ||
"EncodedRequestUri": "LzRkMzY4NDQ1LWNiYjEtNDJhNy05N2E2LTY4NTBhYjk5ZjQ4ZS9hZmZpbml0eWdyb3Vwcy8lMkE=", | ||
"RequestMethod": "GET", | ||
"RequestBody": "", | ||
"RequestHeaders": { | ||
"x-ms-version": [ | ||
"2014-10-01" | ||
], | ||
"User-Agent": [ | ||
"Microsoft.WindowsAzure.Management.ManagementClient/4.0.0.0" | ||
] | ||
}, | ||
"ResponseBody": "<Error xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">\r\n <Code>ResourceNotFound</Code>\r\n <Message>The affinity group does not exist.</Message>\r\n</Error>", | ||
"ResponseHeaders": { | ||
"Content-Length": [ | ||
"199" | ||
], | ||
"Content-Type": [ | ||
"application/xml; charset=utf-8" | ||
], | ||
"x-ms-servedbyregion": [ | ||
"ussouth3" | ||
], | ||
"x-ms-request-id": [ | ||
"e7eb6116c17abe61b27520096b982601" | ||
], | ||
"Cache-Control": [ | ||
"no-cache" | ||
], | ||
"Date": [ | ||
"Wed, 24 Jun 2015 21:52:38 GMT" | ||
], | ||
"Server": [ | ||
"1.0.6198.243", | ||
"(rd_rdfe_stable.150618-1025)", | ||
"Microsoft-HTTPAPI/2.0" | ||
] | ||
}, | ||
"StatusCode": 404 | ||
} | ||
], | ||
"Names": {}, | ||
"Variables": { | ||
"SubscriptionId": "4d368445-cbb1-42a7-97a6-6850ab99f48e" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit. you can do the same thing with a little bit less code:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Thanks!