ARM process is done.

This commit is contained in:
Rodrigo Rodriguez (pragmatismo.io) 2018-11-04 17:26:29 -02:00
parent 5ecf922999
commit ecf2ba35ef
7 changed files with 50 additions and 31 deletions

13
package-lock.json generated
View file

@ -4542,6 +4542,11 @@
"resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz",
"integrity": "sha1-0YUOuXkezRjmGCzhKjDzlmNLsZ0="
},
"is-wsl": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz",
"integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0="
},
"isarray": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
@ -5629,6 +5634,14 @@
"resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz",
"integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4="
},
"opn": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/opn/-/opn-5.4.0.tgz",
"integrity": "sha512-YF9MNdVy/0qvJvDtunAOzFw9iasOQHpVthTCvGzxt61Il64AYSGdK+rYwld7NAfk9qJ7dt+hymBNSc9LNYS+Sw==",
"requires": {
"is-wsl": "^1.1.0"
}
},
"optimist": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",

View file

@ -71,6 +71,7 @@
"ms-rest-azure": "2.5.9",
"nexmo": "2.4.0",
"ngrok": "^3.1.0",
"opn": "^5.4.0",
"pragmatismo-io-framework": "1.0.17",
"process-exists": "^3.1.0",
"public-ip": "^2.4.0",

View file

