本文整理汇总了TypeScript中webdeployment-common/deployusingmsdeploy.js.default.DeployUsingMSDeploy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.DeployUsingMSDeploy方法的具体用法?TypeScript js.default.DeployUsingMSDeploy怎么用?TypeScript js.default.DeployUsingMSDeploy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webdeployment-common/deployusingmsdeploy.js.default
的用法示例。
在下文中一共展示了js.default.DeployUsingMSDeploy方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
async function run()
{
try
{
tl.setResourcePath(path.join( __dirname, 'task.json'));
var webSiteName: string = tl.getInput('WebSiteName', true);
var virtualApplication: string = tl.getInput('VirtualApplication', false);
var webDeployPkg: string = tl.getPathInput('Package', true);
var setParametersFile: string = tl.getPathInput('SetParametersFile', false);
var removeAdditionalFilesFlag: boolean = tl.getBoolInput('RemoveAdditionalFilesFlag', false);
var excludeFilesFromAppDataFlag: boolean = tl.getBoolInput('ExcludeFilesFromAppDataFlag', false);
var takeAppOfflineFlag: boolean = tl.getBoolInput('TakeAppOfflineFlag', false);
var additionalArguments: string = tl.getInput('AdditionalArguments', false);
var xmlTransformation: boolean = tl.getBoolInput('XmlTransformation', false);
var JSONFiles = tl.getDelimitedInput('JSONFiles', '\n', false);
var xmlVariableSubstitution: boolean = tl.getBoolInput('XmlVariableSubstitution', false);
var availableWebPackages = utility.findfiles(webDeployPkg);
var tempPackagePath = null;
if(availableWebPackages.length == 0)
{
throw new Error(tl.loc('Nopackagefoundwithspecifiedpattern'));
}
if(availableWebPackages.length > 1)
{
throw new Error(tl.loc('MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpattern'));
}
webDeployPkg = availableWebPackages[0];
var isFolderBasedDeployment = await utility.isInputPkgIsFolder(webDeployPkg);
if ( JSONFiles.length != 0 || xmlTransformation || xmlVariableSubstitution ) {
var folderPath = await utility.generateTemporaryFolderForDeployment(isFolderBasedDeployment, webDeployPkg);
var isMSBuildPackage = !isFolderBasedDeployment && await utility.isMSDeployPackage(webDeployPkg);
fileTransformationsUtility.fileTransformations(isFolderBasedDeployment, JSONFiles, xmlTransformation, xmlVariableSubstitution, folderPath, isMSBuildPackage);
var output = await utility.archiveFolderForDeployment(isFolderBasedDeployment, folderPath);
tempPackagePath = output.tempPackagePath;
webDeployPkg = output.webDeployPkg;
}
await msDeploy.DeployUsingMSDeploy(webDeployPkg, webSiteName, null, removeAdditionalFilesFlag,
excludeFilesFromAppDataFlag, takeAppOfflineFlag, virtualApplication, setParametersFile,
additionalArguments, isFolderBasedDeployment, true);
}
catch(error)
{
tl.setResult(tl.TaskResult.Failed,error);
}
}
示例2: DeployWar
export async function DeployWar(webPackage, taskParams: TaskParameters, msDeployPublishingProfile, kuduService: Kudu, appServiceUtility: AzureAppServiceUtility): Promise<void> {
// get list of files before deploying to the web app.
await appServiceUtility.pingApplication();
var listOfFilesBeforeDeployment: any = await kuduService.listDir('/site/wwwroot/webapps/');
tl.debug("Listing file structure of webapps folder before deployment starts => " + JSON.stringify(listOfFilesBeforeDeployment));
// Strip package path and only keep the package name.
var warFileName = path.basename(webPackage).split('.war')[0];
// Find if directory with same name as war file, existed before deployment
var directoryWithSameNameBeforeDeployment;
if (listOfFilesBeforeDeployment) {
listOfFilesBeforeDeployment.some(item => {
if (item.name == warFileName && item.mime == "inode/directory") {
directoryWithSameNameBeforeDeployment = item;
return true;
}
return false;
});
}
var retryCount = 3;
while (retryCount > 0) {
await msDeploy.DeployUsingMSDeploy(webPackage, taskParams.WebAppName, msDeployPublishingProfile, taskParams.RemoveAdditionalFilesFlag,
taskParams.ExcludeFilesFromAppDataFlag, taskParams.TakeAppOfflineFlag, taskParams.VirtualApplication, taskParams.SetParametersFile,
taskParams.AdditionalArguments, false, taskParams.UseWebDeploy);
// verify if the war file has expanded
// if not expanded, deploy using msdeploy once more, to make it work.
var hasWarExpandedSuccessfully: boolean = await HasWarExpandedSuccessfully(kuduService, directoryWithSameNameBeforeDeployment, warFileName, appServiceUtility);
if (!hasWarExpandedSuccessfully) {
console.log(tl.loc("WarDeploymentRetry"));
// If the war file is exactly same, MSDeploy doesn't update the war file in webapp.
// So by changing ModifiedTime, we ensure it will be updated.
var currentTime = new Date(Date.now());
var modifiedTime = new Date(Date.now());
fs.utimesSync(webPackage, currentTime, modifiedTime);
}
else {
break;
}
retryCount--;
}
}
示例3: DeployWebAppStep
public async DeployWebAppStep() {
var webPackage = packageUtility.PackageUtility.getPackagePath(this.taskParams.Package);
var isFolderBasedDeployment = deployUtility.isInputPkgIsFolder(webPackage);
var physicalPath: string = Constant.SiteRoot;
if(this.taskParams.VirtualApplication) {
physicalPath = await this.appServiceUtility.getPhysicalPath(this.taskParams.VirtualApplication);
await this.kuduServiceUtility.createPathIfRequired(physicalPath);
this.virtualApplicationPath = physicalPath;
}
webPackage = await FileTransformsUtility.applyTransformations(webPackage, this.taskParams);
if(deployUtility.canUseWebDeploy(this.taskParams.UseWebDeploy)) {
tl.debug("Performing the deployment of webapp.");
if(!tl.osType().match(/^Win/)){
throw Error(tl.loc("PublishusingwebdeployoptionsaresupportedonlywhenusingWindowsagent"));
}
if(this.taskParams.RenameFilesFlag) {
await this.appServiceUtility.enableRenameLockedFiles();
}
var msDeployPublishingProfile = await this.appServiceUtility.getWebDeployPublishingProfile();
if (webPackage.toString().toLowerCase().endsWith('.war')) {
await DeployWar(webPackage, this.taskParams, msDeployPublishingProfile, this.kuduService, this.appServiceUtility);
}
else {
await msDeploy.DeployUsingMSDeploy(webPackage, this.taskParams.WebAppName, msDeployPublishingProfile,
this.taskParams.RemoveAdditionalFilesFlag, this.taskParams.ExcludeFilesFromAppDataFlag, this.taskParams.TakeAppOfflineFlag,
this.taskParams.VirtualApplication, this.taskParams.SetParametersFile, this.taskParams.AdditionalArguments,
isFolderBasedDeployment, this.taskParams.UseWebDeploy);
}
}
else {
tl.debug("Initiated deployment via kudu service for webapp package : ");
await this.kuduServiceUtility.deployWebPackage(webPackage, physicalPath, this.taskParams.VirtualApplication, this.taskParams.TakeAppOfflineFlag);
}
await this.PostDeploymentStep();
}
示例4: run
async function run()
{
try
{
tl.setResourcePath(path.join( __dirname, 'task.json'));
var webSiteName: string = tl.getInput('WebSiteName', true);
var virtualApplication: string = tl.getInput('VirtualApplication', false);
var webDeployPkg: string = tl.getPathInput('Package', true);
var setParametersFile: string = tl.getPathInput('SetParametersFile', false);
var removeAdditionalFilesFlag: boolean = tl.getBoolInput('RemoveAdditionalFilesFlag', false);
var excludeFilesFromAppDataFlag: boolean = tl.getBoolInput('ExcludeFilesFromAppDataFlag', false);
var takeAppOfflineFlag: boolean = tl.getBoolInput('TakeAppOfflineFlag', false);
var additionalArguments: string = tl.getInput('AdditionalArguments', false);
var availableWebPackages = tl.glob(webDeployPkg);
if(availableWebPackages.length == 0)
{
throw new Error(tl.loc('Nopackagefoundwithspecifiedpattern'));
}
if(availableWebPackages.length > 1)
{
throw new Error(tl.loc('MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpatern'));
}
webDeployPkg = availableWebPackages[0];
var isFolderBasedDeployment = await utility.isInputPkgIsFolder(webDeployPkg);
await msDeploy.DeployUsingMSDeploy(webDeployPkg, webSiteName, null, removeAdditionalFilesFlag,
excludeFilesFromAppDataFlag, takeAppOfflineFlag, virtualApplication, setParametersFile,
additionalArguments, isFolderBasedDeployment, true);
}
catch(error)
{
tl.setResult(tl.TaskResult.Failed,error);
}
}
示例5: main
async function main() {
let zipDeploymentID: string;
let isDeploymentSuccess: boolean = true;
let kuduServiceUtility: KuduServiceUtility;
try {
tl.setResourcePath(path.join( __dirname, 'task.json'));
var taskParams: TaskParameters = TaskParametersUtility.getParameters();
var azureEndpoint: AzureEndpoint = await new AzureRMEndpoint(taskParams.connectedServiceName).getEndpoint();
var virtualApplicationPath: string;
console.log(tl.loc('GotconnectiondetailsforazureRMWebApp0', taskParams.WebAppName));
if(!taskParams.DeployToSlotFlag) {
taskParams.ResourceGroupName = await AzureResourceFilterUtility.getResourceGroupName(azureEndpoint, taskParams.WebAppName);
}
tl.debug(`Resource Group: ${taskParams.ResourceGroupName}`);
var appService: AzureAppService = new AzureAppService(azureEndpoint, taskParams.ResourceGroupName, taskParams.WebAppName, taskParams.SlotName, taskParams.WebAppKind);
let appServiceUtility: AzureAppServiceUtility = new AzureAppServiceUtility(appService);
await appServiceUtility.pingApplication();
let kuduService: Kudu = await appServiceUtility.getKuduService();
kuduServiceUtility = new KuduServiceUtility(kuduService);
if(taskParams.WebAppUri) {
tl.setVariable(taskParams.WebAppUri, await appServiceUtility.getApplicationURL(!taskParams.isLinuxApp ? taskParams.VirtualApplication : null));
}
if(taskParams.isLinuxApp) {
switch(taskParams.ImageSource) {
case 'Builtin': {
var webPackage = packageUtility.PackageUtility.getPackagePath(taskParams.Package);
tl.debug('Performing Linux built-in package deployment');
zipDeploymentID = await kuduServiceUtility.zipDeploy(webPackage, taskParams.TakeAppOfflineFlag, { slotName: appService.getSlot() });
await appServiceUtility.updateStartupCommandAndRuntimeStack(taskParams.RuntimeStack, taskParams.StartupCommand);
break;
}
case 'Registry': {
tl.debug("Performing container based deployment.");
let containerDeploymentUtility: ContainerBasedDeploymentUtility = new ContainerBasedDeploymentUtility(appService);
await containerDeploymentUtility.deployWebAppImage(taskParams);
break;
}
default: {
throw new Error('Invalid Image source Type');
}
}
}
else {
var webPackage = packageUtility.PackageUtility.getPackagePath(taskParams.Package);
var isFolderBasedDeployment = deployUtility.isInputPkgIsFolder(webPackage);
var physicalPath: string = '/site/wwwroot';
if(taskParams.VirtualApplication) {
physicalPath = await appServiceUtility.getPhysicalPath(taskParams.VirtualApplication);
await kuduServiceUtility.createPathIfRequired(physicalPath);
virtualApplicationPath = physicalPath;
}
webPackage = await FileTransformsUtility.applyTransformations(webPackage, taskParams);
if(deployUtility.canUseWebDeploy(taskParams.UseWebDeploy)) {
tl.debug("Performing the deployment of webapp.");
if(!tl.osType().match(/^Win/)){
throw Error(tl.loc("PublishusingwebdeployoptionsaresupportedonlywhenusingWindowsagent"));
}
if(taskParams.RenameFilesFlag) {
await appServiceUtility.enableRenameLockedFiles();
}
var msDeployPublishingProfile = await appServiceUtility.getWebDeployPublishingProfile();
if (webPackage.toString().toLowerCase().endsWith('.war')) {
await DeployWar(webPackage, taskParams, msDeployPublishingProfile, kuduService, appServiceUtility);
}
else {
await msDeploy.DeployUsingMSDeploy(webPackage, taskParams.WebAppName, msDeployPublishingProfile, taskParams.RemoveAdditionalFilesFlag,
taskParams.ExcludeFilesFromAppDataFlag, taskParams.TakeAppOfflineFlag, taskParams.VirtualApplication, taskParams.SetParametersFile,
taskParams.AdditionalArguments, isFolderBasedDeployment, taskParams.UseWebDeploy);
}
}
else {
tl.debug("Initiated deployment via kudu service for webapp package : ");
await kuduServiceUtility.deployWebPackage(webPackage, physicalPath, taskParams.VirtualApplication, taskParams.TakeAppOfflineFlag);
}
}
if(!taskParams.isContainerWebApp) {
if(taskParams.AppSettings) {
var customApplicationSettings = ParameterParser.parse(taskParams.AppSettings);
await appServiceUtility.updateAndMonitorAppSettings(customApplicationSettings);
}
if(taskParams.ConfigurationSettings) {
var customApplicationSettings = ParameterParser.parse(taskParams.ConfigurationSettings);
await appServiceUtility.updateConfigurationSettings(customApplicationSettings);
}
}
else {
tl.debug('App Settings and config settings are already updated during container based deployment.')
}
if(taskParams.ScriptType) {
//.........这里部分代码省略.........
示例6: run
//.........这里部分代码省略.........
else {
throw Error(tl.loc("VirtualApplicationDoesNotExist", virtualApplication));
}
}
var isFolderBasedDeployment = deployUtility.isInputPkgIsFolder(webDeployPkg);
var applyFileTransformFlag = JSONFiles.length != 0 || xmlTransformation || xmlVariableSubstitution;
if (applyFileTransformFlag || generateWebConfig) {
var folderPath = await deployUtility.generateTemporaryFolderForDeployment(isFolderBasedDeployment, webDeployPkg);
if (generateWebConfig) {
tl.debug('parsing web.config parameters');
var webConfigParameters = ParameterParser.parse(webConfigParametersStr);
generateWebConfigUtil.addWebConfigFile(folderPath, webConfigParameters, virtualApplicationPhysicalPath);
}
if (applyFileTransformFlag) {
var isMSBuildPackage = !isFolderBasedDeployment && (await deployUtility.isMSDeployPackage(webDeployPkg));
fileTransformationsUtility.fileTransformations(isFolderBasedDeployment, JSONFiles, xmlTransformation, xmlVariableSubstitution, folderPath, isMSBuildPackage);
}
var output = await deployUtility.archiveFolderForDeployment(isFolderBasedDeployment, folderPath);
tempPackagePath = output.tempPackagePath;
webDeployPkg = output.webDeployPkg;
}
if(virtualApplication) {
publishingProfile.destinationAppUrl += "/" + virtualApplication;
}
if(webAppUri) {
tl.setVariable(webAppUri, publishingProfile.destinationAppUrl);
}
if(publishingProfile && publishingProfile.destinationAppUrl) {
try{
await azureRESTUtility.testAzureWebAppAvailability(publishingProfile.destinationAppUrl, 3000);
} catch (error) {
tl.debug("Failed to check availability of azure web app, error : " + error.message);
}
}
if(deployUtility.canUseWebDeploy(useWebDeploy)) {
if(!tl.osType().match(/^Win/)){
throw Error(tl.loc("PublishusingwebdeployoptionsaresupportedonlywhenusingWindowsagent"));
}
var appSettings = await azureRESTUtility.getWebAppAppSettings(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
if(renameFilesFlag) {
if(appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES == undefined || appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES == '0'){
appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES = '1';
await azureRESTUtility.updateWebAppAppSettings(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName, appSettings);
}
}
else {
if(appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES != undefined && appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES != '0'){
delete appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES;
await azureRESTUtility.updateWebAppAppSettings(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName, appSettings);
}
}
console.log("##vso[task.setvariable variable=websiteUserName;issecret=true;]" + publishingProfile.userName);
console.log("##vso[task.setvariable variable=websitePassword;issecret=true;]" + publishingProfile.userPWD);
await msDeploy.DeployUsingMSDeploy(webDeployPkg, webAppName, publishingProfile, removeAdditionalFilesFlag,
excludeFilesFromAppDataFlag, takeAppOfflineFlag, virtualApplication, setParametersFile,
additionalArguments, isFolderBasedDeployment, useWebDeploy);
} else {
tl.debug("Initiated deployment via kudu service for webapp package : " + webDeployPkg);
if(azureWebAppDetails == null) {
azureWebAppDetails = await azureRESTUtility.getAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
}
await DeployUsingKuduDeploy(webDeployPkg, azureWebAppDetails, publishingProfile, virtualApplication, isFolderBasedDeployment, takeAppOfflineFlag);
}
if(scriptType) {
var kuduWorkingDirectory = virtualApplication ? virtualApplicationPhysicalPath : 'site/wwwroot';
await kuduUtility.runPostDeploymentScript(publishingProfile, kuduWorkingDirectory, scriptType, inlineScript, scriptPath, takeAppOfflineFlag);
}
}
await updateWebAppConfigDetails(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
}
catch (error) {
isDeploymentSuccess = false;
tl.setResult(tl.TaskResult.Failed, error);
}
if(publishingProfile != null) {
var customMessage = {
type: "Deployment",
slotName: (deployToSlotFlag ? slotName : "Production")
};
try {
console.log(await azureRESTUtility.updateDeploymentStatus(publishingProfile, isDeploymentSuccess, customMessage));
}
catch(error) {
tl.warning(error);
}
}
if(tempPackagePath) {
tl.rmRF(tempPackagePath);
}
}
示例7: run
//.........这里部分代码省略.........
}
else {
resourceGroupName = await azureRESTUtility.getResourceGroupName(endPoint, webAppName);
}
var publishingProfile = await azureRESTUtility.getAzureRMWebAppPublishProfile(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
console.log(tl.loc('GotconnectiondetailsforazureRMWebApp0', webAppName));
var availableWebPackages = utility.findfiles(webDeployPkg);
if(availableWebPackages.length == 0) {
throw new Error(tl.loc('Nopackagefoundwithspecifiedpattern'));
}
if(availableWebPackages.length > 1) {
throw new Error(tl.loc('MorethanonepackagematchedwithspecifiedpatternPleaserestrainthesearchpattern'));
}
webDeployPkg = availableWebPackages[0];
var isFolderBasedDeployment = utility.isInputPkgIsFolder(webDeployPkg);
if(JSONFiles.length != 0 || xmlTransformation || xmlVariableSubstitution) {
var output = await fileTransformationsUtility.fileTransformations(isFolderBasedDeployment, JSONFiles, xmlTransformation, xmlVariableSubstitution, webDeployPkg);
tempPackagePath = output.tempPackagePath;
webDeployPkg = output.webDeployPkg;
}
if(virtualApplication) {
publishingProfile.destinationAppUrl += "/" + virtualApplication;
}
if(webAppUri) {
tl.setVariable(webAppUri, publishingProfile.destinationAppUrl);
}
var azureWebAppDetails = null;
if(virtualApplication) {
azureWebAppDetails = await azureRESTUtility.getAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
var virtualApplicationMappings = azureWebAppDetails.properties.virtualApplications;
var pathMappings = kuduUtility.getVirtualAndPhysicalPaths(virtualApplication, virtualApplicationMappings);
if(pathMappings[1] != null) {
await kuduUtility.ensurePhysicalPathExists(publishingProfile, pathMappings[1]);
} else {
throw Error(tl.loc("VirtualApplicationDoesNotExist", virtualApplication));
}
}
if(utility.canUseWebDeploy(useWebDeploy)) {
if(!tl.osType().match(/^Win/)){
throw Error(tl.loc("PublishusingwebdeployoptionsaresupportedonlywhenusingWindowsagent"));
}
var appSettings = await azureRESTUtility.getWebAppAppSettings(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
if(renameFilesFlag) {
if(appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES == undefined || appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES == '0'){
appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES = '1';
await azureRESTUtility.updateWebAppAppSettings(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName, appSettings);
}
}
else {
if(appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES != undefined && appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES != '0'){
delete appSettings.properties.MSDEPLOY_RENAME_LOCKED_FILES;
await azureRESTUtility.updateWebAppAppSettings(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName, appSettings);
}
}
console.log("##vso[task.setvariable variable=websiteUserName;issecret=true;]" + publishingProfile.userName);
console.log("##vso[task.setvariable variable=websitePassword;issecret=true;]" + publishingProfile.userPWD);
await msDeploy.DeployUsingMSDeploy(webDeployPkg, webAppName, publishingProfile, removeAdditionalFilesFlag,
excludeFilesFromAppDataFlag, takeAppOfflineFlag, virtualApplication, setParametersFile,
additionalArguments, isFolderBasedDeployment, useWebDeploy);
} else {
tl.debug("Initiated deployment via kudu service for webapp package : " + webDeployPkg);
if(azureWebAppDetails == null) {
azureWebAppDetails = await azureRESTUtility.getAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
}
await DeployUsingKuduDeploy(webDeployPkg, azureWebAppDetails, publishingProfile, virtualApplication, isFolderBasedDeployment, takeAppOfflineFlag);
}
await updateScmType(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
} catch (error) {
isDeploymentSuccess = false;
tl.setResult(tl.TaskResult.Failed, error);
}
if(publishingProfile != null) {
var customMessage = {
type: "Deployment",
slotName: (deployToSlotFlag ? slotName : "Production")
};
try {
console.log(await azureRESTUtility.updateDeploymentStatus(publishingProfile, isDeploymentSuccess, customMessage));
}
catch(error) {
tl.warning(error);
}
}
if(tempPackagePath) {
tl.rmRF(tempPackagePath);
}
}