Skip to content

Commit 077eab3

Browse files
fix: Add AZURE_APP_API_BASE_URL environment variable and update related configurations for Teams extension
1 parent 0dfe330 commit 077eab3

File tree

10 files changed

+31
-11
lines changed

10 files changed

+31
-11
lines changed

docs/teams_extension.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ This extension enables users to experience Chat with your data within Teams, wit
3232

3333
![ENV](images/teams-1.png)
3434

35-
4. Locate the environment variable _AZURE_FUNCTION_URL_.
36-
5. Replace the `<FUNCTION_APP_NAME>` and `<FUNCTION_KEY>` with your actual Function App name and function key
35+
4. Locate the environment variables _AZURE_FUNCTION_URL_ and _AZURE_APP_API_BASE_URL_.
36+
5. Replace the `<FUNCTION_APP_NAME>` and `<FUNCTION_KEY>` with your actual Function App name and function key, and replace `<APP-NAME>` with your actual App Service name
3737
```env
3838
AZURE_FUNCTION_URL=https://<FUNCTION_APP_NAME>.azurewebsites.net/api/GetConversationResponse?code=<FUNCTION_KEY>
39-
39+
AZURE_APP_API_BASE_URL=https://<APP-NAME>.azurewebsites.net/
4040
```
4141
![Env](images/teams-deploy-env.png)
4242
6. Save the file.

extensions/teams/cards/cardBuilder.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import { Attachment, CardFactory } from "botbuilder";
22
import { Citation, CardType } from "../model";
3+
import config from "../config";
34

