You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3838fca
Browse filesBrowse the repository at this point in the historyBrowse files
Update import document tool to new auth model (microsoft#239)
### Motivation and Context
The recent changes to the authentication model in Chat Copilot
effiectively broke the import document tool. This change fixes it, by
enabling users to:
- Use the tool with an unauthenticated local instance of Chat Copilot
without signing in
- Use the tool with an Azure-deployed instance of Chat Copilot with
Azure AD authentication enabled
Fixesmicrosoft#212, fixesmicrosoft#231
### Description
<!-- Describe your changes, the overall approach, the underlying design.
These notes will help understanding how your code works. Thanks! -->
- Adds code paths to authenticate user (or not) depending on
configuration
- Removes user name/info from document import form
- Updates README with instructions for setting up the app registration
for import document tool and configuring appsettings.json
### Contribution Checklist
<!-- Before submitting this PR, please make sure: -->
- [x] The code builds clean without any errors or warnings
- [x] The PR follows the [Contribution
Guidelines](https://github.com/microsoft/copilot-chat/blob/main/CONTRIBUTING.md)
and the [pre-submission formatting
script](https://github.com/microsoft/copilot-chat/blob/main/CONTRIBUTING.md#development-scripts)
raises no violations
- [x] All unit tests pass, and I have added new tests where possible -
N/A, but both supported scenarios have been tested
- [x] I didn't break anyone 😄
Copy file name to clipboardExpand all lines: tools/importdocument/README.md
+66-17Lines changed: 66 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,24 +10,14 @@ relevant information from memories to provide more meaningful answers to users t
10
10
Memories can be generated from conversations as well as imported from external sources, such as documents.
11
11
Importing documents enables Copilot Chat to have up-to-date knowledge of specific contexts, such as enterprise and personal data.
12
12
13
-
## Configure your environment
14
13
15
-
1. A registered App in Azure Portal (https://learn.microsoft.com/azure/active-directory/develop/quickstart-register-app)
16
-
- Select Mobile and desktop applications as platform type, and the Redirect URI will be `http://localhost`
17
-
- Select **`Accounts in any organizational directory (Any Azure AD directory - Multitenant)
18
-
and personal Microsoft accounts (e.g. Skype, Xbox)`** as the supported account
19
-
type for this sample.
20
-
- Note the **`Application (client) ID`** from your app registration.
21
-
2. Make sure the service is running. To start the service, see [here](../../webapi/README.md).
22
-
23
-
## Running the app
14
+
## Running the app against a local Chat Copilot instance
24
15
25
16
1. Ensure the web api is running at `https://localhost:40443/`.
26
-
2. Configure the appsettings.json file under this folder root with the following variables and fill
27
-
in with your information, where
28
-
`ClientId` is the GUID copied from the **Application (client) ID** from your app registration in the Azure Portal,
29
-
`RedirectUri` is the Redirect URI also from the app registration in the Azure Portal, and
30
-
`ServiceUri` is the address the web api is running at.
17
+
2. Configure the appsettings.json file under this folder root with the following variables:
18
+
-`ServiceUri` is the address the web api is running at
19
+
-`AuthenticationType` should be set to "None"
20
+
- The remaining variables can be left blank or with their default values
31
21
32
22
3. Change directory to this folder root.
33
23
4.**Run** the following command to import a document to the app under the global document collection where
@@ -40,8 +30,6 @@ and personal Microsoft accounts (e.g. Skype, Xbox)`** as the supported account
40
30
41
31
`dotnet run --files .\sample-docs\ms10k.txt --chat-id [chatId]`
42
32
43
-
> Note that this will open a browser window for you to sign in to retrieve your user id to make sure you have access to the chat session.
44
-
45
33
> Currently only supports txt and pdf files. A sample file is provided under ./sample-docs.
46
34
47
35
Importing may take some time to generate embeddings for each piece/chunk of a document.
@@ -61,3 +49,64 @@ and personal Microsoft accounts (e.g. Skype, Xbox)`** as the supported account
61
49
With [Microsoft Responsible AI Standard v2 General Requirements.pdf](./sample-docs/Microsoft-Responsible-AI-Standard-v2-General-Requirements.pdf):
## Running the app against a deployed Chat Copilot instance
55
+
56
+
### Configure your environment
57
+
58
+
1. Create a registered app in Azure Portal (https://learn.microsoft.com/azure/active-directory/develop/quickstart-register-app).
59
+
60
+
> Note that this needs to be a separate app registration from those you created when deploying Chat Copilot.
61
+
62
+
- Select Mobile and desktop applications as platform type, and the Redirect URI will be `http://localhost`
63
+
- Select **`Accounts in this organizational directory only (Microsoft only - Single tenant)`** as the supported account
64
+
type for this sample.
65
+
66
+
> **IMPORTANT:** The supported account type should match that of the backend's app registration. If you changed this setting to allow allow multitenant and personal Microsoft accounts access to your Chat Copilot application, you should change it here as well.
67
+
68
+
- Note the **`Application (client) ID`** from your app registration.
69
+
70
+
2. Update the API permissions in the app registration you just created.
71
+
72
+
- From the left-hand menu, select **API permissions** and then **Add a permission**.
73
+
- Select **My APIs** and then select the application corresponding to your backend web api.
74
+
- Check the box next to `access_as_user` and then press **Add permissions**.
75
+
76
+
3. Update the authorized client applications for your backend web api.
77
+
- In the Azure portal, navigate to your backend web api's app registration.
78
+
- From the left-hand menu, select **Expose an API** and then **Add a client application**.
79
+
- Enter the client ID of the app registration you just created and check the box under **Authorized scopes**. Then press **Add application**.
80
+
81
+
4. Configure the appsettings.json file under this folder root with the following variables:
82
+
-`ServiceUri` is the address the web api is running at
83
+
-`AuthenticationType` should be set to "AzureAd"
84
+
-`ClientId` is the **Application (client) ID** GUID from the app registration you just created in the Azure Portal
85
+
-`RedirectUri` is the Redirect URI also from the app registration you just created in the Azure Portal (e.g. `http://localhost`)
86
+
-`BackendClientId` is the **Application (client) ID** GUID from your backend web api's app registration in the Azure Portal,
87
+
-`TenantId` is the Azure AD tenant ID that you want to authenticate users against. For single-tenant applications, this is the same as the **Directory (tenant) ID** from your app registration in the Azure Portal.
88
+
-`Instance` is the Azure AD cloud instance to authenticate users against. For most users, this is `https://login.microsoftonline.com`.
89
+
-`Scopes` should be set to "access_as_user"
90
+
91
+
### Run the app
92
+
93
+
1. Change directory to this folder root.
94
+
2.**Run** the following command to import a document to the app under the global document collection where
95
+
all users will have access to:
96
+
97
+
`dotnet run --files .\sample-docs\ms10k.txt`
98
+
99
+
Or **Run** the following command to import a document to the app under a chat isolated document collection where
100
+
only the chat session will have access to:
101
+
102
+
`dotnet run --files .\sample-docs\ms10k.txt --chat-id [chatId]`
103
+
104
+
> Note that both of these commands will open a browser window for you to sign in to ensure you have access to the Chat Copilot service.
105
+
106
+
> Currently only supports txt and pdf files. A sample file is provided under ./sample-docs.
107
+
108
+
Importing may take some time to generate embeddings for each piece/chunk of a document.
109
+
110
+
To import multiple files, specify multiple files. For example:
111
+
112
+
`dotnet run --files .\sample-docs\ms10k.txt .\sample-docs\Microsoft-Responsible-AI-Standard-v2-General-Requirements.pdf`
0 commit comments