Skip to content

Commit 0b142e6

Browse files
authored
Merge branch 'main' into dependabot/npm_and_yarn/dot-github/actions/conventional-pr/actions/core-1.9.1
2 parents 23d7b05 + 0aed22f commit 0b142e6

File tree

6 files changed

+84
-18
lines changed

6 files changed

+84
-18
lines changed

Composer/packages/server/src/externalContentProvider/azureBotServiceProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class AzureBotServiceProvider extends ExternalContentProvider<AzureBotSer
7474
type: 'azurePublish',
7575
configuration: JSON.stringify({
7676
hostname: '',
77-
runtimeIdentifier: 'win-x64',
77+
runtimeIdentifier: this.metadata.runtimeIdentifier ?? 'win-x64',
7878
settings: {
7979
MicrosoftAppId: appId,
8080
MicrosoftAppPassword: appPwd,

Composer/packages/ui-plugins/composer/src/defaultFlowSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ export const DefaultFlowSchema: FlowUISchema = {
221221
widget: 'ActionCard',
222222
body: {
223223
widget: 'PropertyDescription',
224-
property: '=coalesce(action.errorValue, "?")',
224+
property: '=coalesce(string(action.errorValue), "?")',
225225
description: '= ErrorValue',
226226
},
227227
},

Composer/packages/ui-plugins/schema-editor/src/__tests__/SchemaEditorField.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { EditorExtension } from '@bfc/extension-client';
77
import { render, fireEvent } from '@botframework-composer/test-utils';
88

99
import { SchemaEditorField } from '../Fields/SchemaEditorField';
10-
import { SCHEMA_URI } from '../contants';
1110

1211
const renderSchemaEditor = ({ updateDialogSchema = jest.fn() } = {}) => {
1312
const api: any = {
@@ -61,7 +60,7 @@ describe('Schema Editor', () => {
6160
properties: expect.objectContaining({
6261
propertyName: {
6362
title: 'Property Name',
64-
$ref: `${SCHEMA_URI}#/definitions/valueExpression`,
63+
type: 'string',
6564
},
6665
}),
6766
}),

Composer/packages/ui-plugins/schema-editor/src/uiOptions.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { UIOptions } from '@bfc/extension-client';
55
import formatMessage from 'format-message';
66
import startCase from 'lodash/startCase';
77

8-
import { ValueRefField } from './Fields/ValueRefField';
9-
108
const objectSerializer = {
119
get: (value) => value,
1210
set: (value) =>
@@ -25,15 +23,6 @@ export const uiOptions: UIOptions = {
2523
additionalProperties: {
2624
hidden: ['title'],
2725
order: ['type', 'description', '*'],
28-
serializer: {
29-
get: ({ $ref, ...rest }: any = {}) => ($ref ? { ...rest, type: $ref } : rest),
30-
set: ({ type, ...rest }: any = {}) => (type ? { ...rest, $ref: type } : rest),
31-
},
32-
properties: {
33-
type: {
34-
field: ValueRefField,
35-
},
36-
},
3726
},
3827
},
3928
},

extensions/azurePublish/src/node/deploy.ts

Lines changed: 73 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,26 @@ export class BotProjectDeploy {
162162
status: BotProjectDeployLoggerType.DEPLOY_SUCCESS,
163163
message: 'Published successfully!',
164164
});
165+
166+
// STEP 6: UPDATE STACK PROPERTY IN WEB APP
167+
this.logger({
168+
status: BotProjectDeployLoggerType.DEPLOY_INFO,
169+
message: 'Updating Bots properties',
170+
});
171+
172+
const profile = settings.publishTargets.find((p) => p.name === profileName);
173+
const configuration = JSON.parse(profile.configuration);
174+
175+
if (settings.runtime.command.includes('dotnet') && configuration.appServiceOperatingSystem === 'linux') {
176+
await this.updateBotSettings(
177+
this.accessToken,
178+
name,
179+
environment,
180+
hostname,
181+
absSettings.subscriptionId,
182+
absSettings.resourceGroup
183+
);
184+
}
165185
} catch (error) {
166186
this.logger({
167187
status: BotProjectDeployLoggerType.DEPLOY_ERROR,
@@ -248,14 +268,22 @@ export class BotProjectDeploy {
248268
try {
249269
const statusResponse = await axios.get(statusUrl, { headers: { Authorization: `Bearer ${token}` } });
250270

251-
if (statusResponse.data.provisioningState === 'Succeeded') {
271+
/* We use the 'statusEnum' property to map the states of Windows and Linux bots.
272+
The 'provisioningState' property was previously being used, but Linux bots don't have it.
273+
Visit https://github.com/projectkudu/kudu/blob/master/Kudu.Contracts/Deployment/DeployStatus.cs for more information. */
274+
const statusEnum = {
275+
3: 'Failed',
276+
4: 'Succeeded',
277+
}[statusResponse.data.status];
278+
279+
if (statusEnum === 'Succeeded') {
252280
this.logger({
253281
status: BotProjectDeployLoggerType.DEPLOY_INFO,
254282
message: 'Zip upload processed successfully.',
255283
});
256284
clearInterval(timerId);
257285
resolve();
258-
} else if (statusResponse.data.provisioningState === 'Failed') {
286+
} else if (statusEnum === 'Failed') {
259287
clearInterval(timerId);
260288
reject(`Zip upload processing failed. ${statusResponse.data.status_text}`);
261289
} else {
@@ -324,6 +352,49 @@ export class BotProjectDeploy {
324352
return `https://${hostnameResult}.${scmHostDomainResult}/zipdeploy/?isAsync=true`;
325353
};
326354

355+
// Update Web App Settings
356+
private async updateBotSettings(
357+
token: string,
358+
name: string,
359+
env: string,
360+
hostname: string,
361+
subscriptionId: string,
362+
resourceGroup: string
363+
) {
364+
try {
365+
const updateEndpoint = this.buildUpdateEndpoint(hostname, name, env, subscriptionId, resourceGroup);
366+
const response = await axios.put(
367+
updateEndpoint,
368+
{ properties: { linuxFxVersion: 'DOTNETCORE|3.1' } },
369+
{ headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' } }
370+
);
371+
372+
if (response.status === 200) {
373+
this.logger({
374+
status: BotProjectDeployLoggerType.DEPLOY_INFO,
375+
message: `Settings successfully updated.`,
376+
});
377+
}
378+
} catch (err) {
379+
const errorMessage = JSON.stringify(err, Object.getOwnPropertyNames(err));
380+
throw createCustomizeError(
381+
AzurePublishErrors.DEPLOY_ZIP_ERROR,
382+
`There was a problem updating the bot's settings. ${errorMessage}`
383+
);
384+
}
385+
}
386+
387+
private buildUpdateEndpoint = (
388+
hostname: string,
389+
name: string,
390+
env: string,
391+
subscriptionId: string,
392+
resourceGroupName: string
393+
) => {
394+
const hostnameResult = hostname ? hostname : name + (env ? '-' + env : '');
395+
return `https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Web/sites/${hostnameResult}/config/web?api-version=2022-03-01`;
396+
};
397+
327398
/**
328399
* link the bot channel registration with azure web app service
329400
* @param absSettings the abs settings

extensions/azurePublish/src/node/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,13 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
305305
}
306306
const currentSettings = currentProfile?.settings;
307307

308+
let runtimeIdentifier = 'win-x64';
309+
if (currentProfile?.runtimeIdentifier) {
310+
runtimeIdentifier = currentProfile?.runtimeIdentifier;
311+
} else if (provisionConfig.appServiceOperatingSystem === 'linux') {
312+
runtimeIdentifier = 'linux-x64';
313+
}
314+
308315
const publishProfile = {
309316
name: currentProfile?.name ?? provisionConfig.hostname,
310317
environment: currentProfile?.environment ?? 'composer',
@@ -316,7 +323,7 @@ export default async (composer: IExtensionRegistration): Promise<void> => {
316323
luisResource: provisionResults.luisPrediction
317324
? `${provisionConfig.hostname}-luis`
318325
: currentProfile?.luisResource,
319-
runtimeIdentifier: currentProfile?.runtimeIdentifier ?? 'win-x64',
326+
runtimeIdentifier: runtimeIdentifier,
320327
region: provisionConfig.location,
321328
appServiceOperatingSystem:
322329
provisionConfig.appServiceOperatingSystem ?? currentProfile?.appServiceOperatingSystem,

0 commit comments

Comments
 (0)