Skip to content

Commit

Permalink
AzureResourceGroupDeploymentTask: Improving error log to point to Dep…
Browse files Browse the repository at this point in the history
…loyment logs in Ibiza Portal (#11853)

* Init

* Refactoring

* Update Tasks/AzureResourceManagerTemplateDeploymentV3/task.json

Co-Authored-By: Bishal Prasad <[email protected]>

* Adding functionality for AzureResourceGroupDeploymentV2

* Updating error message

* Handling deploymentScope as Resource Group

* Handling management group

* Updating message

* Review comments

* Updating task version

* Bug fix

* Print log for subscription as well

* Bug fix
  • Loading branch information
issacnitinmsft authored Dec 5, 2019
1 parent f36e3fc commit 8f02a1c
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,6 @@
"loc.messages.LogDeploymentName": "Deployment name is %s",
"loc.messages.ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
"loc.messages.DeploymentGroupConfigurationNotSucceeded": "Deployment group configuration did not succeed on one or more Virtual Machine(s): %s",
"loc.messages.DeploymentGroupConfigurationFailedOnVM": "Failure for Virtual Machine '%s': %s"
"loc.messages.DeploymentGroupConfigurationFailedOnVM": "Failure for Virtual Machine '%s': %s",
"loc.messages.FindMoreDeploymentDetailsAzurePortal": "Task successfully created an Azure Resource Manager deployment, but the deployment failed. Please see more detailed Azure resource manager deployment logs at: (Please Copy-Paste the link) %s"
}
18 changes: 18 additions & 0 deletions Tasks/AzureResourceGroupDeploymentV2/operations/ResourceGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ export class ResourceGroup {
}
if (result.error) {
this.writeDeploymentErrors(result.error);
tl.error(tl.loc("FindMoreDeploymentDetailsAzurePortal", this.getAzurePortalDeploymentURL()));
return reject(tl.loc("CreateTemplateDeploymentFailed"));
} else {
console.log(tl.loc("ValidDeployment"));
Expand All @@ -537,6 +538,7 @@ export class ResourceGroup {
return this.waitAndPerformAzureDeployment(armClient, deployment, retryCount);
}
this.writeDeploymentErrors(error);
this.checkAndPrintPortalDeploymentURL();
return reject(tl.loc("CreateTemplateDeploymentFailed"));
}
if (result && result["properties"] && result["properties"]["outputs"] && utils.isNonEmpty(this.taskParameters.deploymentOutputs)) {
Expand All @@ -551,6 +553,10 @@ export class ResourceGroup {
}
}

protected checkAndPrintPortalDeploymentURL() {
tl.error(tl.loc("FindMoreDeploymentDetailsAzurePortal", this.getAzurePortalDeploymentURL()));
}

private async waitAndPerformAzureDeployment(armClient: armResource.ResourceManagementClient, deployment: Deployment, retryCount): Promise<void> {
await sleepFor(3);
return this.performAzureDeployment(armClient, deployment, retryCount - 1);
Expand All @@ -569,6 +575,18 @@ export class ResourceGroup {
await this.performAzureDeployment(armClient, deployment, 3);
}

private getAzurePortalDeploymentURL() {
try {
let portalUrl = this.taskParameters.endpointPortalUrl ? this.taskParameters.endpointPortalUrl : "https://portal.azure.com";
portalUrl += "/#blade/HubsExtension/DeploymentDetailsBlade/overview/id/";
let subscriptionSpecificURL = "/subscriptions/" + this.taskParameters.subscriptionId + "/resourceGroups/" + this.taskParameters.resourceGroupName + "/providers/Microsoft.Resources/deployments/" + this.taskParameters.deploymentName;
return portalUrl + subscriptionSpecificURL.replace(/\//g, '%2F');
} catch (error) {
tl.error(error);
return error;
}
}

private escapeBlockCharacters(str: string): string {
return str.replace(/[\[]/g, '$&[]');
}
Expand Down
5 changes: 3 additions & 2 deletions Tasks/AzureResourceGroupDeploymentV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 2,
"Minor": 157,
"Patch": 8
"Patch": 10
},
"demands": [],
"minimumAgentVersion": "2.119.1",
Expand Down Expand Up @@ -480,6 +480,7 @@
"LogDeploymentName": "Deployment name is %s",
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
"DeploymentGroupConfigurationNotSucceeded": "Deployment group configuration did not succeed on one or more Virtual Machine(s): %s",
"DeploymentGroupConfigurationFailedOnVM": "Failure for Virtual Machine '%s': %s"
"DeploymentGroupConfigurationFailedOnVM": "Failure for Virtual Machine '%s': %s",
"FindMoreDeploymentDetailsAzurePortal": "Task successfully created an Azure Resource Manager deployment, but the deployment failed. Please see more detailed Azure resource manager deployment logs at: (Please Copy-Paste the link) %s"
}
}
5 changes: 3 additions & 2 deletions Tasks/AzureResourceGroupDeploymentV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 2,
"Minor": 157,
"Patch": 8
"Patch": 10
},
"demands": [],
"minimumAgentVersion": "2.119.1",
Expand Down Expand Up @@ -480,6 +480,7 @@
"LogDeploymentName": "ms-resource:loc.messages.LogDeploymentName",
"ExpiredServicePrincipal": "ms-resource:loc.messages.ExpiredServicePrincipal",
"DeploymentGroupConfigurationNotSucceeded": "ms-resource:loc.messages.DeploymentGroupConfigurationNotSucceeded",
"DeploymentGroupConfigurationFailedOnVM": "ms-resource:loc.messages.DeploymentGroupConfigurationFailedOnVM"
"DeploymentGroupConfigurationFailedOnVM": "ms-resource:loc.messages.DeploymentGroupConfigurationFailedOnVM",
"FindMoreDeploymentDetailsAzurePortal": "ms-resource:loc.messages.FindMoreDeploymentDetailsAzurePortal"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,6 @@
"loc.messages.ResourceGroupNameNotProvided": "Resource Group name should be provided",
"loc.messages.LocationNotProvided": "Location is required for deployment",
"loc.messages.ARMServiceConnectionScope": "ARM Service Conection deployment scope - %s",
"loc.messages.CompleteDeploymentModeNotSupported": "Deployment mode 'Complete' is not supported for deployment at '%s' scope"
"loc.messages.CompleteDeploymentModeNotSupported": "Deployment mode 'Complete' is not supported for deployment at '%s' scope",
"loc.messages.FindMoreDeploymentDetailsAzurePortal": "Task successfully created an Azure Resource Manager deployment, but the deployment failed. Please see more detailed Azure resource manager deployment logs at: (Please Copy-Paste the link) %s"
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ export class DeploymentScopeBase {
return this.waitAndPerformAzureDeployment(retryCount);
}
utils.writeDeploymentErrors(this.taskParameters, error);
this.checkAndPrintPortalDeploymentURL();

return reject(tl.loc("CreateTemplateDeploymentFailed"));
}
if (result && result["properties"] && result["properties"]["outputs"] && utils.isNonEmpty(this.taskParameters.deploymentOutputs)) {
Expand All @@ -68,6 +70,31 @@ export class DeploymentScopeBase {
}
}

protected checkAndPrintPortalDeploymentURL() {
if(this.taskParameters.deploymentScope == "Resource Group") {
tl.error(tl.loc("FindMoreDeploymentDetailsAzurePortal", this.getAzurePortalDeploymentURL()));
}
}

private getAzurePortalDeploymentURL() {
try {
let portalUrl = this.taskParameters.endpointPortalUrl ? this.taskParameters.endpointPortalUrl : "https://portal.azure.com";
portalUrl += "/#blade/HubsExtension/DeploymentDetailsBlade/overview/id/";

let subscriptionSpecificURL = "/subscriptions/" + this.taskParameters.subscriptionId;
if(this.taskParameters.deploymentScope == "Resource Group") {
subscriptionSpecificURL += "/resourceGroups/" + this.taskParameters.resourceGroupName;
}

subscriptionSpecificURL += "/providers/Microsoft.Resources/deployments/" + this.taskParameters.deploymentName;

return portalUrl + subscriptionSpecificURL.replace(/\//g, '%2F');
} catch (error) {
tl.error(error);
return error;
}
}

protected validateDeployment(): Promise<void> {
return new Promise<void>((resolve, reject) => {
console.log(tl.loc("StartingValidation"));
Expand Down
5 changes: 3 additions & 2 deletions Tasks/AzureResourceManagerTemplateDeploymentV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 3,
"Minor": 1,
"Patch": 5
"Patch": 7
},
"preview": "true",
"demands": [],
Expand Down Expand Up @@ -301,6 +301,7 @@
"ResourceGroupNameNotProvided": "Resource Group name should be provided",
"LocationNotProvided": "Location is required for deployment",
"ARMServiceConnectionScope": "ARM Service Conection deployment scope - %s",
"CompleteDeploymentModeNotSupported": "Deployment mode 'Complete' is not supported for deployment at '%s' scope"
"CompleteDeploymentModeNotSupported": "Deployment mode 'Complete' is not supported for deployment at '%s' scope",
"FindMoreDeploymentDetailsAzurePortal": "Task successfully created an Azure Resource Manager deployment, but the deployment failed. Please see more detailed Azure resource manager deployment logs at: (Please Copy-Paste the link) %s"
}
}
5 changes: 3 additions & 2 deletions Tasks/AzureResourceManagerTemplateDeploymentV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"version": {
"Major": 3,
"Minor": 1,
"Patch": 5
"Patch": 7
},
"preview": "true",
"demands": [],
Expand Down Expand Up @@ -301,6 +301,7 @@
"ResourceGroupNameNotProvided": "ms-resource:loc.messages.ResourceGroupNameNotProvided",
"LocationNotProvided": "ms-resource:loc.messages.LocationNotProvided",
"ARMServiceConnectionScope": "ms-resource:loc.messages.ARMServiceConnectionScope",
"CompleteDeploymentModeNotSupported": "ms-resource:loc.messages.CompleteDeploymentModeNotSupported"
"CompleteDeploymentModeNotSupported": "ms-resource:loc.messages.CompleteDeploymentModeNotSupported",
"FindMoreDeploymentDetailsAzurePortal": "ms-resource:loc.messages.FindMoreDeploymentDetailsAzurePortal"
}
}

0 comments on commit 8f02a1c

Please sign in to comment.