本文整理汇总了TypeScript中azure-arm-rest/azure-arm-app-service.AzureAppService类的典型用法代码示例。如果您正苦于以下问题:TypeScript AzureAppService类的具体用法?TypeScript AzureAppService怎么用?TypeScript AzureAppService使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AzureAppService类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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) {
//.........这里部分代码省略.........
示例2: 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 = specifySlotFlag ? tl.getInput('Slot', false) : null;
var appInsightsResourceGroupName: string = tl.getInput('AppInsightsResourceGroupName', false);
var appInsightsResourceName: string = tl.getInput('ApplicationInsightsResourceName', 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 appInsightsWebTestName = tl.getInput('ApplicationInsightsWebTestName', false);
var taskResult = true;
var errorMessage: string = "";
var updateDeploymentStatus: boolean = true;
var azureEndpoint: AzureEndpoint = await new AzureRMEndpoint(connectedServiceName).getEndpoint();
var endpointTelemetry = '{"endpointId":"' + connectedServiceName + '"}';
console.log("##vso[telemetry.publish area=TaskEndpointId;feature=AzureAppServiceManage]" + endpointTelemetry);
if(action != "Swap Slots" && !slotName) {
resourceGroupName = await AzureResourceFilterUtils.getResourceGroupName(azureEndpoint, 'Microsoft.Web/Sites', webAppName);
}
tl.debug(`Resource Group: ${resourceGroupName}`);
var appService: AzureAppService = new AzureAppService(azureEndpoint, resourceGroupName, webAppName, slotName);
var azureAppServiceUtils: AzureAppServiceUtils = new AzureAppServiceUtils(appService);
switch(action) {
case "Start Azure App Service": {
await appService.start();
await azureAppServiceUtils.monitorApplicationState("running");
await azureAppServiceUtils.pingApplication();
break;
}
case "Stop Azure App Service": {
await appService.stop();
await azureAppServiceUtils.monitorApplicationState("stopped");
break;
}
case "Restart Azure App Service": {
await appService.restart();
await azureAppServiceUtils.pingApplication();
break;
}
case "Swap Slots": {
targetSlot = (swapWithProduction) ? "production" : targetSlot;
var appServiceSourceSlot: AzureAppService = new AzureAppService(azureEndpoint, resourceGroupName, webAppName, sourceSlot);
var appServiceTargetSlot: AzureAppService = new AzureAppService(azureEndpoint, resourceGroupName, webAppName, targetSlot);
var appServiceSourceSlotUtils: AzureAppServiceUtils = new AzureAppServiceUtils(appServiceSourceSlot);
var appServiceTargetSlotUtils: AzureAppServiceUtils = new AzureAppServiceUtils(appServiceTargetSlot);
if(appServiceSourceSlot.getSlot().toLowerCase() == appServiceTargetSlot.getSlot().toLowerCase()) {
updateDeploymentStatus = false;
throw new Error(tl.loc('SourceAndTargetSlotCannotBeSame'));
}
console.log(tl.loc('WarmingUpSlots'));
try {
await Promise.all([appServiceSourceSlotUtils.pingApplication(), appServiceTargetSlotUtils.pingApplication()]);
}
catch(error) {
tl.debug('Failed to warm-up slots. Error: ' + error);
}
await appServiceSourceSlot.swap(targetSlot, preserveVnet);
break;
}
case "Start all continuous webjobs": {
var appServiceKuduService: Kudu = await azureAppServiceUtils.getKuduService();
var kuduServiceUtils: KuduServiceUtils = new KuduServiceUtils(appServiceKuduService);
await kuduServiceUtils.startContinuousWebJobs();
break;
}
case "Stop all continuous webjobs": {
var appServiceKuduService = await azureAppServiceUtils.getKuduService();
var kuduServiceUtils: KuduServiceUtils = new KuduServiceUtils(appServiceKuduService);
await kuduServiceUtils.stopContinuousWebJobs();
break;
}
case "Install Extensions": {
var appServiceKuduService = await azureAppServiceUtils.getKuduService();
var kuduServiceUtils: KuduServiceUtils = new KuduServiceUtils(appServiceKuduService);
var extensionOutputVariablesArray = (extensionOutputVariables) ? extensionOutputVariables.split(',') : [];
await kuduServiceUtils.installSiteExtensions(extensionList.split(','), extensionOutputVariablesArray);
break;
}
case "Enable Continuous Monitoring": {
var appInsights: AzureApplicationInsights = new AzureApplicationInsights(azureEndpoint, appInsightsResourceGroupName, appInsightsResourceName);
await enableContinuousMonitoring(azureEndpoint, appService, appInsights, appInsightsWebTestName);
break;
}
default: {
throw Error(tl.loc('InvalidAction'));
//.........这里部分代码省略.........
示例3: monitorApplicationState
public async monitorApplicationState(state: string): Promise<void> {
state = state.toLowerCase();
if(["running", "stopped"].indexOf(state) == -1) {
throw new Error(tl.loc('InvalidMonitorAppState', state));
}
while(true) {
var appDetails = await this._appService.get(true);
if(appDetails && appDetails.properties && appDetails.properties["state"]) {
tl.debug(`App Service state: ${appDetails.properties["state"]}`)
if(appDetails.properties["state"].toLowerCase() == state) {
tl.debug(`App Service state '${appDetails.properties["state"]}' matched with expected state '${state}'.`);
console.log(tl.loc('AppServiceState', appDetails.properties["state"]));
break;
}
await webClient.sleepFor(5);
}
else {
tl.debug('Unable to monitor app service details as the state is unknown.');
break;
}
}
}