本文整理汇总了TypeScript中azurerest-common/azurerestutility.js.default类的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default类的具体用法?TypeScript js.default怎么用?TypeScript js.default使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了js.default类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: run
async function run() {
try {
tl.setResourcePath(path.join( __dirname, 'task.json'));
var connectedServiceName = tl.getInput('ConnectedServiceName', true);
var action = tl.getInput('Action', true);
var webAppName: string = tl.getInput('WebAppName', true);
var resourceGroupName: string = tl.getInput('ResourceGroupName', false);
var specifySlotFlag: boolean = tl.getBoolInput('SpecifySlot', false);
var slotName: string = tl.getInput('Slot', false);
var sourceSlot: string = tl.getInput('SourceSlot', false);
var swapWithProduction = tl.getBoolInput('SwapWithProduction', false);
var targetSlot: string = tl.getInput('TargetSlot', false);
var preserveVnet: boolean = tl.getBoolInput('PreserveVnet', false);
var extensionList = tl.getInput('ExtensionsList', false);
var extensionOutputVariables = tl.getInput('OutputVariable');
var subscriptionId = tl.getEndpointDataParameter(connectedServiceName, 'subscriptionid', true);
var taskResult = true;
var errorMessage: string = "";
var updateDeploymentStatus: boolean = true;
var endPoint = new Array();
endPoint["servicePrincipalClientID"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'serviceprincipalid', false);
endPoint["servicePrincipalKey"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'serviceprincipalkey', false);
endPoint["tenantID"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'tenantid', false);
endPoint["subscriptionId"] = tl.getEndpointDataParameter(connectedServiceName, 'subscriptionid', true);
endPoint["envAuthUrl"] = tl.getEndpointDataParameter(connectedServiceName, 'environmentAuthorityUrl', true);
endPoint["url"] = tl.getEndpointUrl(connectedServiceName, true);
if(resourceGroupName === null) {
resourceGroupName = await azureRmUtil.getResourceGroupName(endPoint, webAppName);
}
switch(action) {
case "Start Azure App Service": {
console.log(await azureRmUtil.startAppService(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName));
await waitForAppServiceToStart(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName);
break;
}
case "Stop Azure App Service": {
console.log(await azureRmUtil.stopAppService(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName));
break;
}
case "Install Extensions": {
resourceGroupName = (specifySlotFlag ? resourceGroupName : await azureRmUtil.getResourceGroupName(endPoint, webAppName));
var publishingProfile = await azureRmUtil.getAzureRMWebAppPublishProfile(endPoint, webAppName, resourceGroupName, specifySlotFlag, slotName);
tl.debug('Retrieved publishing Profile');
var extensionOutputVariablesArray = (extensionOutputVariables) ? extensionOutputVariables.split(',') : [];
var anyExtensionInstalled = await extensionManage.installExtensions(publishingProfile, extensionList.split(','), extensionOutputVariablesArray);
if(!anyExtensionInstalled) {
tl.debug('No new extension installed. Skipping Restart App Service.');
break;
}
}
case "Restart Azure App Service": {
console.log(await azureRmUtil.restartAppService(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName));
await waitForAppServiceToStart(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName);
break;
}
case "Swap Slots": {
if (swapWithProduction) {
targetSlot = "production";
}
if (sourceSlot === targetSlot) {
updateDeploymentStatus = false;
throw new Error(tl.loc("SourceAndTargetSlotCannotBeSame"));
}
await swapSlot(endPoint, resourceGroupName, webAppName, sourceSlot, swapWithProduction, targetSlot, preserveVnet);
break;
}
default:
throw Error(tl.loc('InvalidAction'));
}
}
catch(exception) {
taskResult = false;
errorMessage = exception;
}
if (updateDeploymentStatus) {
var customMessage = {
type: action
}
var deploymentId = kuduLogUtil.generateDeploymentId();
if(action === "Swap Slots") {
customMessage['type'] = 'SlotSwap'; // for Ibiza CD flow
customMessage['sourceSlot'] = sourceSlot;
customMessage['targetSlot'] = swapWithProduction ? "Production" : targetSlot;
await updateKuduDeploymentLog(endPoint, webAppName, resourceGroupName, true, sourceSlot, taskResult, customMessage, deploymentId);
await updateKuduDeploymentLog(endPoint, webAppName, resourceGroupName, !(swapWithProduction), targetSlot, taskResult, customMessage, deploymentId);
}
else {
customMessage['slotName'] = (specifySlotFlag) ? slotName : 'Production';
await updateKuduDeploymentLog(endPoint, webAppName, resourceGroupName, specifySlotFlag, slotName, taskResult, customMessage, deploymentId);
}
}
if (!taskResult) {
tl.setResult(tl.TaskResult.Failed, errorMessage);
}
}
示例2: updateArmMetadata
async function updateArmMetadata(SPN, webAppName: string, resourceGroupName: string, deployToSlotFlag: boolean, slotName: string) {
var collectionUri = tl.getVariable("system.teamfoundationCollectionUri");
var projectId = tl.getVariable("system.teamprojectId");
var buildDefintionId = tl.getVariable("build.definitionId")
var releaseDefinitionId = tl.getVariable("release.definitionId");
let newPoperties = {
VSTSRM_BuildDefinitionId: buildDefintionId,
VSTSRM_ReleaseDefinitionId: releaseDefinitionId,
VSTSRM_ProjectId: projectId,
VSTSRM_AccountId: tl.getVariable("system.collectionId"),
VSTSRM_BuildDefinitionWebAccessUrl: collectionUri + projectId + "/_build?_a=simple-process&definitionId=" + buildDefintionId,
VSTSRM_ConfiguredCDEndPoint: collectionUri + projectId + "/_apps/hub/ms.vss-releaseManagement-web.hub-explorer?definitionId=" + releaseDefinitionId
}
var metadata = await azureRESTUtility.getAzureRMWebAppMetadata(SPN, webAppName, resourceGroupName, deployToSlotFlag, slotName);
var properties = metadata.properties;
Object.keys(newPoperties).forEach((key) => {
properties[key] = newPoperties[key];
});
metadata.properties = properties;
await azureRESTUtility.updateAzureRMWebAppMetadata(SPN, webAppName, resourceGroupName, deployToSlotFlag, slotName, metadata);
}
示例3: updateKuduDeploymentLog
async function updateKuduDeploymentLog(endPoint, webAppName, resourceGroupName, slotFlag, slotName, taskResult, customMessage, deploymentId) {
try {
var publishingProfile = await azureRmUtil.getAzureRMWebAppPublishProfile(endPoint, webAppName, resourceGroupName, slotFlag, slotName);
console.log(await azureRmUtil.updateDeploymentStatus(publishingProfile, taskResult, customMessage, deploymentId));
}
catch(exception) {
tl.warning(exception);
}
}
示例4: deployWebAppImage
export async function deployWebAppImage(endPoint, resourceGroupName, webAppName) {
var startupCommand = tl.getInput('StartupCommand', false);
var appSettings = tl.getInput('AppSettings', false);
var imageSourceAndTag;
// Construct the image
var dockerNamespace = tl.getInput('DockerNamespace', true);
var dockerRepository = tl.getInput('DockerRepository', true);
var dockerImageTag = tl.getInput('DockerImageTag', false);
/*
Special Case : If release definition is not linked to build artifacts
then $(Build.BuildId) variable don't expand in release. So clearing state
of dockerImageTag if $(Build.BuildId) not expanded in value of dockerImageTag.
*/
if(dockerImageTag && (dockerImageTag.trim() == "$(Build.BuildId)")) {
dockerImageTag = null;
}
if(dockerImageTag) {
imageSourceAndTag = dockerNamespace + "/" + dockerRepository + ":" + dockerImageTag;
} else {
imageSourceAndTag = dockerNamespace + "/" + dockerRepository;
}
if(imageSourceAndTag)
{
tl.debug("Deploying the image " + imageSourceAndTag + " to the webapp " + webAppName);
appSettings = appSettings ? appSettings.trim() : "";
appSettings = "-DOCKER_CUSTOM_IMAGE_NAME " + imageSourceAndTag + " " + appSettings;
// Update webapp application setting
var webAppSettings = await azureRESTUtility.getWebAppAppSettings(endPoint, webAppName, resourceGroupName, false, null);
mergeAppSettings(appSettings, webAppSettings);
await azureRESTUtility.updateWebAppAppSettings(endPoint, webAppName, resourceGroupName, false, null, webAppSettings);
// Update startup command
if(startupCommand)
{
tl.debug("Updating the startup command: " + startupCommand);
var updatedConfigDetails = JSON.stringify(
{
"properties": {
"appCommandLine": startupCommand
}
});
await azureRESTUtility.updateAzureRMWebAppConfigDetails(endPoint, webAppName, resourceGroupName, false, null, updatedConfigDetails);
}
}
}
示例5: updateScmType
async function updateScmType(SPN, webAppName: string, resourceGroupName: string, deployToSlotFlag: boolean, slotName: string) {
try {
var configDetails = await azureRESTUtility.getAzureRMWebAppConfigDetails(SPN, webAppName, resourceGroupName, deployToSlotFlag, slotName);
var scmType: string = configDetails.properties.scmType;
if(scmType.toLowerCase() === "none") {
var updatedConfigDetails = JSON.stringify(
{
"properties": {
"scmType": "VSTSRM"
}
});
await azureRESTUtility.updateAzureRMWebAppConfigDetails(SPN, webAppName, resourceGroupName, deployToSlotFlag, slotName, updatedConfigDetails);
console.log(tl.loc("SuccessfullyUpdatedAzureRMWebAppConfigDetails"));
}
}
catch(error) {
tl.warning(tl.loc("FailedToUpdateAzureRMWebAppConfigDetails", error));
}
}
示例6: swapSlot
async function swapSlot(endPoint, resourceGroupName: string, webAppName: string, sourceSlot: string, swapWithProduction: boolean, targetSlot: string, preserveVnet: boolean) {
try {
await azureRmUtil.swapWebAppSlot(endPoint, resourceGroupName, webAppName, sourceSlot, targetSlot, preserveVnet);
console.log(tl.loc("Successfullyswappedslots", webAppName, sourceSlot, targetSlot));
}
catch(error) {
if(!!error)
throw new Error(tl.loc("FailedToSwapWebAppSlots", webAppName, error));
else
throw new Error(tl.loc("SlotSwapOperationNotCompleted", webAppName));
}
}
示例7: waitForAppServiceToStart
async function waitForAppServiceToStart(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName) {
while(true) {
var appServiceDetails = await azureRmUtil.getAppServiceDetails(endPoint, resourceGroupName, webAppName, specifySlotFlag, slotName);
if(appServiceDetails.hasOwnProperty("properties") && appServiceDetails.properties.hasOwnProperty("state")) {
tl.debug('App Service State : ' + appServiceDetails.properties.state);
if(appServiceDetails.properties.state == "Running" || appServiceDetails.properties.state == "running") {
tl.debug('App Service is in Running State');
break;
}
else {
tl.debug('App Service State : ' + appServiceDetails.properties.state);
continue;
}
}
tl.debug('Unable to find state of the App Service.');
break;
}
}
示例8: run
async function run() {
try {
tl.setResourcePath(path.join( __dirname, 'task.json'));
var connectedServiceName = tl.getInput('ConnectedServiceName', true);
var webAppName: string = tl.getInput('WebAppName', true);
var deployToSlotFlag: boolean = tl.getBoolInput('DeployToSlotFlag', false);
var resourceGroupName: string = tl.getInput('ResourceGroupName', false);
var slotName: string = tl.getInput('SlotName', false);
var webDeployPkg: string = tl.getPathInput('Package', true);
var virtualApplication: string = tl.getInput('VirtualApplication', false);
var useWebDeploy: boolean = tl.getBoolInput('UseWebDeploy', false);
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 renameFilesFlag: boolean = tl.getBoolInput('RenameFilesFlag', false);
var additionalArguments: string = tl.getInput('AdditionalArguments', false);
var webAppUri:string = tl.getInput('WebAppUri', false);
var xmlTransformation: boolean = tl.getBoolInput('XmlTransformation', false);
var JSONFiles = tl.getDelimitedInput('JSONFiles', '\n', false);
var xmlVariableSubstitution: boolean = tl.getBoolInput('XmlVariableSubstitution', false);
var scriptType: string = tl.getInput('ScriptType', false);
var inlineScript: string = tl.getInput('InlineScript', false);
var scriptPath: string = tl.getPathInput('ScriptPath', false);
var generateWebConfig = tl.getBoolInput('GenerateWebConfig', false);
var webConfigParametersStr = tl.getInput('WebConfigParameters', false);
var webAppKind = tl.getInput('WebAppKind', false);
var dockerNamespace = tl.getInput('DockerNamespace', false);
var isDeploymentSuccess: boolean = true;
var tempPackagePath = null;
var endPoint = new Array();
endPoint["servicePrincipalClientID"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'serviceprincipalid', false);
endPoint["servicePrincipalKey"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'serviceprincipalkey', false);
endPoint["tenantID"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'tenantid', false);
endPoint["subscriptionId"] = tl.getEndpointDataParameter(connectedServiceName, 'subscriptionid', true);
endPoint["envAuthUrl"] = tl.getEndpointDataParameter(connectedServiceName, 'environmentAuthorityUrl', true);
endPoint["url"] = tl.getEndpointUrl(connectedServiceName, true);
if(webAppKind && webAppKind === "linux") {
deployToSlotFlag = false;
}
if(deployToSlotFlag) {
if (slotName.toLowerCase() === "production") {
deployToSlotFlag = false;
}
}
else {
resourceGroupName = await azureRESTUtility.getResourceGroupName(endPoint, webAppName);
}
var publishingProfile = await azureRESTUtility.getAzureRMWebAppPublishProfile(endPoint, webAppName, resourceGroupName, deployToSlotFlag, slotName);
console.log(tl.loc('GotconnectiondetailsforazureRMWebApp0', webAppName));
// For container based linux deployment
if(webAppKind && webAppKind === "linux" && dockerNamespace)
{
tl.debug("Performing container based deployment.");
await deployWebAppImage(endPoint, resourceGroupName, webAppName);
}
else
{
tl.debug("Performing the deployment of webapp.");
var availableWebPackages = deployUtility.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 azureWebAppDetails = null;
var virtualApplicationPhysicalPath = null;
if(virtualApplication) {
virtualApplication = (virtualApplication.startsWith("/")) ? virtualApplication.substr(1) : 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) {
virtualApplicationPhysicalPath = pathMappings[1];
await kuduUtility.ensurePhysicalPathExists(publishingProfile, pathMappings[1]);
}
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');
//.........这里部分代码省略.........
示例9: require
var nock = require('nock');
var azureRestUtiltiy = require('azurerest-common/azurerestutility.js');
nock('http://testwebapp.azurewebsites.net')
.get("/")
.reply(299, {"statusCode":"299", "statusMessage": "Fail"});
azureRestUtiltiy.testAzureWebAppAvailability('http://testwebapp.azurewebsites.net',100);
示例10: run
async function run() {
try {
tl.setResourcePath(path.join( __dirname, 'task.json'));
var connectedServiceName = tl.getInput('ConnectedServiceName', true);
var webAppName: string = tl.getInput('WebAppName', true);
var deployToSlotFlag: boolean = tl.getBoolInput('DeployToSlotFlag', false);
var resourceGroupName: string = tl.getInput('ResourceGroupName', false);
var slotName: string = tl.getInput('SlotName', false);
var webDeployPkg: string = tl.getPathInput('Package', true);
var virtualApplication: string = tl.getInput('VirtualApplication', false);
var useWebDeploy: boolean = tl.getBoolInput('UseWebDeploy', false);
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 renameFilesFlag: boolean = tl.getBoolInput('RenameFilesFlag', false);
var additionalArguments: string = tl.getInput('AdditionalArguments', false);
var webAppUri:string = tl.getInput('WebAppUri', false);
var xmlTransformation: boolean = tl.getBoolInput('XmlTransformation', false);
var JSONFiles = tl.getDelimitedInput('JSONFiles', '\n', false);
var xmlVariableSubstitution: boolean = tl.getBoolInput('XmlVariableSubstitution', false);
var endPointAuthCreds = tl.getEndpointAuthorization(connectedServiceName, true);
var isDeploymentSuccess: boolean = true;
var tempPackagePath = null;
var endPoint = new Array();
endPoint["servicePrincipalClientID"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'serviceprincipalid', true);
endPoint["servicePrincipalKey"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'serviceprincipalkey', true);
endPoint["tenantID"] = tl.getEndpointAuthorizationParameter(connectedServiceName, 'tenantid', true);
endPoint["subscriptionId"] = tl.getEndpointDataParameter(connectedServiceName, 'subscriptionid', true);
endPoint["url"] = tl.getEndpointUrl(connectedServiceName, true);
if(deployToSlotFlag) {
if(slotName.toLowerCase() === "production") {
deployToSlotFlag = false;
}
}
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);
//.........这里部分代码省略.........