當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript js.default.generateDeploymentId方法代碼示例

本文整理匯總了TypeScript中azurerest-common/utility.js.default.generateDeploymentId方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript js.default.generateDeploymentId方法的具體用法?TypeScript js.default.generateDeploymentId怎麽用?TypeScript js.default.generateDeploymentId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在azurerest-common/utility.js.default的用法示例。


在下文中一共展示了js.default.generateDeploymentId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: runPostDeploymentScript

export async function runPostDeploymentScript(publishingProfile, physicalPath, scriptType, inlineScript, scriptPath, appOfflineFlag) {
    var scriptFile = getPostDeploymentScript(scriptType, inlineScript, scriptPath);
    var uniqueID = azureUtility.generateDeploymentId();
    tl.debug('Deployment ID : ' + uniqueID);
    var deleteLogFiles = false;

    if(appOfflineFlag) {
        await appOfflineKuduService(publishingProfile, physicalPath, true);
    }
    try {
        var mainCmdFilePath = path.join(__dirname, 'postDeploymentScript', 'mainCmdFile.cmd');
        await uploadFiletoKudu(publishingProfile, physicalPath, 'mainCmdFile_' + uniqueID + '.cmd', mainCmdFilePath);
        await uploadFiletoKudu(publishingProfile, physicalPath, 'kuduPostDeploymentScript_' + uniqueID + '.cmd', scriptFile.filePath);
        console.log(tl.loc('ExecuteScriptOnKudu', publishingProfile.publishUrl));
        await runCommandOnKudu(publishingProfile, physicalPath, 'mainCmdFile_' + uniqueID + '.cmd ' + uniqueID, 30, 'script_result_' +  uniqueID + '.txt');
        console.log(tl.loc('ScriptExecutionOnKuduSuccess'));
        deleteLogFiles = true;
        await getPostDeploymentScriptLogs(publishingProfile, physicalPath, uniqueID);
    }
    catch(Exception) {
        throw Error(Exception);
    }
    finally {
        if(scriptFile.isCreated) {
            tl.rmRF(scriptFile.filePath, true);
        }
        try {
            await uploadFiletoKudu(publishingProfile, physicalPath, 'delete_log_file_' + uniqueID + '.cmd', path.join(__dirname, 'postDeploymentScript', 'deleteLogFile.cmd'));
            var commandResult = await runCommandOnKudu(publishingProfile, physicalPath, 'delete_log_file_' + uniqueID + '.cmd ' + uniqueID, 0, null);
            tl.debug(JSON.stringify(commandResult));
        }
        catch(error) {
            tl.debug('Unable to delete log files : ' + error);
        }
        if(appOfflineFlag) {
            await appOfflineKuduService(publishingProfile, physicalPath, false);
        }
    }
}
開發者ID:colindembovsky,項目名稱:vsts-tasks,代碼行數:39,代碼來源:kuduutility.ts

示例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 = 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);
    }
}
開發者ID:colindembovsky,項目名稱:vsts-tasks,代碼行數:99,代碼來源:azureappservicemanage.ts


注:本文中的azurerest-common/utility.js.default.generateDeploymentId方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。