diff --git a/Composer/packages/client/src/components/GetStarted/GetStartedNextSteps.tsx b/Composer/packages/client/src/components/GetStarted/GetStartedNextSteps.tsx index 522d267c37..f673e2ad70 100644 --- a/Composer/packages/client/src/components/GetStarted/GetStartedNextSteps.tsx +++ b/Composer/packages/client/src/components/GetStarted/GetStartedNextSteps.tsx @@ -38,7 +38,7 @@ export const GetStartedNextSteps: React.FC = (props) => { const [displayManageLuis, setDisplayManageLuis] = useState(false); const [displayManageQNA, setDisplayManageQNA] = useState(false); - const { setSettings } = useRecoilValue(dispatcherState); + const { setSettings, setQnASettings } = useRecoilValue(dispatcherState); const rootBotProjectId = useRecoilValue(rootBotProjectIdSelector) || ''; const settings = useRecoilValue(settingsState(projectId)); const mergedSettings = mergePropertiesManagedByRootBot(projectId, rootBotProjectId, settings); @@ -89,6 +89,7 @@ export const GetStartedNextSteps: React.FC = (props) => { ...mergedSettings, qna: { ...mergedSettings.qna, ...newQNASettings }, }); + setQnASettings(rootBotProjectId, newQNASettings.subscriptionKey); }; const linkToPackageManager = `/bot/${rootBotProjectId}/plugin/package-manager/package-manager`; diff --git a/Composer/packages/client/src/components/ManageQNA/ManageQNA.tsx b/Composer/packages/client/src/components/ManageQNA/ManageQNA.tsx index 56af46a2ec..f4c05ea42d 100644 --- a/Composer/packages/client/src/components/ManageQNA/ManageQNA.tsx +++ b/Composer/packages/client/src/components/ManageQNA/ManageQNA.tsx @@ -278,22 +278,6 @@ export const ManageQNA = (props: ManageQNAProps) => { applicationType: 'web', kind: 'web', }); - // deploy qna host webapp - const webAppResult = await webSiteManagementClient.webApps.createOrUpdate( - resourceGroupName, - qnaMakerWebAppName, - { - name: qnaMakerWebAppName, - serverFarmId: resourceGroupName, - location: localRootQNARegion, - siteConfig: { - cors: { - allowedOrigins: ['*'], - }, - }, - enabled: true, - } - ); // add web config for websites const azureSearchAdminKey = (await searchManagementClient.adminKeys.get(resourceGroupName, qnaMakerSearchName)) @@ -310,46 +294,60 @@ export const ManageQNA = (props: ManageQNAProps) => { const defaultAnswer = 'No good match found in KB.'; const QNAMAKER_EXTENSION_VERSION = 'latest'; - await webSiteManagementClient.webApps.createOrUpdateConfiguration(resourceGroupName, qnaMakerWebAppName, { - appSettings: [ - { - name: 'AzureSearchName', - value: qnaMakerSearchName, - }, - { - name: 'AzureSearchAdminKey', - value: azureSearchAdminKey, - }, - { - name: 'UserAppInsightsKey', - value: userAppInsightsKey, - }, - { - name: 'UserAppInsightsName', - value: userAppInsightsName, - }, - { - name: 'UserAppInsightsAppId', - value: userAppInsightsAppId, - }, - { - name: 'PrimaryEndpointKey', - value: primaryEndpointKey, - }, - { - name: 'SecondaryEndpointKey', - value: secondaryEndpointKey, - }, - { - name: 'DefaultAnswer', - value: defaultAnswer, - }, - { - name: 'QNAMAKER_EXTENSION_VERSION', - value: QNAMAKER_EXTENSION_VERSION, + // deploy qna host webapp + const webAppResult = await webSiteManagementClient.webApps.createOrUpdate( + resourceGroupName, + qnaMakerWebAppName, + { + name: qnaMakerWebAppName, + serverFarmId: resourceGroupName, + location: localRootQNARegion, + siteConfig: { + cors: { + allowedOrigins: ['*'], + }, + appSettings: [ + { + name: 'AzureSearchName', + value: qnaMakerSearchName, + }, + { + name: 'AzureSearchAdminKey', + value: azureSearchAdminKey, + }, + { + name: 'UserAppInsightsKey', + value: userAppInsightsKey, + }, + { + name: 'UserAppInsightsName', + value: userAppInsightsName, + }, + { + name: 'UserAppInsightsAppId', + value: userAppInsightsAppId, + }, + { + name: 'PrimaryEndpointKey', + value: primaryEndpointKey, + }, + { + name: 'SecondaryEndpointKey', + value: secondaryEndpointKey, + }, + { + name: 'DefaultAnswer', + value: defaultAnswer, + }, + { + name: 'QNAMAKER_EXTENSION_VERSION', + value: QNAMAKER_EXTENSION_VERSION, + }, + ], }, - ], - }); + enabled: true, + } + ); // Create qna account const cognitiveServicesManagementClient = new CognitiveServicesManagementClient( @@ -593,6 +591,7 @@ export const ManageQNA = (props: ManageQNAProps) => { = (pr ...mergedSettings, qna: { ...mergedSettings.qna, ...newQNASettings }, }); + setQnASettings(projectId, newQNASettings.subscriptionKey); }; return ( @@ -384,6 +385,7 @@ export const RootBotExternalService: React.FC = (pr )} { @@ -407,6 +409,7 @@ export const RootBotExternalService: React.FC = (pr /> { diff --git a/extensions/azurePublish/src/node/azureResourceManager/azureResourceManager.ts b/extensions/azurePublish/src/node/azureResourceManager/azureResourceManager.ts index 1982be277f..08a37f3c11 100644 --- a/extensions/azurePublish/src/node/azureResourceManager/azureResourceManager.ts +++ b/extensions/azurePublish/src/node/azureResourceManager/azureResourceManager.ts @@ -323,31 +323,6 @@ export class AzureResourceMananger { throw createCustomizeError(ProvisionErrors.CREATE_QNA_ERROR, appinsightsDeployResult._response.bodyAsText); } - // deploy qna host webapp - const webAppResult = await webSiteManagementClient.webApps.createOrUpdate( - config.resourceGroupName, - qnaMakerWebAppName, - { - name: qnaMakerWebAppName, - serverFarmId: servicePlanResult.name, - location: config.location, - siteConfig: { - cors: { - allowedOrigins: ['*'], - }, - }, - enabled: true, - } - ); - - if (webAppResult._response.status >= 300) { - this.logger({ - status: BotProjectDeployLoggerType.PROVISION_ERROR, - message: webAppResult._response.bodyAsText, - }); - throw createCustomizeError(ProvisionErrors.CREATE_QNA_ERROR, webAppResult._response.bodyAsText); - } - // add web config for websites const azureSearchAdminKey = ( await searchManagementClient.adminKeys.get(config.resourceGroupName, qnaMakerSearchName) @@ -363,62 +338,73 @@ export class AzureResourceMananger { const secondaryEndpointKey = `${qnaMakerWebAppName}-SecondaryEndpointKey`; const defaultAnswer = 'No good match found in KB.'; const QNAMAKER_EXTENSION_VERSION = 'latest'; - const EnalbeMultipleTestIndex = 'true'; + const EnableMultipleTestIndex = 'true'; - const webAppConfigUpdateResult = await webSiteManagementClient.webApps.createOrUpdateConfiguration( + // deploy qna host webapp + const webAppResult = await webSiteManagementClient.webApps.createOrUpdate( config.resourceGroupName, qnaMakerWebAppName, { - appSettings: [ - { - name: 'AzureSearchName', - value: qnaMakerSearchName, - }, - { - name: 'AzureSearchAdminKey', - value: azureSearchAdminKey, - }, - { - name: 'UserAppInsightsKey', - value: userAppInsightsKey, - }, - { - name: 'UserAppInsightsName', - value: userAppInsightsName, - }, - { - name: 'UserAppInsightsAppId', - value: userAppInsightsAppId, - }, - { - name: 'PrimaryEndpointKey', - value: primaryEndpointKey, - }, - { - name: 'SecondaryEndpointKey', - value: secondaryEndpointKey, - }, - { - name: 'DefaultAnswer', - value: defaultAnswer, - }, - { - name: 'QNAMAKER_EXTENSION_VERSION', - value: QNAMAKER_EXTENSION_VERSION, - }, - { - name: 'EnalbeMultipleTestIndex', - value: EnalbeMultipleTestIndex, + name: qnaMakerWebAppName, + serverFarmId: servicePlanResult.name, + location: config.location, + siteConfig: { + cors: { + allowedOrigins: ['*'], }, - ], + appSettings: [ + { + name: 'AzureSearchName', + value: qnaMakerSearchName, + }, + { + name: 'AzureSearchAdminKey', + value: azureSearchAdminKey, + }, + { + name: 'UserAppInsightsKey', + value: userAppInsightsKey, + }, + { + name: 'UserAppInsightsName', + value: userAppInsightsName, + }, + { + name: 'UserAppInsightsAppId', + value: userAppInsightsAppId, + }, + { + name: 'PrimaryEndpointKey', + value: primaryEndpointKey, + }, + { + name: 'SecondaryEndpointKey', + value: secondaryEndpointKey, + }, + { + name: 'DefaultAnswer', + value: defaultAnswer, + }, + { + name: 'QNAMAKER_EXTENSION_VERSION', + value: QNAMAKER_EXTENSION_VERSION, + }, + { + name: 'EnableMultipleTestIndex', + value: EnableMultipleTestIndex, + }, + ], + }, + enabled: true, } ); - if (webAppConfigUpdateResult._response.status >= 300) { + + if (webAppResult._response.status >= 300) { this.logger({ status: BotProjectDeployLoggerType.PROVISION_ERROR, - message: webAppConfigUpdateResult._response.bodyAsText, + message: webAppResult._response.bodyAsText, }); - throw createCustomizeError(ProvisionErrors.CREATE_QNA_ERROR, webAppConfigUpdateResult._response.bodyAsText); + throw createCustomizeError(ProvisionErrors.CREATE_QNA_ERROR, webAppResult._response.bodyAsText); } // Create qna account