Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding scenario support to the Policies sample #68

Merged
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions samples/nodejs-typescript-policies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,22 @@ Version|Date|Comments
> [!NOTE]
> It can take a moment for the search results to appear. If you don't see the results immediately, wait a few moments and try again.

## Using another scenario

The sample provides 3 scenarios to ingest data into Microsoft 365: `IT Policies`, `Financial Services` and `Healthcare`. To switch between scenarios, update the `CONNECTOR_SCENARIO` environment variable in the `.env.*` file to one of the following:

- `IT Policies`: `CONNECTOR_SCENARIO=it-policies`
- `Financial Services`: `CONNECTOR_SCENARIO=financial-services`
- `Healthcare`: `CONNECTOR_SCENARIO=healthcare`

## Providing your own scenario

This sample is extensible and you can provide your own scenario. To do so, you need to:

1. Create a new folder in the `content` folder
2. Add your `md` files with the content you want to ingest
3. Update the `CONNECTOR_SCENARIO` environment variable in the `.env.*` file to the name of the folder you created

## Help

We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
Expand Down
1 change: 1 addition & 0 deletions samples/nodejs-typescript-policies/env/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ DC_NAME=Policy copilot
CONNECTOR_ID=policies
CONNECTOR_NAME=Policy Management
CONNECTOR_DESCRIPTION=Contains information about your policies.
CONNECTOR_SCENARIO=it
CONNECTOR_BASE_URL=https://localhost:3000/

# Updating Azure resources
Expand Down
9 changes: 8 additions & 1 deletion samples/nodejs-typescript-policies/env/.env.local
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ DC_NAME=Policy copilot
CONNECTOR_ID=policies
CONNECTOR_NAME=Policy Management
CONNECTOR_DESCRIPTION=Contains information about your policies.
CONNECTOR_SCENARIO=it
CONNECTOR_BASE_URL=https://localhost:3000/

# Generated during provision, you can also add your own variables.
# Generated during provision, you can also add your own variables.
APP_NAME_SUFFIX=local
AAD_APP_CLIENT_ID=7d9dd66c-1cb5-45c3-9b04-cae0124dd7b9
AAD_APP_OBJECT_ID=73af6e75-116e-48a1-a15d-c593378058a0
AAD_APP_TENANT_ID=7ebcf57d-059a-4d89-82dc-a01ce81251c2
AAD_APP_OAUTH_AUTHORITY=https://login.microsoftonline.com/7ebcf57d-059a-4d89-82dc-a01ce81251c2
AAD_APP_OAUTH_AUTHORITY_HOST=https://login.microsoftonline.com
5 changes: 5 additions & 0 deletions samples/nodejs-typescript-policies/infra/azure.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ param connectorId string
param connectorName string
param connectorDescription string
param connectorBaseUrl string
param connectorScenario string
param teamsfxEnv string
param location string = resourceGroup().location
param appServiceName string = resourceBaseName
Expand Down Expand Up @@ -128,6 +129,10 @@ resource functionApp 'Microsoft.Web/sites@2021-02-01' = {
name: 'CONNECTOR_BASE_URL'
value: connectorBaseUrl
}
{
name: 'CONNECTOR_SCENARIO'
value: connectorScenario
}
{
name: 'TEAMSFX_ENV'
value: teamsfxEnv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
"connectorBaseUrl": {
"value": "${{CONNECTOR_BASE_URL}}"
},
"connectorScenario": {
"value": "${{CONNECTOR_SCENARIO}}"
},
"teamsfxEnv": {
"value": "${{TEAMSFX_ENV}}"
}
Expand Down
3 changes: 2 additions & 1 deletion samples/nodejs-typescript-policies/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export function initConfig(context: InvocationContext): Config {
description: process.env.CONNECTOR_DESCRIPTION,
schema: schema as ExternalConnectors.Schema,
baseUrl: process.env.CONNECTOR_BASE_URL,
template: template
template: template,
scenario: process.env.CONNECTOR_SCENARIO,
}
};

Expand Down
1 change: 1 addition & 0 deletions samples/nodejs-typescript-policies/src/models/Config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export interface Config {
schema: ExternalConnectors.Schema;
baseUrl: string;
template: any;
scenario: string;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import { getItemFromDocument } from '../custom/getItemFromDocument';
*/
function extractDocuments(config: Config): GrayMatterFile<string>[] {
let content = [];
let contentFiles = fs.readdirSync('./content');
let contentFiles = fs.readdirSync(`./content/${config.connector.scenario}`);

contentFiles.forEach(f => {
if (!f.endsWith('.md')) {
return;
}

const fileContents = fs.readFileSync(path.resolve('./content', f), 'utf-8');
const fileContents = fs.readFileSync(path.resolve(`./content/${config.connector.scenario}`, f), 'utf-8');
const doc = matter(fileContents);
doc.content = removeMd(doc.content.replace(/<[^>]+>/g, ' '));
doc.data.url = new URL(doc.data.id, config.connector.baseUrl).href;
Expand Down
1 change: 1 addition & 0 deletions samples/nodejs-typescript-policies/teamsapp.local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ provision:
CONNECTOR_NAME: ${{CONNECTOR_NAME}}
CONNECTOR_DESCRIPTION: ${{CONNECTOR_DESCRIPTION}}
CONNECTOR_BASE_URL: ${{CONNECTOR_BASE_URL}}
CONNECTOR_SCENARIO: ${{CONNECTOR_SCENARIO}}
Loading