本文整理汇总了TypeScript中azurermdeploycommon/webdeployment-common/utility.js.default.generateTemporaryFolderOrZipPath方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.generateTemporaryFolderOrZipPath方法的具体用法?TypeScript js.default.generateTemporaryFolderOrZipPath怎么用?TypeScript js.default.generateTemporaryFolderOrZipPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类azurermdeploycommon/webdeployment-common/utility.js.default
的用法示例。
在下文中一共展示了js.default.generateTemporaryFolderOrZipPath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: DeployWebAppStep
public async DeployWebAppStep() {
let packageType = this.taskParams.Package.getPackageType();
let deploymentMethodtelemetry = packageType === PackageType.war ? '{"deploymentMethod":"War Deploy"}' : '{"deploymentMethod":"Zip Deploy"}';
console.log("##vso[telemetry.publish area=TaskDeploymentMethod;feature=AzureWebAppDeployment]" + deploymentMethodtelemetry);
tl.debug('Performing Linux built-in package deployment');
await this.kuduServiceUtility.warmpUp();
switch(packageType){
case PackageType.folder:
let tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
let archivedWebPackage = await zipUtility.archiveFolder(this.taskParams.Package.getPath(), "", tempPackagePath);
tl.debug("Compressed folder into zip " + archivedWebPackage);
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(archivedWebPackage);
break;
case PackageType.zip:
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(this.taskParams.Package.getPath());
break;
case PackageType.jar:
tl.debug("Initiated deployment via kudu service for webapp jar package : "+ this.taskParams.Package.getPath());
var folderPath = await webCommonUtility.generateTemporaryFolderForDeployment(false, this.taskParams.Package.getPath(), PackageType.jar);
var jarName = webCommonUtility.getFileNameFromPath(this.taskParams.Package.getPath(), ".jar");
var destRootPath = "/home/site/wwwroot/";
var script = 'java -jar "' + destRootPath + jarName + '.jar' + '" --server.port=80';
var initScriptFileName = "startupscript_" + jarName + ".sh";
var initScriptFile = path.join(folderPath, initScriptFileName);
var destInitScriptPath = destRootPath + initScriptFileName;
if(!this.taskParams.AppSettings) {
this.taskParams.AppSettings = "-INIT_SCRIPT " + destInitScriptPath;
}
if(this.taskParams.AppSettings.indexOf("-INIT_SCRIPT") < 0) {
this.taskParams.AppSettings += " -INIT_SCRIPT " + destInitScriptPath;
}
this.taskParams.AppSettings = this.taskParams.AppSettings.trim();
tl.writeFile(initScriptFile, script, { encoding: 'utf8' });
var output = await webCommonUtility.archiveFolderForDeployment(false, folderPath);
var webPackage = output.webDeployPkg;
tl.debug("Initiated deployment via kudu service for webapp jar package : "+ webPackage);
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingZipDeploy(webPackage);
break;
case PackageType.war:
tl.debug("Initiated deployment via kudu service for webapp war package : "+ this.taskParams.Package.getPath());
var warName = webCommonUtility.getFileNameFromPath(this.taskParams.Package.getPath(), ".war");
this.zipDeploymentID = await this.kuduServiceUtility.deployUsingWarDeploy(this.taskParams.Package.getPath(),
{ slotName: this.appService.getSlot() }, warName);
break;
default:
throw new Error(tl.loc('Invalidwebapppackageorfolderpathprovided', this.taskParams.Package.getPath()));
}
await this.appServiceUtility.updateStartupCommandAndRuntimeStack(this.taskParams.RuntimeStack, this.taskParams.StartupCommand);
await this.PostDeploymentStep();
}
示例2: DeployWebAppStep
public async DeployWebAppStep() {
let deploymentMethodtelemetry = '{"deploymentMethod":"Run from Package"}';
console.log("##vso[telemetry.publish area=TaskDeploymentMethod;feature=AzureWebAppDeployment]" + deploymentMethodtelemetry);
var webPackage = await FileTransformsUtility.applyTransformations(this.taskParams.Package.getPath(), this.taskParams.WebConfigParameters, this.taskParams.Package.getPackageType());
if(this.taskParams.DeploymentType === DeploymentType.runFromPackage) {
var _isMSBuildPackage = await this.taskParams.Package.isMSBuildPackage();
if(_isMSBuildPackage) {
throw Error(tl.loc("Publishusingzipdeploynotsupportedformsbuildpackage"));
}
else if(this.taskParams.Package.getPackageType() === PackageType.war) {
throw Error(tl.loc("Publishusingzipdeploydoesnotsupportwarfile"));
}
}
if(tl.stats(webPackage).isDirectory()) {
let tempPackagePath = deployUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
webPackage = await zipUtility.archiveFolder(webPackage, "", tempPackagePath);
tl.debug("Compressed folder into zip " + webPackage);
}
tl.debug("Initiated deployment via kudu service for webapp package : ");
var addCustomApplicationSetting = ParameterParser.parse(runFromZipAppSetting);
var deleteCustomApplicationSetting = ParameterParser.parse(oldRunFromZipAppSetting);
var isNewValueUpdated: boolean = await this.appServiceUtility.updateAndMonitorAppSettings(addCustomApplicationSetting, deleteCustomApplicationSetting);
if(!isNewValueUpdated) {
await this.kuduServiceUtility.warmpUp();
}
await this.kuduServiceUtility.deployUsingRunFromZip(webPackage,
{ slotName: this.appService.getSlot() });
await this.PostDeploymentStep();
}
示例3: uploadPackage
private async uploadPackage(storageDetails, deployPackage) : Promise<string> {
let defer = Q.defer<string>();
let storageAccount = storageDetails["AccountName"];
let storageKey = storageDetails["AccountKey"];
const blobService = azureStorage.createBlobService(storageAccount, storageKey);
const containerName: string = 'azure-pipelines-deploy';
const blobName: string = `package_${Date.now()}.zip`;
let fileName;
switch(deployPackage.getPackageType()){
case PackageType.folder:
let tempPackagePath = webCommonUtility.generateTemporaryFolderOrZipPath(tl.getVariable('AGENT.TEMPDIRECTORY'), false);
let archivedWebPackage;
try {
archivedWebPackage = await zipUtility.archiveFolder(deployPackage.getPath(), "", tempPackagePath);
}
catch(error) {
defer.reject(error);
}
tl.debug("Compressed folder into zip " + archivedWebPackage);
fileName = archivedWebPackage;
break;
case PackageType.zip:
fileName = deployPackage.getPath();
break;
default:
throw new Error(tl.loc('Invalidwebapppackageorfolderpathprovided', deployPackage.getPath()));
}
blobService.createContainerIfNotExists(containerName, error => {
if (error){
defer.reject(error);
}
//upoading package
blobService.createBlockBlobFromLocalFile(containerName, blobName, fileName, (error, result) => {
if (error) {
defer.reject(error);
}
//generating SAS URL
let startDate = new Date();
let expiryDate = new Date(startDate);
expiryDate.setFullYear(startDate.getUTCFullYear() + 1);
startDate.setMinutes(startDate.getMinutes()-5);
let sharedAccessPolicy = {
AccessPolicy: {
Permissions: azureStorage.BlobUtilities.SharedAccessPermissions.READ,
Start: startDate,
Expiry: expiryDate
}
};
let token = blobService.generateSharedAccessSignature(containerName, blobName, sharedAccessPolicy);
let sasUrl = blobService.getUrl(containerName, blobName, token);
let index = sasUrl.indexOf("?");
let sasToken: string = sasUrl.substring(index + 1);
tl.setVariable('SAS_TOKEN', sasToken, true);
tl.debug(`SAS URL is: ${sasUrl}`);
defer.resolve(sasUrl);
});
});
return defer.promise;
}