feat: Use SDK DI extension methods, migrate to Azure.Connectors.Sdk namespace#37
feat: Use SDK DI extension methods, migrate to Azure.Connectors.Sdk namespace#37
Conversation
…amespace Replace ~130 lines of manual DI boilerplate in Program.cs with SDK extension methods (AddOffice365Client, AddTeamsClient, etc.). Changes: - Program.cs: Replace 10 factory registrations with 9 one-liner extension calls - Remove Configuration/ConnectorOptions.cs (no longer needed) - Remove AzureLogAnalyticsFunctions.cs (connector deprecated in SDK) - Update namespaces: Microsoft.Azure.Connectors.DirectClient.* -> Azure.Connectors.Sdk.* - Update exception types: per-connector exceptions -> unified ConnectorException - Update exception property: StatusCode -> Status (from RequestFailedException) - Remove IsFatal() guards (made internal in SDK) - Switch from NuGet package to project reference (pending next SDK release) Depends on: Azure/Connectors-NET-SDK#117
There was a problem hiding this comment.
Pull request overview
This PR updates the DirectConnector sample to use the new Azure Connectors SDK DI extension methods (reducing DI boilerplate), migrates code to the Azure.Connectors.Sdk.* namespaces, and aligns error handling with the SDK’s unified ConnectorException.
Changes:
- Replaced manual connector client DI registrations with SDK-provided
Add*Client(...)extension methods. - Migrated connector namespaces/exceptions to
Azure.Connectors.Sdk.*andConnectorException(includingStatusCode→Status). - Removed legacy per-connector configuration options class and removed the deprecated Azure Log Analytics sample functions.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| DirectConnector/Program.cs | Switches connector client DI wiring to SDK DI extension methods driven by config sections. |
| DirectConnector/DirectConnector.csproj | Replaces the SDK NuGet dependency with a project reference (currently pointing outside the repo). |
| DirectConnector/ConnectorFunctions.cs | Migrates connector namespaces and exception handling to ConnectorException/Status. |
| DirectConnector/OneDriveFunctions.cs | Migrates connector namespaces and exception handling to ConnectorException/Status. |
| DirectConnector/Office365UsersFunctions.cs | Migrates connector namespaces and exception handling to ConnectorException/Status. |
| DirectConnector/MsGraphFunctions.cs | Migrates connector namespaces and exception handling to ConnectorException/Status. |
| DirectConnector/MqFunctions.cs | Migrates connector namespaces and exception handling to ConnectorException/Status. |
| DirectConnector/SmtpFunctions.cs | Migrates connector namespaces and exception handling to ConnectorException/Status. |
| DirectConnector/AzureBlobFunctions.cs | Migrates connector namespaces and exception handling to ConnectorException/Status. |
| DirectConnector/ConnectorTriggerMetadataAttribute.cs | Updates XML doc references to the new SDK namespace. |
| DirectConnector/Configuration/ConnectorOptions.cs | Removed (legacy options binding/validation path). |
| DirectConnector/AzureLogAnalyticsFunctions.cs | Removed (connector deprecated/removed in the SDK). |
- Replace cross-repo ProjectReference with NuGet PackageReference (0.9.0-preview.1) - Add 'when (ex is not OperationCanceledException)' filter to all catch-all blocks to preserve cancellation propagation and avoid catching fatal exceptions
|
[Dobby] Converted to draft — this PR depends on Azure/Connectors-NET-SDK#117 being merged and published as \Azure.Connectors.Sdk\ 0.9.0-preview.1 to nuget.org. CI will fail with \NU1101: Unable to find package Azure.Connectors.Sdk\ until then. Mark as ready for review after the SDK release. |
|
Closing — superseded by #40 which consolidates all SDK v0.9.0-preview.1 breaking changes, namespace migrations, and new features into a single PR. |
Summary
Replace ~130 lines of manual DI boilerplate in
Program.cswith the new SDK extension methods from Azure/Connectors-NET-SDK#117.Before (Program.cs — 164 lines)
After (Program.cs — 33 lines)
Changes
Configuration/ConnectorOptions.cs— no longer needed (was 250 lines of per-connector options classes)AzureLogAnalyticsFunctions.cs— connector deprecated in SDK, replaced byazuremonitorlogsMicrosoft.Azure.Connectors.DirectClient.*toAzure.Connectors.Sdk.*ConnectorExceptionex.StatusCodetoex.Status(fromRequestFailedException)IsFatal()guards (made internal in SDK)Net diff: +184 / -741 lines
Depends on