Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 40 additions & 19 deletions extensions/azurePublish/src/node/provision.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export class BotProjectProvision {
this.graphToken = config.graphToken;
}

private sleep = (waitTimeInMs) => new Promise((resolve) => setTimeout(resolve, waitTimeInMs));

/*******************************************************************************************************************************/
/* This section has to do with creating new Azure resources
/*******************************************************************************************************************************/
Expand Down Expand Up @@ -101,19 +103,29 @@ export class BotProjectProvision {
// documented here: https://docs.microsoft.com/en-us/graph/api/resources/application?view=graph-rest-1.0#properties
// we need the `appId` and `id` fields - appId is part of our configuration, and the `id` is used to set the password.
let appCreated;
try {
appCreated = await rp.post(applicationUri, appCreateOptions);
} catch (err) {
let retryCount = 3;
while (retryCount >= 0) {
try {
appCreated = await rp.post(applicationUri, appCreateOptions);
} catch (err) {
this.logger({
status: BotProjectDeployLoggerType.PROVISION_ERROR,
message: `App create failed: ${JSON.stringify(err, null, 4)}, retrying ...`,
});
if (retryCount == 0) {
throw createCustomizeError(ProvisionErrors.CREATE_APP_REGISTRATION, 'App create failed!');
} else {
await this.sleep(3000);
retryCount--;
continue;
}
}
this.logger({
status: BotProjectDeployLoggerType.PROVISION_ERROR,
message: `App create failed: ${JSON.stringify(err, null, 4)}`,
status: BotProjectDeployLoggerType.PROVISION_INFO,
message: `Start to add password for App, Id : ${appCreated.appId}`,
});
throw createCustomizeError(ProvisionErrors.CREATE_APP_REGISTRATION, 'App create failed!');
break;
}
this.logger({
status: BotProjectDeployLoggerType.PROVISION_INFO,
message: `Start to add password for App, Id : ${appCreated.appId}`,
});

const appId = appCreated.appId;

Expand All @@ -131,16 +143,25 @@ export class BotProjectProvision {
} as rp.RequestPromiseOptions;

let passwordSet;
try {
passwordSet = await rp.post(addPasswordUri, setSecretOptions);
} catch (err) {
this.logger({
status: BotProjectDeployLoggerType.PROVISION_ERROR,
message: `Add application password failed: ${JSON.stringify(err, null, 4)}`,
});
throw createCustomizeError(ProvisionErrors.CREATE_APP_REGISTRATION, 'Add application password failed!');
retryCount = 3;
while (retryCount >= 0) {
try {
passwordSet = await rp.post(addPasswordUri, setSecretOptions);
} catch (err) {
this.logger({
status: BotProjectDeployLoggerType.PROVISION_ERROR,
message: `Add application password failed: ${JSON.stringify(err, null, 4)}, retrying ...`,
});
if (retryCount == 0) {
throw createCustomizeError(ProvisionErrors.CREATE_APP_REGISTRATION, 'Add application password failed!');
} else {
await this.sleep(3000);
retryCount--;
continue;
}
}
break;
}

const appPassword = passwordSet.secretText;

this.logger({
Expand Down