diff --git a/appservice/src/SiteWrapper.ts b/appservice/src/SiteWrapper.ts index c206fe52c7..0262a91a1e 100644 --- a/appservice/src/SiteWrapper.ts +++ b/appservice/src/SiteWrapper.ts @@ -96,8 +96,8 @@ export class SiteWrapper { public async updateConfiguration(client: WebSiteManagementClient, config: SiteConfigResource): Promise { return this.slotName ? - await client.webApps.updateConfigurationSlot(this.resourceGroup, this.appName, config, this.slotName) : - await client.webApps.updateConfiguration(this.resourceGroup, this.appName, config); + await client.webApps.updateConfigurationSlot(this.resourceGroup, this.name, config, this.slotName) : + await client.webApps.updateConfiguration(this.resourceGroup, this.name, config); } public async getAppServicePlan(client: WebSiteManagementClient): Promise { @@ -138,7 +138,62 @@ export class SiteWrapper { outputChannel.appendLine(localize('DeleteSucceeded', 'Successfully deleted "{0}".', this.appName)); } - public async deployZip(fsPath: string, client: WebSiteManagementClient, outputChannel: vscode.OutputChannel): Promise { + public async deploy(fsPath: string, client: WebSiteManagementClient, outputChannel: vscode.OutputChannel): Promise { + const config: SiteConfigResource = await this.getSiteConfig(client); + switch (config.scmType) { + case 'LocalGit': + await this.localGitDeploy(fsPath, client, outputChannel); + break; + default: + await this.deployZip(fsPath, client, outputChannel); + break; + } + } + + public async isHttpLogsEnabled(client: WebSiteManagementClient): Promise { + const logsConfig: SiteLogsConfig = this.slotName ? await client.webApps.getDiagnosticLogsConfigurationSlot(this.resourceGroup, this.name, this.slotName) : + await client.webApps.getDiagnosticLogsConfiguration(this.resourceGroup, this.name); + return logsConfig.httpLogs && logsConfig.httpLogs.fileSystem && logsConfig.httpLogs.fileSystem.enabled; + } + + public async enableHttpLogs(client: WebSiteManagementClient): Promise { + const logsConfig: SiteLogsConfig = { + location: this.location, + httpLogs: { + fileSystem: { + enabled: true, + retentionInDays: 7, + retentionInMb: 35 + } + } + }; + + if (this.slotName) { + await client.webApps.updateDiagnosticLogsConfigSlot(this.resourceGroup, this.name, logsConfig, this.slotName); + } else { + await client.webApps.updateDiagnosticLogsConfig(this.resourceGroup, this.name, logsConfig); + } + } + + public async getKuduClient(client: WebSiteManagementClient): Promise { + const user: User = await this.getWebAppPublishCredential(client); + if (!user.publishingUserName || !user.publishingPassword) { + throw new ArgumentError(user); + } + + const cred: BasicAuthenticationCredentials = new BasicAuthenticationCredentials(user.publishingUserName, user.publishingPassword); + + return new KuduClient(cred, `https://${this.appName}.scm.azurewebsites.net`); + } + + public async editScmType(client: WebSiteManagementClient): Promise { + const config: SiteConfigResource = await this.getSiteConfig(client); + const newScmType: string = await this.showScmPrompt(config.scmType); + // returns the updated scmType + return await this.updateScmType(client, config, newScmType); + } + + private async deployZip(fsPath: string, client: WebSiteManagementClient, outputChannel: vscode.OutputChannel): Promise { const warning: string = localize('zipWarning', 'Are you sure you want to deploy to "{0}"? This will overwrite any previous deployment and cannot be undone.', this.appName); if (await vscode.window.showWarningMessage(warning, DialogResponses.yes, DialogResponses.cancel) !== DialogResponses.yes) { throw new UserCancelledError(); @@ -182,7 +237,7 @@ export class SiteWrapper { this.log(outputChannel, 'Deployment completed.'); } - public async localGitDeploy(fsPath: string, client: WebSiteManagementClient, outputChannel: vscode.OutputChannel): Promise { + private async localGitDeploy(fsPath: string, client: WebSiteManagementClient, outputChannel: vscode.OutputChannel): Promise { const kuduClient: KuduClient = await this.getKuduClient(client); const pushReject: string = localize('localGitPush', 'Push rejected due to Git history diverging. Force push?'); const publishCredentials: User = await this.getWebAppPublishCredential(client); @@ -217,50 +272,9 @@ export class SiteWrapper { throw err; } } - return await this.waitForDeploymentToComplete(kuduClient, outputChannel); - } - - public async isHttpLogsEnabled(client: WebSiteManagementClient): Promise { - const logsConfig: SiteLogsConfig = this.slotName ? await client.webApps.getDiagnosticLogsConfigurationSlot(this.resourceGroup, this.name, this.slotName) : - await client.webApps.getDiagnosticLogsConfiguration(this.resourceGroup, this.name); - return logsConfig.httpLogs && logsConfig.httpLogs.fileSystem && logsConfig.httpLogs.fileSystem.enabled; - } - - public async enableHttpLogs(client: WebSiteManagementClient): Promise { - const logsConfig: SiteLogsConfig = { - location: this.location, - httpLogs: { - fileSystem: { - enabled: true, - retentionInDays: 7, - retentionInMb: 35 - } - } - }; - - if (this.slotName) { - await client.webApps.updateDiagnosticLogsConfigSlot(this.resourceGroup, this.name, logsConfig, this.slotName); - } else { - await client.webApps.updateDiagnosticLogsConfig(this.resourceGroup, this.name, logsConfig); - } - } - - public async getKuduClient(client: WebSiteManagementClient): Promise { - const user: User = await this.getWebAppPublishCredential(client); - if (!user.publishingUserName || !user.publishingPassword) { - throw new ArgumentError(user); - } - - const cred: BasicAuthenticationCredentials = new BasicAuthenticationCredentials(user.publishingUserName, user.publishingPassword); - - return new KuduClient(cred, `https://${this.appName}.scm.azurewebsites.net`); - } - - public async editScmType(client: WebSiteManagementClient): Promise { - const config: SiteConfigResource = await this.getSiteConfig(client); - const newScmType: string = await this.showScmPrompt(config.scmType); - // returns the updated scmType - return await this.updateScmType(client, config, newScmType); + this.log(outputChannel, (localize('localGitDeploy', `Deploying Local Git repository to "${this.appName}"...`))); + await this.waitForDeploymentToComplete(kuduClient, outputChannel); + this.log(outputChannel, 'Deployment completed.'); } private async showScmPrompt(currentScmType: string): Promise {