@ -40,6 +40,9 @@ const msRestAzure = require("ms-rest-azure");
const PasswordGenerator = require("strict-password-generator").default;
export class GBAdminService {
static GB_PROMPT: string = "GeneralBots: "
static generateUuid(): string {
return msRestAzure.generateUuid();
}

View file

@ -48,6 +48,7 @@ import { AppServicePlan } from "azure-arm-website/lib/models";
import { GBConfigService } from "../../../packages/core.gbapp/services/GBConfigService";
import { GBAdminService } from "../../../packages/admin.gbapp/services/GBAdminService";
import { GBCorePackage } from "../../../packages/core.gbapp";
import { GBDeployer } from "packages/core.gbapp/services/GBDeployer";
const Spinner = require("cli-spinner").Spinner;
const scanf = require("scanf");
@ -72,7 +73,12 @@ export class AzureDeployerService extends GBService {
public subscriptionId: string;
static apiVersion = "2017-12-01";
farmName: any;
deployer: GBDeployer;
constructor(deployer: GBDeployer){
super();
this.deployer = deployer;
}
public static async getSubscriptions(credentials) {
let subscriptionClient = new SubscriptionClient.default(credentials);
return subscriptionClient.subscriptions.list();
@ -97,16 +103,6 @@ export class AzureDeployerService extends GBService {
logger.info(`Deploying Deploy Group (It may take a few minutes)...`);
await this.createDeployGroup(name, instance.cloudLocation);
instance = await this.deployBootBot(
instance,
name,
`${proxyAddress}/api/messages/${name}`,
instance.nlpAppId,
instance.nlpKey,
instance.cloudSubscriptionId
);
logger.info(`Deploying Bot Server...`);
let serverFarm = await this.createHostingPlan(
name,
@ -155,7 +151,8 @@ export class AzureDeployerService extends GBService {
instance.searchHost = `${searchName}.search.windows.net`;
instance.searchIndex = "azuresql-index";
instance.searchIndexer = "azuresql-indexer";
instance.searchKey = searchKeys[0].key;
instance.searchKey = searchKeys.primaryKey;
this.deployer.rebuildIndex(instance);
logger.info(`Deploying Speech...`);
let speech = await this.createSpeech(
@ -218,6 +215,7 @@ export class AzureDeployerService extends GBService {
instance.cloudSubscriptionId
);
spinner.stop();
return instance;
}
@ -262,32 +260,32 @@ export class AzureDeployerService extends GBService {
}
let retriveUsername = () => {
if (!username) {
process.stdout.write("CLOUD_USERNAME:");
process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_USERNAME:`);
username = scanf("%s").replace(/(\n|\r)+$/, "");
}
};
let retrivePassword = () => {
if (!password) {
process.stdout.write("CLOUD_PASSWORD:");
process.stdout.write(`${GBAdminService.GB_PROMPT}CLOUD_PASSWORD:`);
password = scanf("%s").replace(/(\n|\r)+$/, "");
}
};
let retrieveBotId = () => {
if (!botId) {
process.stdout.write(
"Bot Id must only contain lowercase letters, digits or dashes, cannot start or end with or contain consecutive dashes and is limited from 4 to 42 characters long.\n"
`${GBAdminService.GB_PROMPT}Bot Id must only contain lowercase letters, digits or dashes, cannot start or end with or contain consecutive dashes and is limited from 4 to 42 characters long.\n`
);
process.stdout.write("BOT_ID:");
botId = scanf("%s").replace(/(\n|\r)+$/, "");
process.stdout.write(`${GBAdminService.GB_PROMPT}BOT_ID:`);
botId = scanf("%s").replace(/(\n|\r)+$/, ""); // TODO: Update this regexp to match description of it.
}
};
let authoringKey = GBConfigService.get("NLP_AUTHORING_KEY");
let retriveAuthoringKey = () => {
if (!authoringKey) {
process.stdout.write(
"Due to this opened issue: https://github.com/Microsoft/botbuilder-tools/issues/550\n"
`${GBAdminService.GB_PROMPT}Due to this opened issue: https://github.com/Microsoft/botbuilder-tools/issues/550\n`
);
process.stdout.write("Please enter your LUIS Authoring Key:");
process.stdout.write(`${GBAdminService.GB_PROMPT}Please enter your LUIS Authoring Key:`);
authoringKey = scanf("%s").replace(/(\n|\r)+$/, "");
}
};
@ -380,8 +378,8 @@ export class AzureDeployerService extends GBService {
nlpKey,
subscriptionId
) {
let appId = GBConfigService.get("MSAPP_ID");
let appPassword = GBConfigService.get("MSAPP_PASSWORD");
let appId = GBConfigService.get("MARKETPLACE_ID");
let appPassword = GBConfigService.get("MARKETPLACE_SECRET");
if (!appId || !appPassword) {
process.stdout.write(
@ -391,14 +389,14 @@ export class AzureDeployerService extends GBService {
let retriveAppId = () => {
if (!appId) {
process.stdout.write("Generated Application Id (MSAPP_ID):");
process.stdout.write("Generated Application Id (MARKETPLACE_ID):");
appId = scanf("%s").replace(/(\n|\r)+$/, "");
}
};
let retriveAppPassword = () => {
if (!appPassword) {
process.stdout.write("Generated Password (MSAPP_PASSWORD):");
process.stdout.write("Generated Password (MARKETPLACE_SECRET):");
appPassword = scanf("%s").replace(/(\n|\r)+$/, "");
}
};

View file

@ -307,8 +307,8 @@ export class GBCoreService implements IGBCoreService {
`CLOUD_GROUP=${instance.botId}\n` +
`CLOUD_USERNAME=${instance.cloudUsername}\n` +
`CLOUD_PASSWORD=${instance.cloudPassword}\n` +
`MSAPP_ID=${instance.marketplaceId}\n`+
`MSAPP_PASSWORD=${instance.marketplacePassword}\n`+
`MARKETPLACE_ID=${instance.marketplaceId}\n`+
`MARKETPLACE_SECRET=${instance.marketplacePassword}\n`+
`NLP_AUTHORING_KEY=${instance.nlpAuthoringKey}\n`+
`STORAGE_DIALECT=${instance.storageDialect}\n` +
`STORAGE_SERVER=${instance.storageServer}.database.windows.net\n` +

View file

@ -500,7 +500,7 @@ export class GBMinService {
let json = await request(options);
return Promise.resolve(JSON.parse(json));
} catch (error) {
let msg = `Error calling Direct Line client, verify Bot endpoint on the cloud. Error is: ${error}.`;
let msg = `[botId:${instance.botId}] Error calling Direct Line client, verify Bot endpoint on the cloud. Error is: ${error}.`;
return Promise.reject(new Error(msg));
}
}

View file

@ -36,6 +36,7 @@
const logger = require("./logger");
const express = require("express");
const bodyParser = require("body-parser");
const opn = require('opn');
import { GBConfigService } from "../packages/core.gbapp/services/GBConfigService";
import { GBConversationalService } from "../packages/core.gbapp/services/GBConversationalService";
@ -101,7 +102,8 @@ export class GBServer {
logger.info(`Establishing a development local proxy (ngrok)...`);
let proxyAddress = await core.ensureProxy(port);
let azureDeployer = new AzureDeployerService();
let deployer = new GBDeployer(core, new GBImporter(core));
let azureDeployer = new AzureDeployerService(deployer);
try {
await core.initDatabase();
@ -111,7 +113,7 @@ export class GBServer {
bootInstance = await azureDeployer.deployFarm(proxyAddress);
} catch (error) {
logger.warn(
"In case of error, please cleanup any infrastructure objects created during this procedure before running again."
"In case of error, please cleanup any infrastructure objects created during this procedure and .env before running again."
);
throw error;
}
@ -132,7 +134,7 @@ export class GBServer {
if (!GBAdminService.StrongRegex.test(password)) {
throw new Error(
"STOP: Please, define a really strong password in ADMIN_PASS environment variable before running the server."
"Please, define a really strong password in ADMIN_PASS environment variable before running the server."
);
}
@ -202,8 +204,6 @@ export class GBServer {
// Deploy packages and format object store according to .gbapp storage models.
logger.info(`Deploying packages...`);
let deployer = new GBDeployer(core, new GBImporter(core));
await deployer.rebuildIndex(instances[0]);
await deployer.deployPackages(core, server, appPackages);
// If instances is undefined here it's because storage has been formatted.
@ -216,7 +216,7 @@ export class GBServer {
// Setup server dynamic (per bot instance) resources and listeners.
logger.info(`Building instances.`);
logger.info(`Mouting instances...`);
let minService = new GBMinService(
core,
conversationalService,
@ -226,6 +226,10 @@ export class GBServer {
await minService.buildMin(server, appPackages, instances);
logger.info(`The Bot Server is in RUNNING mode...`);
if (process.env.NODE_ENV === "development") {
opn('http://localhost:4242');
}
return core;
} catch (err) {
logger.error(`STOP: ${err} ${err.stack ? err.stack : ""}`);