Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,15 @@ public DeploymentExtended ProvisionDeploymentStatus(PSDeploymentCmdletParameters
var deploymentExtended = this.WaitDeploymentStatus(
getDeploymentFunc,
writeProgressAction,
deploymentOperationError,
ProvisioningState.Canceled,
ProvisioningState.Succeeded,
ProvisioningState.Failed);

if (deploymentOperationError.ErrorMessages.Count > 0)
{
WriteError(GetDeploymentErrorMessagesWithOperationId(deploymentOperationError, parameters.DeploymentName));
WriteError(GetDeploymentErrorMessagesWithOperationId(deploymentOperationError,
parameters.DeploymentName,
deploymentExtended?.Properties?.CorrelationId));
}

return deploymentExtended;
Expand Down Expand Up @@ -318,7 +319,6 @@ private void WriteDeploymentProgress(PSDeploymentCmdletParameters parameters, De
private DeploymentExtended WaitDeploymentStatus(
Func<Task<AzureOperationResponse<DeploymentExtended>>> getDeployment,
Action listDeploymentOperations,
DeploymentOperationErrorInfo deploymentOperationError,
params ProvisioningState[] status)
{
DeploymentExtended deployment;
Expand Down Expand Up @@ -349,10 +349,9 @@ private DeploymentExtended WaitDeploymentStatus(

using (var getResult = getDeploymentTask.ConfigureAwait(false).GetAwaiter().GetResult())
{
deploymentOperationError.SetCorrelationIdFromResponseHeaders(getResult?.Response);

deployment = getResult.Body;
var response = getResult.Response;

if (response != null && response.Headers.RetryAfter != null && response.Headers.RetryAfter.Delta.HasValue)
{
step = response.Headers.RetryAfter.Delta.Value.Seconds;
Expand Down Expand Up @@ -1702,7 +1701,7 @@ public virtual PSResource GetById(string resourceId, string apiVersion)
return null;
}

public string GetDeploymentErrorMessagesWithOperationId(DeploymentOperationErrorInfo errorInfo, string deploymentName = null)
public string GetDeploymentErrorMessagesWithOperationId(DeploymentOperationErrorInfo errorInfo, string deploymentName = null, string correlationId = null)
{
if (errorInfo.ErrorMessages.Count == 0)
return String.Empty;
Expand All @@ -1726,7 +1725,7 @@ public string GetDeploymentErrorMessagesWithOperationId(DeploymentOperationError
.AppendLine());

// Add correlationId
sb.AppendLine().AppendFormat(ProjectResources.DeploymentCorrelationId, errorInfo.CorrelationId);
sb.AppendLine().AppendFormat(ProjectResources.DeploymentCorrelationId, correlationId);

return sb.ToString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,10 @@ public class DeploymentOperationErrorInfo
public DeploymentOperationErrorInfo()
{
ErrorMessages = new List<ErrorResponse>();
CorrelationId = string.Empty;
}

public List<ErrorResponse> ErrorMessages { get; private set; }

public string CorrelationId { get; private set; }

#region Public Methods

public void ProcessError(DeploymentOperation operation)
Expand All @@ -52,15 +49,6 @@ public void ProcessError(DeploymentOperation operation)
ErrorMessages.Add(error);
}
}
public void SetCorrelationIdFromResponseHeaders(HttpResponseMessage response)
{
CorrelationId = string.Empty;

if (response?.Headers != null && response.Headers.TryGetValues("x-ms-request-id", out IEnumerable<string> requestIdValues))
{
CorrelationId = string.Join(";", requestIdValues);
}
}
#endregion

#region Static Methods
Expand Down