45
export function actionBuilder(citation: Citation, docId: number): any {
56

6-
const urlParts = citation.url.split("]");
7-
let url = urlParts[urlParts.length - 1].replaceAll("(", "").replaceAll(")", "");
87
let title = citation.title.replaceAll("/documents/", "");
8+
const filename = title;
9+
let fileApiUrl = `${config.getFileEndpoint}/${filename}`;
910
let content = citation.content.replaceAll(citation.title, "").replaceAll("url", "");
1011
content = content.replaceAll(/(<([^>]+)>)/ig, "\n").replaceAll("<>", "");
1112
let citationCardAction = {
@@ -37,7 +38,7 @@ export function actionBuilder(citation: Citation, docId: number): any {
3738
{
3839
type: CardType.OpenUrl,
3940
title: "Go to the source",
40-
url: decodeURI(url),
41+
url: decodeURI(fileApiUrl),
4142
}
4243
]
4344
}

extensions/teams/config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ const config = {
22
botId: process.env.BOT_ID,
33
botPassword: process.env.BOT_PASSWORD,
44
azureFunctionUrl: process.env.AZURE_FUNCTION_URL,
5+
azureAppApiBaseUrl: process.env.AZURE_APP_API_BASE_URL,
56
tenantId: process.env.TEAMS_APP_TENANT_ID,
7+
getFileEndpoint: process.env.AZURE_APP_API_BASE_URL ?
8+
`${process.env.AZURE_APP_API_BASE_URL}api/files` :
9+
null,
610
};
711

812
export default config;

extensions/teams/env/.env.dev

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ BOT_ID=
1414
TEAMS_APP_ID=
1515
BOT_AZURE_APP_SERVICE_RESOURCE_ID=
1616
BOT_DOMAIN=
17-
AZURE_FUNCTION_URL=https://backend-<RESOURCE_TOKEN>.azurewebsites.net/api/GetConversationResponse?code=<FUNCTION_APP_CLIENT_KEY>&clientId=clientKey
17+
AZURE_FUNCTION_URL=https://<FUNCTION_APP_NAME>.azurewebsites.net/api/GetConversationResponse?code=<FUNCTION_KEY>
18+
AZURE_APP_API_BASE_URL=https://<APP-NAME>.azurewebsites.net/

extensions/teams/env/.env.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ BOT_ID=
1414
TEAMS_APP_ID=
1515
BOT_AZURE_APP_SERVICE_RESOURCE_ID=
1616
BOT_DOMAIN=
17-
AZURE_FUNCTION_URL=https://backend-<RESOURCE_TOKEN>.azurewebsites.net/api/GetConversationResponse?code=<FUNCTION_APP_CLIENT_KEY>&clientId=clientKey
17+
AZURE_FUNCTION_URL=https://<FUNCTION_APP_NAME>.azurewebsites.net/api/GetConversationResponse?code=<FUNCTION_KEY>
18+
AZURE_APP_API_BASE_URL=https://<APP-NAME>.azurewebsites.net/
1819
TEAMS_APP_TENANT_ID=
1920
TEAMS_APP_PUBLISHED_APP_ID=

extensions/teams/env/.env.testtool

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ TEAMSFX_ENV=testtool
66
# Environment variables used by test tool
77
TEAMSAPPTESTER_PORT=56150
88
TEAMSFX_NOTIFICATION_STORE_FILENAME=.notification.testtoolstore.json
9-
AZURE_FUNCTION_URL=https://backend-<RESOURCE_TOKEN>.azurewebsites.net/api/GetConversationResponse?code=<FUNCTION_APP_CLIENT_KEY>&clientId=clientKey
9+
AZURE_FUNCTION_URL=https://<FUNCTION_APP_NAME>.azurewebsites.net/api/GetConversationResponse?code=<FUNCTION_KEY>
10+
AZURE_APP_API_BASE_URL=https://<APP-NAME>.azurewebsites.net/

extensions/teams/infra/azure.bicep

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ param botAadAppClientSecret string
1717
@description('Required by Bot Framework azureFunctionURL')
1818
param azureFunctionURL string
1919

20+
@description('Base URL for the Azure Web App API endpoints used for file access')
21+
param azureAppApiBaseUrl string
22+
2023
param webAppSKU string
2124

2225
@maxLength(42)
@@ -72,6 +75,10 @@ resource webApp 'Microsoft.Web/sites@2021-02-01' = {
7275
name: 'AZURE_FUNCTION_URL'
7376
value: azureFunctionURL
7477
}
78+
{
79+
name: 'AZURE_APP_API_BASE_URL'
80+
value: azureAppApiBaseUrl
81+
}
7582
{
7683
name: 'TEAMS_APP_TENANT_ID'
7784
value: botAadAppTenantId

extensions/teams/infra/azure.parameters.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,14 @@
1717
"azureFunctionURL": {
1818
"value": "${{AZURE_FUNCTION_URL}}"
1919
},
20+
"azureAppApiBaseUrl": {
21+
"value": "${{AZURE_APP_API_BASE_URL}}"
22+
},
2023
"webAppSKU": {
2124
"value": "B1"
2225
},
2326
"botDisplayName": {
2427
"value": "teams-bot-toolkit"
2528
}
2629
}
27-
}
30+
}

extensions/teams/teamsapp.local.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,4 @@ deploy:
7777
BOT_ID: ${{BOT_ID}}
7878
BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}}
7979
AZURE_FUNCTION_URL: ${{AZURE_FUNCTION_URL}}
80+
AZURE_APP_API_BASE_URL: ${{AZURE_APP_API_BASE_URL}}

extensions/teams/teamsapp.testtool.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ deploy:
2222
target: ./.localConfigs.testTool
2323
envs:
2424
TEAMSFX_NOTIFICATION_STORE_FILENAME: ${{TEAMSFX_NOTIFICATION_STORE_FILENAME}}
25-
AZURE_FUNCTION_URL: ${{AZURE_FUNCTION_URL}}
25+
AZURE_FUNCTION_URL: ${{AZURE_FUNCTION_URL}}
26+
AZURE_APP_API_BASE_URL: ${{AZURE_APP_API_BASE_URL}}

0 commit comments

Comments
 (0)