Skip to content

Commit

Permalink
Users/suaggar/code cleanup (#11886)
Browse files Browse the repository at this point in the history
* cleanup
  • Loading branch information
suaggar authored and leantk committed Dec 23, 2019
1 parent 475ee18 commit f765c93
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { IWebAppDeploymentProvider } from './IWebAppDeploymentProvider';
import { TaskParameters } from '../taskparameters';
import { KuduServiceUtility } from 'azurermdeploycommon/operations/KuduServiceUtility';
import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility'

import { AzureAppService } from 'azurermdeploycommon/azure-arm-rest/azure-arm-app-service';
import { Kudu } from 'azurermdeploycommon/azure-arm-rest/azure-arm-app-service-kudu';
import { AzureAppServiceUtility } from 'azurermdeploycommon/operations/AzureAppServiceUtility';
import tl = require('azure-pipelines-task-lib/task');
import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility'
import { addReleaseAnnotation } from 'azurermdeploycommon/operations/ReleaseAnnotationUtility';
import { PackageUtility } from 'azurermdeploycommon/webdeployment-common/packageUtility';
import { AzureDeployPackageArtifactAlias } from 'azurermdeploycommon/Constants';
import { AzureEndpoint } from 'azurermdeploycommon/azure-arm-rest/azureModels';
import { AzureRmEndpointAuthenticationScheme } from 'azurermdeploycommon/azure-arm-rest/constants';
import { IWebAppDeploymentProvider } from './IWebAppDeploymentProvider';
import { Kudu } from 'azurermdeploycommon/azure-arm-rest/azure-arm-app-service-kudu';
import { KuduServiceUtility } from 'azurermdeploycommon/operations/KuduServiceUtility';
import { PackageUtility } from 'azurermdeploycommon/webdeployment-common/packageUtility';
import { TaskParameters } from '../taskparameters';
import { addReleaseAnnotation } from 'azurermdeploycommon/operations/ReleaseAnnotationUtility';

import tl = require('azure-pipelines-task-lib/task');

import publishProfileUtility = require("utility-common-v2/publishProfileUtility");
import { AzureEndpoint } from 'azurermdeploycommon/azure-arm-rest/azureModels';

export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvider {
protected taskParams:TaskParameters;
Expand All @@ -22,8 +25,7 @@ export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvide
protected virtualApplicationPath: string = "";
protected activeDeploymentID;
protected publishProfileScmCredentials: publishProfileUtility.ScmCredentials;
protected isPublishProfileAuthSchemeEndpoint: boolean = false;
protected slotName: string;
protected slotName;

constructor(taskParams: TaskParameters) {
this.taskParams = taskParams;
Expand All @@ -34,7 +36,6 @@ export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvide
public async PreDeploymentStep() {
if (this.taskParams.azureEndpoint.scheme && this.taskParams.azureEndpoint.scheme.toLowerCase() === AzureRmEndpointAuthenticationScheme.PublishProfile) {
let publishProfileEndpoint: AzureEndpoint = this.taskParams.azureEndpoint;
this.isPublishProfileAuthSchemeEndpoint = true;
this.publishProfileScmCredentials = await publishProfileUtility.getSCMCredentialsFromPublishProfile(publishProfileEndpoint.PublishProfile);
this.kuduService = new Kudu(this.publishProfileScmCredentials.scmUri, this.publishProfileScmCredentials.username, this.publishProfileScmCredentials.password);
let resourceId = publishProfileEndpoint.resourceId;
Expand All @@ -53,16 +54,17 @@ export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvide
public async DeployWebAppStep() {}

public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) {
if(this.kuduServiceUtility) {
if (!this.isPublishProfileAuthSchemeEndpoint) {
await addReleaseAnnotation(this.taskParams.azureEndpoint, this.appService, isDeploymentSuccess);
}
if(!!this.appService) {
await addReleaseAnnotation(this.taskParams.azureEndpoint, this.appService, isDeploymentSuccess);
}

if(!!this.kuduServiceUtility) {
this.activeDeploymentID = await this.kuduServiceUtility.updateDeploymentStatus(isDeploymentSuccess, null, {'type': 'Deployment', slotName: this.slotName});
tl.debug('Active DeploymentId :'+ this.activeDeploymentID);
}

let appServiceApplicationUrl: string;
if (!this.isPublishProfileAuthSchemeEndpoint) {
if (!!this.appServiceUtility) {
appServiceApplicationUrl = await this.appServiceUtility.getApplicationURL();
} else {
appServiceApplicationUrl = this.publishProfileScmCredentials.applicationUrl;
Expand All @@ -72,7 +74,7 @@ export class AzureRmWebAppDeploymentProvider implements IWebAppDeploymentProvide
}

protected async PostDeploymentStep() {
if (!this.isPublishProfileAuthSchemeEndpoint) {
if (!!this.appServiceUtility) {
if(this.taskParams.AppSettings) {
var customApplicationSettings = ParameterParser.parse(this.taskParams.AppSettings);
await this.appServiceUtility.updateAndMonitorAppSettings(customApplicationSettings);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider';
import tl = require('azure-pipelines-task-lib/task');
import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility'

import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider';
import { PackageType } from 'azurermdeploycommon/webdeployment-common/packageUtility';

import tl = require('azure-pipelines-task-lib/task');

var webCommonUtility = require('azurermdeploycommon/webdeployment-common/utility.js');
var deployUtility = require('azurermdeploycommon/webdeployment-common/utility.js');
var zipUtility = require('azurermdeploycommon/webdeployment-common/ziputility.js');
Expand Down Expand Up @@ -60,12 +62,11 @@ export class BuiltInLinuxWebAppDeploymentProvider extends AzureRmWebAppDeploymen
}

public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) {
await super.UpdateDeploymentStatus(isDeploymentSuccess);
if(this.kuduServiceUtility) {
if(this.zipDeploymentID && this.activeDeploymentID && isDeploymentSuccess) {
await this.kuduServiceUtility.postZipDeployOperation(this.zipDeploymentID, this.activeDeploymentID);
}

await super.UpdateDeploymentStatus(isDeploymentSuccess);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider';
import tl = require('azure-pipelines-task-lib/task');
import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility'

import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider';
import { DeploymentType } from '../taskparameters';
import { FileTransformsUtility } from 'azurermdeploycommon/operations/FileTransformsUtility.js';
import { PackageType } from 'azurermdeploycommon/webdeployment-common/packageUtility';
import { addReleaseAnnotation } from 'azurermdeploycommon/operations/ReleaseAnnotationUtility';
import { FileTransformsUtility } from 'azurermdeploycommon/operations/FileTransformsUtility.js';

import tl = require('azure-pipelines-task-lib/task');

var deployUtility = require('azurermdeploycommon/webdeployment-common/utility.js');
var zipUtility = require('azurermdeploycommon/webdeployment-common/ziputility.js');

Expand Down Expand Up @@ -36,7 +39,7 @@ export class WindowsWebAppRunFromZipProvider extends AzureRmWebAppDeploymentProv
}

tl.debug("Initiated deployment via kudu service for webapp package : " + webPackage);
if (!this.isPublishProfileAuthSchemeEndpoint) {
if (!!this.appServiceUtility) {
var addCustomApplicationSetting = ParameterParser.parse(runFromZipAppSetting);
var deleteCustomApplicationSetting = ParameterParser.parse(oldRunFromZipAppSetting);
var isNewValueUpdated: boolean = await this.appServiceUtility.updateAndMonitorAppSettings(addCustomApplicationSetting, deleteCustomApplicationSetting);
Expand All @@ -55,14 +58,17 @@ export class WindowsWebAppRunFromZipProvider extends AzureRmWebAppDeploymentProv
}

public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) {
if (this.isPublishProfileAuthSchemeEndpoint) {
await super.UpdateDeploymentStatus(isDeploymentSuccess);
} else {
if(!!this.appService) {
await addReleaseAnnotation(this.taskParams.azureEndpoint, this.appService, isDeploymentSuccess);
}

let appServiceApplicationUrl: string = await this.appServiceUtility.getApplicationURL();
console.log(tl.loc('AppServiceApplicationURL', appServiceApplicationUrl));
tl.setVariable('AppServiceApplicationUrl', appServiceApplicationUrl);
let appServiceApplicationUrl: string;
if (!!this.appServiceUtility) {
appServiceApplicationUrl = await this.appServiceUtility.getApplicationURL();
} else {
appServiceApplicationUrl = this.publishProfileScmCredentials.applicationUrl;
}
console.log(tl.loc('AppServiceApplicationURL', appServiceApplicationUrl));
tl.setVariable('AppServiceApplicationUrl', appServiceApplicationUrl);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider';

import tl = require('azure-pipelines-task-lib/task');
var webCommonUtility = require('azurermdeploycommon/webdeployment-common/utility.js');


export class WindowsWebAppWarDeployProvider extends AzureRmWebAppDeploymentProvider {

private zipDeploymentID: string;
Expand All @@ -25,8 +25,8 @@ export class WindowsWebAppWarDeployProvider extends AzureRmWebAppDeploymentProvi
}

public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) {
await super.UpdateDeploymentStatus(isDeploymentSuccess);
if(this.kuduServiceUtility) {
await super.UpdateDeploymentStatus(isDeploymentSuccess);
if(this.zipDeploymentID && this.activeDeploymentID && isDeploymentSuccess) {
await this.kuduServiceUtility.postZipDeployOperation(this.zipDeploymentID, this.activeDeploymentID);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider';
import tl = require('azure-pipelines-task-lib/task');
import * as ParameterParser from 'azurermdeploycommon/operations/ParameterParserUtility'

import { AzureRmWebAppDeploymentProvider } from './AzureRmWebAppDeploymentProvider';
import { DeploymentType } from '../taskparameters';
import { PackageType } from 'azurermdeploycommon/webdeployment-common/packageUtility';
import { FileTransformsUtility } from 'azurermdeploycommon/operations/FileTransformsUtility.js';
import { PackageType } from 'azurermdeploycommon/webdeployment-common/packageUtility';

import tl = require('azure-pipelines-task-lib/task');

const removeRunFromZipAppSetting: string = '-WEBSITE_RUN_FROM_PACKAGE -WEBSITE_RUN_FROM_ZIP';
var deployUtility = require('azurermdeploycommon/webdeployment-common/utility.js');
var zipUtility = require('azurermdeploycommon/webdeployment-common/ziputility.js');
Expand Down Expand Up @@ -35,9 +38,9 @@ export class WindowsWebAppZipDeployProvider extends AzureRmWebAppDeploymentProvi
}

tl.debug("Initiated deployment via kudu service for webapp package : ");
if (!this.isPublishProfileAuthSchemeEndpoint) {
if (!!this.appServiceUtility) {
var deleteApplicationSetting = ParameterParser.parse(removeRunFromZipAppSetting)
var isNewValueUpdated: boolean = await this.appServiceUtility.updateAndMonitorAppSettings(null, deleteApplicationSetting);
var isNewValueUpdated: boolean = await this.appServiceUtility.updateAndMonitorAppSettings(null, deleteApplicationSetting);

if(!isNewValueUpdated) {
await this.kuduServiceUtility.warmpUp();
Expand All @@ -52,8 +55,8 @@ export class WindowsWebAppZipDeployProvider extends AzureRmWebAppDeploymentProvi
}

public async UpdateDeploymentStatus(isDeploymentSuccess: boolean) {
await super.UpdateDeploymentStatus(isDeploymentSuccess);
if(this.kuduServiceUtility) {
await super.UpdateDeploymentStatus(isDeploymentSuccess);
if(this.zipDeploymentID && this.activeDeploymentID && isDeploymentSuccess) {
await this.kuduServiceUtility.postZipDeployOperation(this.zipDeploymentID, this.activeDeploymentID);
}
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureWebAppV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 1,
"Minor": 160,
"Patch": 1
"Patch": 2
},
"minimumAgentVersion": "2.104.1",
"groups": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureWebAppV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"version": {
"Major": 1,
"Minor": 160,
"Patch": 1
"Patch": 2
},
"minimumAgentVersion": "2.104.1",
"groups": [
Expand Down

0 comments on commit f765c93

Please sign in to comment.