Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
10 changes: 9 additions & 1 deletion extensions/azurePublish/src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,27 @@ export class BotProjectDeploy {
const publishEndpoint = `https://${
hostname ? hostname : name + '-' + env
}.scm.azurewebsites.net/zipdeploy/?isAsync=true`;
const fileReadStream = fs.createReadStream(zipPath, {autoClose:true});
fileReadStream.on( "error", function (err) {
console.log(err);
Comment thread
a-b-r-o-w-n marked this conversation as resolved.
Outdated
throw err;
});

try {
const response = await rp.post({
uri: publishEndpoint,
auth: {
bearer: token,
},
body: fs.createReadStream(zipPath),
body: fileReadStream,
});
this.logger({
status: BotProjectDeployLoggerType.DEPLOY_INFO,
message: response,
});
} catch (err) {
// close file read stream
fileReadStream.close();
if (err.statusCode === 403) {
throw new Error(
`Token expired, please run az account get-access-token, then replace the accessToken in your configuration`
Expand Down
82 changes: 53 additions & 29 deletions extensions/azurePublish/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,14 @@ export default async (composer: ExtensionRegistration): Promise<void> => {
* @param resourcekey
*/
private async cleanup(resourcekey: string) {
const projFolder = this.getRuntimeFolder(resourcekey);
await emptyDir(projFolder);
await rmdir(projFolder);
try {
const projFolder = this.getRuntimeFolder(resourcekey);
await emptyDir(projFolder);
await rmdir(projFolder);
} catch (error) {
console.error(error);
Comment thread
a-b-r-o-w-n marked this conversation as resolved.
Outdated
}

}

/**
Expand Down Expand Up @@ -334,34 +339,53 @@ export default async (composer: ExtensionRegistration): Promise<void> => {
runtimeCodePath = project.settings.runtime.path;
}

// Prepare the temporary project
// this writes all the settings to the root settings/appsettings.json file
await this.init(project, runtimeCodePath, resourcekey, runtime);
try {
// Prepare the temporary project
// this writes all the settings to the root settings/appsettings.json file
await this.init(project, runtimeCodePath, resourcekey, runtime);

// Merge all the settings
// this combines the bot-wide settings, the environment specific settings, and 2 new fields needed for deployed bots
// these will be written to the appropriate settings file inside the appropriate runtime plugin.
const mergedSettings = mergeDeep(fullSettings, settings);

// Prepare parameters and then perform the actual deployment action
const customizeConfiguration: CreateAndDeployResources = {
accessToken,
subscriptionID,
name,
environment,
hostname,
luisResource,
};
await this.performDeploymentAction(
project,
mergedSettings,
runtime,
project.id,
profileName,
jobId,
resourcekey,
customizeConfiguration
);
} catch (err) {
console.log(err);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Composer logger.

if (err instanceof Error) {
this.logMessages.push(err.message);
} else if (typeof err === 'object') {
this.logMessages.push(JSON.stringify(err));
} else {
this.logMessages.push(err);
}

// Merge all the settings
// this combines the bot-wide settings, the environment specific settings, and 2 new fields needed for deployed bots
// these will be written to the appropriate settings file inside the appropriate runtime plugin.
const mergedSettings = mergeDeep(fullSettings, settings);
const response = this.getLoadingStatus(project.id, profileName, jobId);
response.status = 500;
response.result.message = this.logMessages[this.logMessages.length - 1];

// Prepare parameters and then perform the actual deployment action
const customizeConfiguration: CreateAndDeployResources = {
accessToken,
subscriptionID,
name,
environment,
hostname,
luisResource,
};
await this.performDeploymentAction(
project,
mergedSettings,
runtime,
project.id,
profileName,
jobId,
resourcekey,
customizeConfiguration
);
await this.updateHistory(project.id, profileName, { status: response.status, ...response.result });
this.removeLoadingStatus(project.id, profileName, jobId);
this.cleanup(resourcekey);
}
};

/**************************************************************************************************
Expand Down