本文整理汇总了TypeScript中azure-arm-rest/azure-arm-app-service-kudu.Kudu.uploadFile方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Kudu.uploadFile方法的具体用法?TypeScript Kudu.uploadFile怎么用?TypeScript Kudu.uploadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azure-arm-rest/azure-arm-app-service-kudu.Kudu
的用法示例。
在下文中一共展示了Kudu.uploadFile方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: runPostDeploymentScript
public async runPostDeploymentScript(taskParams: TaskParameters, directoryPath?: string): Promise<void> {
var uniqueID = this.getDeploymentID();
let vstsPostDeploymentFolderPath: string = path.join(physicalRootPath.substring(1), '..', 'VSTS_PostDeployment_' + uniqueID);
try {
var rootDirectoryPath = directoryPath || physicalRootPath.substring(1);
if(taskParams.TakeAppOfflineFlag) {
await this._appOfflineKuduService(rootDirectoryPath, true);
}
var scriptFile = this._getPostDeploymentScript(taskParams.ScriptType, taskParams.InlineScript, taskParams.ScriptPath, taskParams.isLinuxApp);
var fileExtension : string = taskParams.isLinuxApp ? '.sh' : '.cmd';
var mainCmdFilePath = path.join(__dirname, '..', 'postDeploymentScript', 'mainCmdFile' + fileExtension);
await this._appServiceKuduService.uploadFile(vstsPostDeploymentFolderPath, 'mainCmdFile' + fileExtension, mainCmdFilePath);
await this._appServiceKuduService.uploadFile(vstsPostDeploymentFolderPath, 'kuduPostDeploymentScript' + fileExtension, scriptFile.filePath);
console.log(tl.loc('ExecuteScriptOnKudu'));
var cmdFilePath = '%Home%\\site\\VSTS_PostDeployment_' + uniqueID + '\\mainCmdFile' + fileExtension;
var scriprResultPath = '/site/VSTS_PostDeployment_' + uniqueID;
if (taskParams.isLinuxApp){
cmdFilePath = '/home/site/VSTS_PostDeployment_' + uniqueID + '/mainCmdFile' + fileExtension;
}
await this.runCommand(rootDirectoryPath, cmdFilePath + ' ' + uniqueID, 30, scriprResultPath, 'script_result.txt');
await this._printPostDeploymentLogs(vstsPostDeploymentFolderPath);
}
catch(error) {
if(taskParams.UseWebDeploy && taskParams.DeploymentType === DeploymentType.runFromZip) {
var debugMode = tl.getVariable('system.debug');
if(debugMode && debugMode.toLowerCase() == 'true') {
tl.warning(tl.loc('Publishusingrunfromzipwithpostdeploymentscript'));
}
else {
console.log(tl.loc('Publishusingrunfromzipwithpostdeploymentscript'));
}
}
throw Error(tl.loc('FailedToRunScriptOnKuduError', error));
}
finally {
try {
let deleteFilePath = '%Home%\\site\\VSTS_PostDeployment_' + uniqueID + '\\delete_log_file' + fileExtension;
if(taskParams.isLinuxApp) {
deleteFilePath = '/home/site/VSTS_PostDeployment_' + uniqueID + '/delete_log_file' + fileExtension;
}
await this._appServiceKuduService.uploadFile(vstsPostDeploymentFolderPath, 'delete_log_file' + fileExtension, path.join(__dirname, '..', 'postDeploymentScript', 'deleteLogFile' + fileExtension));
await this.runCommand(vstsPostDeploymentFolderPath, deleteFilePath);
await this._appServiceKuduService.deleteFolder(vstsPostDeploymentFolderPath);
}
catch(error) {
tl.debug('Unable to delete log files : ' + error);
}
if(taskParams.TakeAppOfflineFlag) {
await this._appOfflineKuduService(rootDirectoryPath, false);
}
}
}
示例2: _preZipDeployOperation
private async _preZipDeployOperation(): Promise<void> {
try {
tl.debug('ZIP DEPLOY - Performing pre-zipdeploy operation.');
let activeDeploymentID: string = await this._appServiceKuduService.getFileContent(deploymentFolder, 'active');
if(!!activeDeploymentID) {
let activeDeploymentFolder: string = `${deploymentFolder}/${activeDeploymentID}`;
tl.debug(`Active Deployment ID: '${activeDeploymentID}'. Deployment Folder: '${activeDeploymentFolder}'`);
let manifestFileContent: string = await this._appServiceKuduService.getFileContent(activeDeploymentFolder, manifestFileName);
if(!manifestFileContent) {
tl.debug(`No Manifest file present. Creating a empty manifest file in '${activeDeploymentFolder}' directory.`);
var tempManifestFile: string = path.join(tl.getVariable('AGENT.TEMPDIRECTORY'), manifestFileName);
tl.writeFile(tempManifestFile, '');
await this._appServiceKuduService.uploadFile(`${activeDeploymentFolder}`, manifestFileName, tempManifestFile);
tl.debug(`Manifest file created in '${activeDeploymentFolder}' directory.`);
}
else {
tl.debug('Manifest file present in active deployment directory. Skip creating a new one.');
}
tl.debug('ZIP DEPLOY - Performed pre-zipdeploy operation.');
}
}
catch(error) {
tl.debug(`Failed to execute pre zip-deploy operation: ${JSON.stringify(error)}.`);
}
}
示例3: _appOfflineKuduService
private async _appOfflineKuduService(physicalPath: string, enableFeature: boolean): Promise<void> {
if(enableFeature) {
tl.debug('Trying to enable app offline mode.');
var appOfflineFilePath = path.join(tl.getVariable('AGENT.TEMPDIRECTORY'), 'app_offline_temp.htm');
tl.writeFile(appOfflineFilePath, '<h1>App Service is offline.</h1>');
await this._appServiceKuduService.uploadFile(physicalPath, 'app_offline.htm', appOfflineFilePath);
tl.debug('App Offline mode enabled.');
}
else {
tl.debug('Trying to disable app offline mode.');
await this._appServiceKuduService.deleteFile(physicalPath, 'app_offline.htm');
tl.debug('App Offline mode disabled.');
}
}
示例4: runPostDeploymentScript
public async runPostDeploymentScript(taskParams: TaskParameters, directoryPath?: string): Promise<void> {
try {
directoryPath = (!!directoryPath) ? directoryPath : physicalRootPath.substring(1);
if(taskParams.TakeAppOfflineFlag) {
await this._appOfflineKuduService(directoryPath, true);
}
var scriptFile = this._getPostDeploymentScript(taskParams.ScriptType, taskParams.InlineScript, taskParams.ScriptPath, taskParams.isLinuxApp);
var uniqueID = this.getDeploymentID();
var fileExtension : string = taskParams.isLinuxApp ? '.sh' : '.cmd';
var mainCmdFilePath = path.join(__dirname, '..', 'postDeploymentScript', 'mainCmdFile' + fileExtension);
await this._appServiceKuduService.uploadFile(directoryPath, 'mainCmdFile_' + uniqueID + fileExtension, mainCmdFilePath);
await this._appServiceKuduService.uploadFile(directoryPath, 'kuduPostDeploymentScript_' + uniqueID + fileExtension, scriptFile.filePath);
console.log(tl.loc('ExecuteScriptOnKudu'));
await this.runCommand(directoryPath,
(taskParams.isLinuxApp ? 'sh ' : '') + 'mainCmdFile_' + uniqueID + fileExtension + ' ' + uniqueID,
30, 'script_result_' + uniqueID + '.txt');
await this._printPostDeploymentLogs(directoryPath, uniqueID);
}
catch(error) {
throw Error(tl.loc('FailedToRunScriptOnKuduError', error));
}
finally {
try {
await this._appServiceKuduService.uploadFile(directoryPath, 'delete_log_file_' + uniqueID + fileExtension, path.join(__dirname, '..', 'postDeploymentScript', 'deleteLogFile' + fileExtension));
await this.runCommand(directoryPath, (taskParams.isLinuxApp ? 'sh ' : '') + 'delete_log_file_' + uniqueID + fileExtension + ' ' + uniqueID, 0, null);
}
catch(error) {
tl.debug('Unable to delete log files : ' + error);
}
if(taskParams.TakeAppOfflineFlag) {
await this._appOfflineKuduService(directoryPath, false);
}
}
}
示例5: postZipDeployOperation
public async postZipDeployOperation(oldDeploymentID: string, activeDeploymentID: string): Promise<void> {
try {
tl.debug(`ZIP DEPLOY - Performing post zip-deploy operation: ${oldDeploymentID} => ${activeDeploymentID}`);
let manifestFileContent = await this._appServiceKuduService.getFileContent(`${deploymentFolder}/${oldDeploymentID}`, manifestFileName);
if(!!manifestFileContent) {
let tempManifestFile: string = path.join(tl.getVariable('AGENT.TEMPDIRECTORY'), manifestFileName);
tl.writeFile(tempManifestFile, manifestFileContent);
await this._appServiceKuduService.uploadFile(`${deploymentFolder}/${activeDeploymentID}`, manifestFileName, tempManifestFile);
}
tl.debug('ZIP DEPLOY - Performed post-zipdeploy operation.');
}
catch(error) {
tl.debug(`Failed to execute post zip-deploy operation: ${JSON.stringify(error)}.`);
}
}