当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript AzureAppService.restart方法代码示例

本文整理汇总了TypeScript中azure-arm-rest/azure-arm-app-service.AzureAppService.restart方法的典型用法代码示例。如果您正苦于以下问题:TypeScript AzureAppService.restart方法的具体用法?TypeScript AzureAppService.restart怎么用?TypeScript AzureAppService.restart使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在azure-arm-rest/azure-arm-app-service.AzureAppService的用法示例。


在下文中一共展示了AzureAppService.restart方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = 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'));
//.........这里部分代码省略.........
开发者ID:Microsoft,项目名称:vsts-tasks,代码行数:101,代码来源:azureappservicemanage.ts


注:本文中的azure-arm-rest/azure-arm-app-service.AzureAppService.restart方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。