Skip to content

Commit

Permalink
PnP sample improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsharepoint committed Jul 24, 2024
1 parent 1cdf8a7 commit d362a4c
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 28 deletions.
27 changes: 16 additions & 11 deletions samples/msgext-action-search-data-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,21 @@ Version|Date|Author|Comments

---
## Minimal Path to Awesome
- Create a simple [Azure Table as described here](https://learn.microsoft.com/en-us/azure/storage/tables/table-storage-quickstart-portal?WT.mc_id=M365-MVP-5004617)
- Create entities (PartitionKey becomes Id, RowKey becomes Name, Orders=int, Category=string)
- Clone the repository
```bash
git clone https://github.com/pnp/teams-dev-samples.git
- In Azure create an Azure Table and fill in the Account name into .env.local (copy from .env.dev) AZURE_TABLE_ACCOUNTNAME
- Columns: PartitionKey, RowKey, Orders, Category
- Fill in the Azure Table key into .env.local (copy from .env.dev) AZURE_TABLE_KEY
- Select the Teams Toolkit icon on the left in the VS Code toolbar.
- In the Account section, sign in with your [Microsoft 365 account](https://docs.microsoft.com/microsoftteams/platform/toolkit/accounts) if you haven't already.
- Press F5 to start debugging which launches your app in Teams using a web browser. Select `Debug in Teams (Edge)` or `Debug in Teams (Chrome)`.
- When Teams launches in the browser, select the Add button in the dialog to install your app to Teams.
- Run the Messaging Extesion from the offered Chat window
**Congratulations**! You are running an application that can now show a beautiful web page in Teams, Outlook and the Microsoft 365 app.
git clone https://github.com/mmsharepoint/msgext-action-search-data-node.git
```
- Create .env.local from .env.dev
```bash
copy .\env\.env.dev .\env\.env.local
```
- Fill in parameters from Azure Table: AZURE_TABLE_NAME, AZURE_TABLE_ACCOUNTNAME, AZURE_TABLE_ACCOUNT_KEY

- In Teams Toolkit:
1. First, select the Teams Toolkit icon on the left in the VS Code toolbar.
2. In the Account section, sign in with your [Microsoft 365 account](https://docs.microsoft.com/microsoftteams/platform/toolkit/accounts) if you haven't already.
3. Press F5 to start debugging which launches your app in Teams using a web browser. Select `Debug in Teams (Edge)` or `Debug in Teams (Chrome)`.
4. When Teams launches in the browser, select the Add button in the dialog to install your app to Teams.
5. Run the Messaging Extension from the offered Chat window
6 changes: 5 additions & 1 deletion samples/msgext-action-search-data-node/bot/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion samples/msgext-action-search-data-node/bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
"url": "https://github.com"
},
"dependencies": {
"@azure/data-tables": "^13.2.2",
"adaptive-expressions": "^4.20.0",
"adaptivecards": "^3.0.1",
"adaptivecards-templating": "^2.3.1",
"botbuilder": "^4.20.0",
"restify": "^10.0.0"
},
"devDependencies": {
"@azure/data-tables": "^13.2.2",
"@types/node": "^16.0.0",
"@types/restify": "^8.5.5",
"env-cmd": "^10.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { AzureNamedKeyCredential, TableClient } from "@azure/data-tables";
import IProduct from "../Model/IProduct";

const getTableClient = (): TableClient => {
const tableName: string = process.env.AZURE_TABLE_NAME!;
const accountName: string = process.env.AZURE_TABLE_ACCOUNTNAME!;
const storageAccountKey: string = process.env.AZURE_TABLE_KEY!;
const storageAccountKey: string = process.env.AZURE_TABLE_ACCOUNT_KEY!;
const storageUrl = `https://${accountName}.table.core.windows.net/`;
const tableClient = new TableClient(storageUrl, "Products2", new AzureNamedKeyCredential(accountName, storageAccountKey));
const tableClient = new TableClient(storageUrl, tableName, new AzureNamedKeyCredential(accountName, storageAccountKey));
return tableClient;
}

Expand Down
5 changes: 4 additions & 1 deletion samples/msgext-action-search-data-node/env/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ AAD_APP_OAUTH_AUTHORITY=
TAB_ENDPOINT=
TAB_DOMAIN=
API_FUNCTION_ENDPOINT=
API_FUNCTION_RESOURCE_ID=
API_FUNCTION_RESOURCE_ID=
AZURE_TABLE_NAME=
AZURE_TABLE_ACCOUNTNAME=
AZURE_TABLE_ACCOUNT_KEY=
6 changes: 4 additions & 2 deletions samples/msgext-action-search-data-node/teamsapp.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ deploy:
BOT_ID: ${{BOT_ID}}
BOT_PASSWORD: ${{SECRET_BOT_PASSWORD}}
TAB_ENDPOINT: ${{TAB_ENDPOINT}}
AZURE_TABLE_NAME: ${{AZURE_TABLE_NAME}}
AZURE_TABLE_ACCOUNTNAME: ${{AZURE_TABLE_ACCOUNTNAME}}
AZURE_TABLE_KEY: ${{AZURE_TABLE_KEY}}
AZURE_TABLE_ACCOUNT_KEY: ${{AZURE_TABLE_ACCOUNT_KEY}}

# Generate runtime environment variables for backend
- uses: file/createOrUpdateEnvironmentFile
Expand All @@ -190,7 +191,8 @@ deploy:
M365_TENANT_ID: ${{AAD_APP_TENANT_ID}}
M365_AUTHORITY_HOST: ${{AAD_APP_OAUTH_AUTHORITY_HOST}}
ALLOWED_APP_IDS: 1fec8e78-bce4-4aaf-ab1b-5451cc387264;5e3ce6c0-2b1f-4285-8d4b-75ee78787346;0ec893e0-5785-4de6-99da-4ed124e5296c;4345a7b9-9a63-4910-a426-35363201d503;4765445b-32c6-49b0-83e6-1d93765276ca;d3590ed6-52b3-4102-aeff-aad2292ab01c;00000002-0000-0ff1-ce00-000000000000;bc59ab01-8403-45c6-8796-ac3ef710b3e3
AZURE_TABLE_NAME: ${{AZURE_TABLE_NAME}}
AZURE_TABLE_ACCOUNTNAME: ${{AZURE_TABLE_ACCOUNTNAME}}
AZURE_TABLE_KEY: ${{AZURE_TABLE_KEY}}
AZURE_TABLE_ACCOUNT_KEY: ${{AZURE_TABLE_ACCOUNT_KEY}}


19 changes: 13 additions & 6 deletions samples/msgext-action-search-data-node/ui/api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions samples/msgext-action-search-data-node/ui/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@azure/data-tables": "^13.2.2",
"@azure/functions": "^4.0.0",
"@microsoft/microsoft-graph-client": "^3.0.1",
"@microsoft/teamsfx": "^2.0.0"
},
"devDependencies": {
"@azure/data-tables": "^13.2.2",
"@azure/functions": "^4.5.0",
"@types/node": "^18.x",
"env-cmd": "^10.1.0",
"rimraf": "^5.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { AzureNamedKeyCredential, TableClient, odata } from "@azure/data-tables"
import IProduct from "../Model/IProduct";

const getTableClient = (): TableClient => {
const tableName: string = process.env.AZURE_TABLE_NAME!;
const accountName: string = process.env.AZURE_TABLE_ACCOUNTNAME!;
const storageAccountKey: string = process.env.AZURE_TABLE_KEY!;
const storageAccountKey: string = process.env.AZURE_TABLE_ACCOUNT_KEY!;
const storageUrl = `https://${accountName}.table.core.windows.net/`;
const tableClient = new TableClient(storageUrl, "Products2", new AzureNamedKeyCredential(accountName, storageAccountKey));
const tableClient = new TableClient(storageUrl, tableName, new AzureNamedKeyCredential(accountName, storageAccountKey));
return tableClient;
}

Expand Down

0 comments on commit d362a4c

Please sign in to comment.