Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/microsoft/learn-microsoft-graph-connectors-dotnet
Project for the Build Microsoft Graph connectors with .NET learn module
https://github.com/microsoft/learn-microsoft-graph-connectors-dotnet
dotnet microsoft-365 microsoft-copilot microsoft-copilot-for-microsoft-365 microsoft-graph-connectors
Last synced: 3 months ago
JSON representation
Project for the Build Microsoft Graph connectors with .NET learn module
- Host: GitHub
- URL: https://github.com/microsoft/learn-microsoft-graph-connectors-dotnet
- Owner: microsoft
- License: mit
- Created: 2024-08-19T11:17:00.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-19T12:27:31.000Z (5 months ago)
- Last Synced: 2024-09-26T19:03:08.756Z (3 months ago)
- Topics: dotnet, microsoft-365, microsoft-copilot, microsoft-copilot-for-microsoft-365, microsoft-graph-connectors
- Language: C#
- Homepage: https://learn.microsoft.com/training/modules/copilot-graph-connectors/
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
- Support: SUPPORT.md
Awesome Lists containing this project
README
# Microsoft Graph connector
This project contains a [Microsoft Graph connector](https://learn.microsoft.com/graph/connecting-external-content-connectors-overview). Using Graph connectors you can import external data into Microsoft 365 and Microsoft Search. Ingested content is available to Microsoft Copilot for Microsoft 365, Microsoft Search and other Microsoft 365 services.
When developing the Graph connector, you can use [Dev Proxy](https://aka.ms/devproxy) to simulate Microsoft Graph API responses. This allows you to develop and test the connector without having to connect to the Microsoft Graph API and wait for the connection to be provisioned/removed.
## Prerequisites
- [Microsoft 365 Developer tenant](https://developer.microsoft.com/microsoft-365/dev-program)
- [.NET 8](https://dotnet.microsoft.com/download/dotnet/8.0)
- [Microsoft Graph PowerShell SDK](https://learn.microsoft.com/powershell/microsoftgraph/installation?view=graph-powershell-1.0)
- Microsoft PowerShell## Minimal path to awesome
- Create a new Microsoft Entra app registration (uses [Microsoft Graph PowerShell SDK](https://aka.ms/cli-m365)) by running `./setup.ps1`.
- Complete project
- In `ConnectionConfiguration.cs`:
- Complete schema definition
- Define URL to item resolvers (optional but recommended)
- In `ContentService.cs`:
- Update the `Document` class to match the schema you defined previously
- Implement the `Extract` method to load the content to import
- Implement the `GetDocId` method to generate a unique ID for each document
- Update the `Transform` method that convert documents from the external system into Microsoft Graph external items, with the schema you defined previously
- In `resultLayout.json`:
- Update the Adaptive Card layout to match the schema you defined previously
- Build the project: `dotnet build`
- Create connection: `dotnet run -- create-connection` (this will take several minutes)
- Load content: `dotnet run -- load-content`If you want to simulate Microsoft Graph API responses using Dev Proxy:
- [Install Dev Proxy](https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/get-started)
- Open terminal
- Change the working directory to the project root
- Start Dev Proxy: `devproxy`
- Open a new terminal
- Use the project as described above
- When finished, stop Dev Proxy:
- In the terminal where Dev Proxy is running, press `Ctrl+C` to stop Dev Proxy## Project structure
```text
.
├── .devproxy
│ └── graph-connector-mocks.json
├── .vscode
│ ├── extensions.json
│ ├── launch.json
│ └── tasks.json
├── CompleteJobWithDelayHandler.cs
├── ConnectionConfiguration.cs
├── ConnectionService.cs
├── ContentService.cs
├── DebugRequestHandler.cs
├── DebugResponseHandler.cs
├── GraphService.cs
├── MsGraphDocs.csproj
├── Program.cs
├── devproxyrc.json
├── resultLayout.json
└── setup.ps1
```### .devproxy/graph-connector-mocks.json
Dev Proxy Microsoft Graph API mocks for the Graph connector.
### .vscode
Visual Studio Code configuration files.
### CompleteJobWithDelayMiddleware.cs
Microsoft Graph SDK Middleware to handle the long-running job of provisioning the connection's schema. The middleware waits for the job to complete before continuing. It waits the recommended 60 seconds before checking the job status.
### ConnectionConfiguration.cs
Graph connector configuration. You can define the schema for the external items, the URL to the item resolvers, and the connection name.
### ConnectionService.cs
Code to create the external connection and provision the schema.
### ContentService.cs
Code to load content to import. The code is organized following the Extract-Transform-Load (ETL) principle.
### DebugRequestHandler.cs/DebugResponseHandler.cs
Microsoft Graph SDK Middleware to log requests and responses to the console. Disabled by default. Enable in the **GraphService.cs** file.
### GraphService.cs
Microsoft Graph SDK client instantiation code.
### Program.cs
Main entry point that defines the commands to create the connection and load content.
### devproxyrc.json
Dev Proxy configuration for use with the project.
### resultLayout.json
Result layout (Adaptive Card) for Microsoft Search.
### setup.ps1
Setup script to create a new Microsoft Entra app registration using Microsoft Graph PowerShell SDK. You need to install Microsoft Graph PowerShell SDK before using this script.
## Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [[email protected]](mailto:[email protected]) 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](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
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.