Skip to content

microsoftgraph/msgraph-people-connector-sample-dotnet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Microsoft 365 Copilot connector for people data sample

License.

Microsoft 365 Copilot connectors for people data allows you to enrich or extend the views of people in your tenant with your own data and have it power various Microsoft 365 experiences, including the profile card, people search and Microsoft 365 Copilot chat. This .NET applications shows you how to build a Microsoft 365 Copilot connector for people data.

NOTE: This capability is currently in public preview.

For additional details please see the Build connectors with people data article.

Configure and run the sample

Follow these instructions to configure, build and run the example.

Create an Entra ID app registration

This connector requires an Entra ID application to registered. Follow these steps to create a new Entra ID app registration for your people connector.

  1. Log in to the Azure Entra ID portal using a global administrator role.
  2. Select Applications > App registrations and click on + New registration.
  3. Type the name of your application in the Name text box. Ex ContosoHrConnector.
  4. Click Register to complete the registration.
  5. Select API Permissions and choose + Add a permission to add permissions to the app.
  6. Choose Microsoft Graph and then Application permissions and select the following permission scopes:
    1. ExternalConnection.ReadWrite.OwnedBy (required to create the connection and schema)
    2. ExternalItem.ReadWrite.OwnedBy (required to ingest people data)
    3. PeopleSettings.ReadWrite.All (required to add the connection as a profile source)
  7. Click Add Permissions and then click Grant admin consent for Contoso (replace Contoso with your organization’s name) to grant these permissions to the application. Select Yes to complete the grant.
  8. Select Certificates & secrets and create a new secret with + New client secret. Give it an appropriate description and expiry length and click Add.
  9. Note the Secret value and store it in a safe location.
  10. Click Overview and record the Application (client) ID and Directory (tenant) ID.

Tip

For production scenarios, consider modify the code and create two different applications—one to create the connection, schema, and perform the profile source registration, and another for the actual ingestion. Use Managed Identities for credentials instead of storing client secrets.

Set up authorization to Microsoft Graph

To connect the application to Microsoft Graph using the Entra ID app registration, run the following commands in the terminal window, in the src directory of the console application where you cloned or copied the sample code. Replace the client ID, tenant ID, and client secret with the values you stored in a safe location.

dotnet user-secrets init
dotnet user-secrets set settings:clientId <client-id>
dotnet user-secrets set settings:tenantId <tenant-id>
dotnet user-secrets set settings:clientSecret <client-secret>

Modify the code

Next is to modify the code to match your tenants details. All places referred to below are marked with TODO: in the sample code.

  1. Update src/appsettings.json to reflect the id and name of your connection (settings:connectorId and settings:connectorName).
  2. Update the people data in src/people.csv (or provide your own file path via --people-csv). The CSV must include a header row with these columns: UPN,Department,Position,FavoriteColor. Changes to the CSV must be reflected in PersonRecord.cs, for more information see below.
  3. Update the schema registration and the sync command in Program.cs to reflect any changes to the CSV and PersonRecord.cs.
  4. If you decide to add additional columns/properties for your people data, you must also update the schema (in the setupCommand) and the people sync logic (in the syncCommand).

Commands

This sample uses a command line interface (CLI).

  • Use dotnet run setup to create the Copilot connector using Microsoft Graph.
  • Use dotnet run register to register the connection as a source of people data.
  • Use dotnet run sync to ingest the people data into Microsoft Graph. By default it reads people.csv from the current directory; override with dotnet run sync --people-csv ./path/to/people.csv.

Keeping people.csv and PersonRecord in sync

This sample loads people data from a CSV file using the PersonRecord type as the source of truth.

How columns are determined

  • Each public, writable property on PersonRecord becomes a CSV column.
  • Column names must match property names (case-insensitive). Example: UPN maps to PersonRecord.UPN.

Supported column types

PeopleCsvLoader supports these property types (including nullable variants like int?):

  • string
  • int
  • double
  • DateTime (recommended format: ISO 8601 / round-trip, e.g. 2026-01-08T13:45:00Z)
  • bool (accepts true/false, 1/0, yes/no, y/n, t/f)

Parsing uses invariant culture. For example, use 3.14 for doubles (not 3,14).

Required vs optional columns

  • Non-nullable value types (e.g., int, bool, DateTime) are required.
  • Nullable value types (e.g., int?, bool?, DateTime?) are optional.
  • For string, non-nullable string is required and string? is optional.

If an optional column is missing from the CSV header entirely, it will be ignored and the property will keep its default value.

What to do when you change PersonRecord

When you add/rename/remove a property in PersonRecord, you should:

  1. Update the CSV header to add/rename/remove the corresponding column.
  2. Update existing CSV rows to include values for any new required columns.
  3. If the new property is meant to flow into Microsoft Graph, update:
    • the schema in the setup command, and
    • the mapping logic in the sync command.

Code of conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

About

This .NET application shows how to use the Microsoft Graph APIs to create a Microsoft 365 Copilot connector for people data

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages