More testing and adjustments on automation.
This commit is contained in:
parent
b7f256b01f
commit
d3e82b5806
4 changed files with 74 additions and 74 deletions
|
@ -249,7 +249,7 @@ export class AzureDeployerService extends GBService {
|
||||||
// No .env so asks for cloud credentials to start a new farm.
|
// No .env so asks for cloud credentials to start a new farm.
|
||||||
if (!username || !password || !subscriptionId || !location || !botId) {
|
if (!username || !password || !subscriptionId || !location || !botId) {
|
||||||
process.stdout.write(
|
process.stdout.write(
|
||||||
"A empty enviroment is detected. Please, enter details:"
|
"A empty enviroment is detected. To start automatic deploy, please enter some information:\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let retriveUsername = () => {
|
let retriveUsername = () => {
|
||||||
|
@ -366,22 +366,19 @@ export class AzureDeployerService extends GBService {
|
||||||
|
|
||||||
public async deployBootBot(
|
public async deployBootBot(
|
||||||
instance,
|
instance,
|
||||||
name,
|
botId,
|
||||||
endpoint,
|
endpoint,
|
||||||
nlpAppId,
|
nlpAppId,
|
||||||
nlpKey,
|
nlpKey,
|
||||||
subscriptionId,
|
subscriptionId,
|
||||||
appId
|
appId
|
||||||
) {
|
) {
|
||||||
let botId = name + AzureDeployerService.getRndBotId();
|
await this.internalDeployBot(
|
||||||
[
|
instance,
|
||||||
instance.marketplacePassword,
|
|
||||||
instance.webchatKey
|
|
||||||
] = await this.internalDeployBot(
|
|
||||||
this.accessToken,
|
this.accessToken,
|
||||||
botId,
|
botId,
|
||||||
name,
|
botId,
|
||||||
name,
|
botId,
|
||||||
"General BootBot",
|
"General BootBot",
|
||||||
endpoint,
|
endpoint,
|
||||||
"global",
|
"global",
|
||||||
|
@ -396,10 +393,6 @@ export class AzureDeployerService extends GBService {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async dangerouslyDeleteDeploy(name) {
|
|
||||||
return await this.resourceClient.resourceGroups.deleteMethod(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async createStorageServer(
|
private async createStorageServer(
|
||||||
group,
|
group,
|
||||||
name,
|
name,
|
||||||
|
@ -440,7 +433,7 @@ export class AzureDeployerService extends GBService {
|
||||||
/**
|
/**
|
||||||
* @see https://github.com/Azure/azure-rest-api-specs/blob/master/specification/botservice/resource-manager/Microsoft.BotService/preview/2017-12-01/botservice.json
|
* @see https://github.com/Azure/azure-rest-api-specs/blob/master/specification/botservice/resource-manager/Microsoft.BotService/preview/2017-12-01/botservice.json
|
||||||
*/
|
*/
|
||||||
private async internalDeployBot(
|
private async internalDeployBot(instance,
|
||||||
accessToken,
|
accessToken,
|
||||||
botId,
|
botId,
|
||||||
name,
|
name,
|
||||||
|
@ -453,6 +446,7 @@ export class AzureDeployerService extends GBService {
|
||||||
subscriptionId,
|
subscriptionId,
|
||||||
appId
|
appId
|
||||||
) {
|
) {
|
||||||
|
return new Promise(async (resolve, reject) => {
|
||||||
let baseUrl = `https://management.azure.com/`;
|
let baseUrl = `https://management.azure.com/`;
|
||||||
await this.registerProviders(subscriptionId, baseUrl, accessToken);
|
await this.registerProviders(subscriptionId, baseUrl, accessToken);
|
||||||
|
|
||||||
|
@ -490,6 +484,7 @@ export class AzureDeployerService extends GBService {
|
||||||
);
|
);
|
||||||
let res = await httpClient.sendRequest(req);
|
let res = await httpClient.sendRequest(req);
|
||||||
|
|
||||||
|
setTimeout(async () => {
|
||||||
query = `subscriptions/${subscriptionId}/resourceGroups/${group}/providers/Microsoft.BotService/botServices/${botId}/channels/WebChatChannel/listChannelWithKeys?api-version=${
|
query = `subscriptions/${subscriptionId}/resourceGroups/${group}/providers/Microsoft.BotService/botServices/${botId}/channels/WebChatChannel/listChannelWithKeys?api-version=${
|
||||||
AzureDeployerService.apiVersion
|
AzureDeployerService.apiVersion
|
||||||
}`;
|
}`;
|
||||||
|
@ -501,8 +496,17 @@ export class AzureDeployerService extends GBService {
|
||||||
);
|
);
|
||||||
let resChannel = await httpClient.sendRequest(req);
|
let resChannel = await httpClient.sendRequest(req);
|
||||||
|
|
||||||
let key = (resChannel.bodyAsJson as any).properties.properties.sites[0].key;
|
console.log(resChannel.bodyAsText);
|
||||||
return [appPassword, key];
|
let key = (resChannel.bodyAsJson as any).properties.properties.sites[0]
|
||||||
|
.key;
|
||||||
|
|
||||||
|
instance.marketplacePassword = appPassword
|
||||||
|
instance.webchatKey = key
|
||||||
|
|
||||||
|
resolve(instance)
|
||||||
|
|
||||||
|
}, 10000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private createRequestObject(url: string, accessToken: string, body) {
|
private createRequestObject(url: string, accessToken: string, body) {
|
||||||
|
@ -735,20 +739,6 @@ export class AzureDeployerService extends GBService {
|
||||||
return `sa${generated}`;
|
return `sa${generated}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getRndBotId() {
|
|
||||||
const passwordGenerator = new PasswordGenerator();
|
|
||||||
const options = {
|
|
||||||
upperCaseAlpha: false,
|
|
||||||
lowerCaseAlpha: true,
|
|
||||||
number: true,
|
|
||||||
specialCharacter: false,
|
|
||||||
minimumLength: 8,
|
|
||||||
maximumLength: 8
|
|
||||||
};
|
|
||||||
let generated = passwordGenerator.generatePassword(options);
|
|
||||||
return `${generated}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static getRndPassword() {
|
private static getRndPassword() {
|
||||||
const passwordGenerator = new PasswordGenerator();
|
const passwordGenerator = new PasswordGenerator();
|
||||||
const options = {
|
const options = {
|
||||||
|
@ -760,6 +750,7 @@ export class AzureDeployerService extends GBService {
|
||||||
maximumLength: 14
|
maximumLength: 14
|
||||||
};
|
};
|
||||||
let password = passwordGenerator.generatePassword(options);
|
let password = passwordGenerator.generatePassword(options);
|
||||||
|
password = password.replace("=", "");
|
||||||
return password;
|
return password;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,9 @@ export class GBConfigService {
|
||||||
case "CLOUD_USERNAME":
|
case "CLOUD_USERNAME":
|
||||||
value = undefined;
|
value = undefined;
|
||||||
break;
|
break;
|
||||||
|
case "BOT_ID":
|
||||||
|
value = undefined;
|
||||||
|
break;
|
||||||
case "CLOUD_PASSWORD":
|
case "CLOUD_PASSWORD":
|
||||||
value = undefined;
|
value = undefined;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -307,6 +307,7 @@ export class GBCoreService implements IGBCoreService {
|
||||||
`STORAGE_NAME=${instance.storageName}\n` +
|
`STORAGE_NAME=${instance.storageName}\n` +
|
||||||
`STORAGE_USERNAME=${instance.storageUsername}\n` +
|
`STORAGE_USERNAME=${instance.storageUsername}\n` +
|
||||||
`STORAGE_PASSWORD=${instance.storagePassword}\n`+
|
`STORAGE_PASSWORD=${instance.storagePassword}\n`+
|
||||||
|
`STORAGE_SYNC=true\n`+
|
||||||
`CLOUD_USERNAME=${instance.cloudUsername}\n` +
|
`CLOUD_USERNAME=${instance.cloudUsername}\n` +
|
||||||
`CLOUD_PASSWORD=${instance.cloudPassword}\n` +
|
`CLOUD_PASSWORD=${instance.cloudPassword}\n` +
|
||||||
`CLOUD_SUBSCRIPTIONID=${instance.cloudSubscriptionId}\n` +
|
`CLOUD_SUBSCRIPTIONID=${instance.cloudSubscriptionId}\n` +
|
||||||
|
|
|
@ -102,8 +102,13 @@ export class GBServer {
|
||||||
await core.initDatabase();
|
await core.initDatabase();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.info(`Deploying cognitive infrastructure...`);
|
logger.info(`Deploying cognitive infrastructure...`);
|
||||||
|
try {
|
||||||
let azureDeployer = new AzureDeployerService();
|
let azureDeployer = new AzureDeployerService();
|
||||||
bootInstance = await azureDeployer.deployFarm(proxyAddress);
|
bootInstance = await azureDeployer.deployFarm(proxyAddress);
|
||||||
|
} catch (error) {
|
||||||
|
logger.warn("Error while deploying to the cloud, please, cleanup any objects created before running again.")
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
core.writeEnv(bootInstance);
|
core.writeEnv(bootInstance);
|
||||||
logger.info(`File .env written, starting...`);
|
logger.info(`File .env written, starting...`);
|
||||||
GBConfigService.init();
|
GBConfigService.init();
|
||||||
|
|
Loading…
Add table
Reference in a new issue