diff --git a/DirectConnector/AzureBlobFunctions.cs b/DirectConnector/AzureBlobFunctions.cs index 4dc8c38..4b5e920 100644 --- a/DirectConnector/AzureBlobFunctions.cs +++ b/DirectConnector/AzureBlobFunctions.cs @@ -3,8 +3,8 @@ //------------------------------------------------------------ using System.Net; -using Microsoft.Azure.Connectors.DirectClient.Azureblob; using Microsoft.Azure.Connectors.Sdk; +using Microsoft.Azure.Connectors.Sdk.Azureblob; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.Extensions.Logging; @@ -13,7 +13,7 @@ namespace DirectConnector; /// /// Azure Functions demonstrating Azure Blob Storage operations using the generated -/// from the DirectClient SDK. +/// from the Connectors SDK. /// /// /// Azure Blob Storage uses key-based auth (accountName + accessKey), not OAuth. diff --git a/DirectConnector/AzureLogAnalyticsFunctions.cs b/DirectConnector/AzureLogAnalyticsFunctions.cs deleted file mode 100644 index 04f3492..0000000 --- a/DirectConnector/AzureLogAnalyticsFunctions.cs +++ /dev/null @@ -1,158 +0,0 @@ -//------------------------------------------------------------ -// Copyright (c) Microsoft Corporation. All rights reserved. -//------------------------------------------------------------ - -using System.Net; -using Microsoft.Azure.Connectors.DirectClient.Azureloganalytics; -using Microsoft.Azure.Connectors.Sdk; -using Microsoft.Azure.Functions.Worker; -using Microsoft.Azure.Functions.Worker.Http; -using Microsoft.Extensions.Logging; - -namespace DirectConnector; - -/// -/// Azure Functions demonstrating Azure Log Analytics operations using the generated -/// from the DirectClient SDK. -/// -public class AzureLogAnalyticsFunctions -{ - private readonly ILogger _logger; - private readonly AzureloganalyticsClient _logAnalyticsClient; - - public AzureLogAnalyticsFunctions( - ILogger logger, - AzureloganalyticsClient logAnalyticsClient) - { - this._logger = logger; - this._logAnalyticsClient = logAnalyticsClient; - } - - /// - /// Lists Azure subscriptions available to the authenticated connection. - /// Demonstrates paginated enumeration via await foreach over ConnectorPageable. - /// - [Function("ListLogAnalyticsSubscriptions")] - public async Task ListSubscriptionsAsync( - [HttpTrigger(AuthorizationLevel.Function, "get", Route = "loganalytics/subscriptions")] HttpRequestData request, - CancellationToken cancellationToken) - { - this._logger.LogInformation("ListLogAnalyticsSubscriptions: Using generated AzureloganalyticsClient from SDK."); - - try - { - var subscriptions = new List(); - await foreach (var subscription in this._logAnalyticsClient - .ListSubscriptionsAsync() - .WithCancellation(cancellationToken) - .ConfigureAwait(continueOnCapturedContext: false)) - { - subscriptions.Add(subscription); - } - - var response = request.CreateResponse(HttpStatusCode.OK); - await response - .WriteAsJsonAsync(new { success = true, count = subscriptions.Count, subscriptions }, cancellationToken) - .ConfigureAwait(continueOnCapturedContext: false); - - return response; - } - catch (AzureloganalyticsConnectorException ex) - { - this._logger.LogError(ex, "ListLogAnalyticsSubscriptions failed with status '{StatusCode}'.", ex.StatusCode); - - var errorResponse = request.CreateResponse(HttpStatusCode.BadGateway); - await errorResponse - .WriteAsJsonAsync(new { success = false, error = ex.Message, statusCode = ex.StatusCode, details = ex.ResponseBody }, cancellationToken) - .ConfigureAwait(continueOnCapturedContext: false); - - return errorResponse; - } - catch (Exception ex) when (!ex.IsFatal()) - { - this._logger.LogError(ex, "Error in ListLogAnalyticsSubscriptions."); - - var errorResponse = request.CreateResponse(HttpStatusCode.InternalServerError); - await errorResponse - .WriteAsJsonAsync(new - { - success = false, - error = ex.Message - }) - .ConfigureAwait(continueOnCapturedContext: false); - - return errorResponse; - } - } - - /// - /// Lists Log Analytics workspaces in a subscription and resource group. - /// Demonstrates paginated enumeration with query parameters passed to the connector. - /// - [Function("ListLogAnalyticsWorkspaces")] - public async Task ListWorkspacesAsync( - [HttpTrigger(AuthorizationLevel.Function, "get", Route = "loganalytics/workspaces")] HttpRequestData request, - CancellationToken cancellationToken) - { - this._logger.LogInformation("ListLogAnalyticsWorkspaces: Using generated AzureloganalyticsClient from SDK."); - - var subscription = request.Query["subscription"]; - var resourceGroup = request.Query["resourceGroup"]; - - if (string.IsNullOrWhiteSpace(subscription) || string.IsNullOrWhiteSpace(resourceGroup)) - { - var badRequest = request.CreateResponse(HttpStatusCode.BadRequest); - await badRequest - .WriteAsJsonAsync(new { success = false, error = "Query parameters 'subscription' and 'resourceGroup' are required." }, cancellationToken) - .ConfigureAwait(continueOnCapturedContext: false); - - return badRequest; - } - - try - { - // Note: SDK returns ResourceGroup type for workspace entries per the connector API schema - var workspaces = new List(); - await foreach (var workspace in this._logAnalyticsClient - .ListWorkspaceNamesAsync(subscription: subscription, resourceGroup: resourceGroup) - .WithCancellation(cancellationToken) - .ConfigureAwait(continueOnCapturedContext: false)) - { - workspaces.Add(workspace); - } - - var response = request.CreateResponse(HttpStatusCode.OK); - await response - .WriteAsJsonAsync(new { success = true, count = workspaces.Count, workspaces }, cancellationToken) - .ConfigureAwait(continueOnCapturedContext: false); - - return response; - } - catch (AzureloganalyticsConnectorException ex) - { - this._logger.LogError(ex, "ListLogAnalyticsWorkspaces failed with status '{StatusCode}'.", ex.StatusCode); - - var errorResponse = request.CreateResponse(HttpStatusCode.BadGateway); - await errorResponse - .WriteAsJsonAsync(new { success = false, error = ex.Message, statusCode = ex.StatusCode, details = ex.ResponseBody }, cancellationToken) - .ConfigureAwait(continueOnCapturedContext: false); - - return errorResponse; - } - catch (Exception ex) when (!ex.IsFatal()) - { - this._logger.LogError(ex, "Error in ListLogAnalyticsWorkspaces."); - - var errorResponse = request.CreateResponse(HttpStatusCode.InternalServerError); - await errorResponse - .WriteAsJsonAsync(new - { - success = false, - error = ex.Message - }) - .ConfigureAwait(continueOnCapturedContext: false); - - return errorResponse; - } - } -} diff --git a/DirectConnector/Configuration/ConnectorOptions.cs b/DirectConnector/Configuration/ConnectorOptions.cs index 4e57886..3eddced 100644 --- a/DirectConnector/Configuration/ConnectorOptions.cs +++ b/DirectConnector/Configuration/ConnectorOptions.cs @@ -70,12 +70,6 @@ public class ConnectorOptions /// [ValidateObjectMembers] public Office365UsersOptions Office365Users { get; set; } = new Office365UsersOptions(); - - /// - /// Azure Log Analytics connector options. - /// - [ValidateObjectMembers] - public AzureLogAnalyticsOptions AzureLogAnalytics { get; set; } = new AzureLogAnalyticsOptions(); } /// @@ -248,22 +242,3 @@ public class Office365UsersOptions /// public string? ManagedIdentityClientId { get; set; } } - -/// -/// Configuration options for the Azure Log Analytics connector. -/// -public class AzureLogAnalyticsOptions -{ - /// - /// The API connection runtime URL for Azure Log Analytics. - /// - [Required(ErrorMessage = "Connectors:AzureLogAnalytics:ConnectionRuntimeUrl is required.")] - public string ConnectionRuntimeUrl { get; set; } = string.Empty; - - /// - /// Managed identity client ID for user-assigned identity. - /// Set to empty string for system-assigned managed identity. - /// Leave unset (null) to use the DefaultAzureCredential chain (CLI, env vars, etc.). - /// - public string? ManagedIdentityClientId { get; set; } -} diff --git a/DirectConnector/ConnectorFunctions.cs b/DirectConnector/ConnectorFunctions.cs index 81b52a1..3042874 100644 --- a/DirectConnector/ConnectorFunctions.cs +++ b/DirectConnector/ConnectorFunctions.cs @@ -5,20 +5,20 @@ using System.Net; using System.Text; using System.Text.Json; -using Microsoft.Azure.Connectors.DirectClient.Office365; -using Microsoft.Azure.Connectors.DirectClient.Sharepointonline; -using Microsoft.Azure.Connectors.DirectClient.Teams; using Microsoft.Azure.Connectors.Sdk; +using Microsoft.Azure.Connectors.Sdk.Office365; +using Microsoft.Azure.Connectors.Sdk.Sharepointonline; +using Microsoft.Azure.Connectors.Sdk.Teams; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.Extensions.Logging; -using SharePointBlobMetadata = Microsoft.Azure.Connectors.DirectClient.Sharepointonline.BlobMetadata; +using SharePointBlobMetadata = Microsoft.Azure.Connectors.Sdk.Sharepointonline.BlobMetadata; namespace DirectConnector; /// /// Azure Functions that use the generated , , -/// and from the DirectClient SDK. +/// and from the Connectors SDK. /// /// /// Demonstrates DI-based lifetime management, JSON deserialization for structured responses, @@ -1178,7 +1178,7 @@ await badRequest // The actual message body properties are determined at runtime by the connector's schema // discovery endpoint. With [JsonExtensionData] on AdditionalProperties, arbitrary properties // are now serialized correctly. Populate the dictionary with the expected message fields. - var messageRequest = new Microsoft.Azure.Connectors.DirectClient.Teams.DynamicPostMessageRequest(); + var messageRequest = new Microsoft.Azure.Connectors.Sdk.Teams.DynamicPostMessageRequest(); messageRequest.AdditionalProperties["recipient"] = JsonSerializer.SerializeToElement( new { diff --git a/DirectConnector/ConnectorTriggerMetadataAttribute.cs b/DirectConnector/ConnectorTriggerMetadataAttribute.cs index fd4ac8e..a9e98fc 100644 --- a/DirectConnector/ConnectorTriggerMetadataAttribute.cs +++ b/DirectConnector/ConnectorTriggerMetadataAttribute.cs @@ -34,7 +34,7 @@ public sealed class ConnectorTriggerMetadataAttribute : Attribute /// /// The trigger operation name. Use constants from the connector's *TriggerOperations class - /// (e.g., ). + /// (e.g., ). /// public string OperationName { get; set; } = ""; diff --git a/DirectConnector/DirectConnector.csproj b/DirectConnector/DirectConnector.csproj index 25131d0..0b5f1d6 100644 --- a/DirectConnector/DirectConnector.csproj +++ b/DirectConnector/DirectConnector.csproj @@ -14,7 +14,9 @@ - + + diff --git a/DirectConnector/MqFunctions.cs b/DirectConnector/MqFunctions.cs index f5a1918..435c9de 100644 --- a/DirectConnector/MqFunctions.cs +++ b/DirectConnector/MqFunctions.cs @@ -4,8 +4,8 @@ using System.Net; using System.Text.Json; -using Microsoft.Azure.Connectors.DirectClient.Mq; using Microsoft.Azure.Connectors.Sdk; +using Microsoft.Azure.Connectors.Sdk.Mq; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.Extensions.Logging; @@ -14,7 +14,7 @@ namespace DirectConnector; /// /// Azure Functions demonstrating IBM MQ operations using the generated -/// from the DirectClient SDK. +/// from the Connectors SDK. /// /// /// IBM MQ uses parameter-based auth (server, queue manager, channel, credentials). diff --git a/DirectConnector/MsGraphFunctions.cs b/DirectConnector/MsGraphFunctions.cs index 7be6cbb..8ab4554 100644 --- a/DirectConnector/MsGraphFunctions.cs +++ b/DirectConnector/MsGraphFunctions.cs @@ -3,8 +3,8 @@ //------------------------------------------------------------ using System.Net; -using Microsoft.Azure.Connectors.DirectClient.Msgraphgroupsanduser; using Microsoft.Azure.Connectors.Sdk; +using Microsoft.Azure.Connectors.Sdk.Msgraphgroupsanduser; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.Extensions.Logging; @@ -13,7 +13,7 @@ namespace DirectConnector; /// /// Azure Functions demonstrating MS Graph Groups & Users operations using the generated -/// from the DirectClient SDK. +/// from the Connectors SDK. /// /// /// Exercises user listing, group search, and group property retrieval. diff --git a/DirectConnector/Office365UsersFunctions.cs b/DirectConnector/Office365UsersFunctions.cs index d6d4d41..5d0e0af 100644 --- a/DirectConnector/Office365UsersFunctions.cs +++ b/DirectConnector/Office365UsersFunctions.cs @@ -3,8 +3,8 @@ //------------------------------------------------------------ using System.Net; -using Microsoft.Azure.Connectors.DirectClient.Office365users; using Microsoft.Azure.Connectors.Sdk; +using Microsoft.Azure.Connectors.Sdk.Office365users; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.Extensions.Logging; @@ -13,7 +13,7 @@ namespace DirectConnector; /// /// Azure Functions demonstrating Office 365 Users operations using the generated -/// from the DirectClient SDK. +/// from the Connectors SDK. /// public class Office365UsersFunctions { diff --git a/DirectConnector/OneDriveFunctions.cs b/DirectConnector/OneDriveFunctions.cs index f46dbdc..e0b9cc0 100644 --- a/DirectConnector/OneDriveFunctions.cs +++ b/DirectConnector/OneDriveFunctions.cs @@ -5,18 +5,18 @@ using System.Net; using System.Text; using System.Text.Json; -using Microsoft.Azure.Connectors.DirectClient.Onedriveforbusiness; using Microsoft.Azure.Connectors.Sdk; +using Microsoft.Azure.Connectors.Sdk.Onedriveforbusiness; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.Extensions.Logging; -using OneDriveBlobMetadata = Microsoft.Azure.Connectors.DirectClient.Onedriveforbusiness.BlobMetadata; +using OneDriveBlobMetadata = Microsoft.Azure.Connectors.Sdk.Onedriveforbusiness.BlobMetadata; namespace DirectConnector; /// /// Azure Functions demonstrating OneDrive for Business operations using the generated -/// from the DirectClient SDK. +/// from the Connectors SDK. /// /// /// Exercises folder listing, file download/upload, search, sharing links, diff --git a/DirectConnector/Program.cs b/DirectConnector/Program.cs index e88984c..f41846f 100644 --- a/DirectConnector/Program.cs +++ b/DirectConnector/Program.cs @@ -3,16 +3,15 @@ //------------------------------------------------------------ using DirectConnector.Configuration; -using Microsoft.Azure.Connectors.DirectClient.Azureblob; -using Microsoft.Azure.Connectors.DirectClient.Azureloganalytics; -using Microsoft.Azure.Connectors.DirectClient.Mq; -using Microsoft.Azure.Connectors.DirectClient.Msgraphgroupsanduser; -using Microsoft.Azure.Connectors.DirectClient.Office365; -using Microsoft.Azure.Connectors.DirectClient.Office365users; -using Microsoft.Azure.Connectors.DirectClient.Onedriveforbusiness; -using Microsoft.Azure.Connectors.DirectClient.Sharepointonline; -using Microsoft.Azure.Connectors.DirectClient.Smtp; -using Microsoft.Azure.Connectors.DirectClient.Teams; +using Microsoft.Azure.Connectors.Sdk.Azureblob; +using Microsoft.Azure.Connectors.Sdk.Mq; +using Microsoft.Azure.Connectors.Sdk.Msgraphgroupsanduser; +using Microsoft.Azure.Connectors.Sdk.Office365; +using Microsoft.Azure.Connectors.Sdk.Office365users; +using Microsoft.Azure.Connectors.Sdk.Onedriveforbusiness; +using Microsoft.Azure.Connectors.Sdk.Sharepointonline; +using Microsoft.Azure.Connectors.Sdk.Smtp; +using Microsoft.Azure.Connectors.Sdk.Teams; using Microsoft.Azure.Functions.Worker; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -145,17 +144,6 @@ options.Office365Users.ManagedIdentityClientId) : new Office365usersClient(options.Office365Users.ConnectionRuntimeUrl); }); - - services.AddSingleton(serviceProvider => - { - var options = serviceProvider.GetRequiredService>().Value; - - return options.AzureLogAnalytics.ManagedIdentityClientId != null - ? new AzureloganalyticsClient( - options.AzureLogAnalytics.ConnectionRuntimeUrl, - options.AzureLogAnalytics.ManagedIdentityClientId) - : new AzureloganalyticsClient(options.AzureLogAnalytics.ConnectionRuntimeUrl); - }); }) .Build(); diff --git a/DirectConnector/SmtpFunctions.cs b/DirectConnector/SmtpFunctions.cs index d84a1ce..1d39821 100644 --- a/DirectConnector/SmtpFunctions.cs +++ b/DirectConnector/SmtpFunctions.cs @@ -4,8 +4,8 @@ using System.Net; using System.Text.Json; -using Microsoft.Azure.Connectors.DirectClient.Smtp; using Microsoft.Azure.Connectors.Sdk; +using Microsoft.Azure.Connectors.Sdk.Smtp; using Microsoft.Azure.Functions.Worker; using Microsoft.Azure.Functions.Worker.Http; using Microsoft.Extensions.Logging; @@ -14,7 +14,7 @@ namespace DirectConnector; /// /// Azure Functions demonstrating SMTP operations using the generated -/// from the DirectClient SDK. +/// from the Connectors SDK. /// public class SmtpFunctions { diff --git a/DirectConnector/local.settings.json.template b/DirectConnector/local.settings.json.template index e068f83..2f03a50 100644 --- a/DirectConnector/local.settings.json.template +++ b/DirectConnector/local.settings.json.template @@ -38,10 +38,6 @@ "Connectors:Office365Users:ConnectionRuntimeUrl": "https://YOUR-INSTANCE.azure-apihub.net/apim/office365users/YOUR-CONNECTION-ID", "__comment_Office365Users_MSI": "To use managed identity, remove the __ prefix from the key below. Use empty string for system-assigned MSI, or a client ID GUID for user-assigned MSI.", - "__Connectors:Office365Users:ManagedIdentityClientId": "", - - "Connectors:AzureLogAnalytics:ConnectionRuntimeUrl": "https://YOUR-INSTANCE.azure-apihub.net/apim/azureloganalytics/YOUR-CONNECTION-ID", - "__comment_AzureLogAnalytics_MSI": "To use managed identity, remove the __ prefix from the key below. Use empty string for system-assigned MSI, or a client ID GUID for user-assigned MSI.", - "__Connectors:AzureLogAnalytics:ManagedIdentityClientId": "" + "__Connectors:Office365Users:ManagedIdentityClientId": "" } } diff --git a/README.md b/README.md index 24214c4..8cbc6f4 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Sample Azure Functions demonstrating the [Azure Connectors .NET SDK](https://git ## What's Inside -The `DirectConnector/` project is an Azure Functions (isolated worker) app with 40 sample functions across 10 connectors. Newer connectors have dedicated Functions classes; the original three (Office 365, SharePoint, Teams) share `ConnectorFunctions.cs`: +The `DirectConnector/` project is an Azure Functions (isolated worker) app with 38 sample functions across 9 connectors. Newer connectors have dedicated Functions classes; the original three (Office 365, SharePoint, Teams) share `ConnectorFunctions.cs`: | File | Connector | Sample Operations | |------|-----------|-------------------| @@ -17,7 +17,6 @@ The `DirectConnector/` project is an Azure Functions (isolated worker) app with | MqFunctions.cs | IBM MQ | Send, browse, receive, delete messages | | SmtpFunctions.cs | SMTP | Send email via SMTP | | AzureBlobFunctions.cs | Azure Blob Storage | Upload, download, get metadata, delete blobs | -| AzureLogAnalyticsFunctions.cs | Azure Log Analytics | List subscriptions, list workspaces | ### Key Patterns Demonstrated