From ec8e89ac7bec7d4e1cb604ae4c58debf40d5298c Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Mon, 2 Dec 2024 16:18:55 -0800 Subject: [PATCH 01/13] hid toke creds policy --- .../{RestCLient => }/TokenCredentialAuthenticationPolicy.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename sdk/cloudmachine/Azure.CloudMachine/src/Core/{RestCLient => }/TokenCredentialAuthenticationPolicy.cs (98%) diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/TokenCredentialAuthenticationPolicy.cs b/sdk/cloudmachine/Azure.CloudMachine/src/Core/TokenCredentialAuthenticationPolicy.cs similarity index 98% rename from sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/TokenCredentialAuthenticationPolicy.cs rename to sdk/cloudmachine/Azure.CloudMachine/src/Core/TokenCredentialAuthenticationPolicy.cs index 3cb1ae80ccd14..ec19184950245 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/TokenCredentialAuthenticationPolicy.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/Core/TokenCredentialAuthenticationPolicy.cs @@ -14,7 +14,7 @@ namespace Azure.AI.OpenAI; /// /// TokenCredentialAuthenticationPolicy is a pipeline policy that authenticates requests using a TokenCredential. /// -public partial class TokenCredentialAuthenticationPolicy : PipelinePolicy +internal partial class TokenCredentialAuthenticationPolicy : PipelinePolicy { private readonly TokenCredential _credential; private readonly string[] _scopes; From 0c23833dc678380f20c2de051c80762eff724f80 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Mon, 2 Dec 2024 16:26:52 -0800 Subject: [PATCH 02/13] removed CMWorkspace --- .../src/CloudMachineClient.cs | 79 ++++++++++++- .../src/CloudMachineWorkspace.cs | 104 ------------------ .../CloudMachineInfrastructure.cs | 2 +- .../TokenCredentialAuthenticationPolicy.cs | 5 +- .../src/Tooling/Azd.cs | 2 +- .../src/Tooling/CloudMachineCommands.cs | 2 +- 6 files changed, 81 insertions(+), 113 deletions(-) delete mode 100644 sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs rename sdk/cloudmachine/{Azure.CloudMachine/src/Core => Azure.Provisioning.CloudMachine/src}/TokenCredentialAuthenticationPolicy.cs (98%) diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs index 2d31947889926..6ab18683b2c26 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs @@ -1,8 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Collections.Generic; +using System.ComponentModel; using Azure.Core; +using Azure.Identity; using Microsoft.Extensions.Configuration; namespace Azure.CloudMachine; @@ -10,12 +13,25 @@ namespace Azure.CloudMachine; /// /// The cloud machine client. /// -public partial class CloudMachineClient : CloudMachineWorkspace +public partial class CloudMachineClient : ClientWorkspace { + /// + /// The cloud machine ID. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public string Id { get; } + + /// + /// subclient connections. + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public ConnectionCollection Connections { get; } = []; + /// /// Initializes a new instance of the class for mocking purposes.. /// - protected CloudMachineClient() + protected CloudMachineClient() : + this(BuildCredentail(default)) { Messaging = new MessagingServices(this); Storage = new StorageServices(this); @@ -29,8 +45,19 @@ protected CloudMachineClient() /// public CloudMachineClient(TokenCredential credential = default, IConfiguration configuration = default, IEnumerable connections = default) #pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. - : base(credential, configuration, connections) + : base(credential) { + if (connections != default) + { + Connections.AddRange(connections); + } + + Id = configuration switch + { + null => AppConfigHelpers.ReadOrCreateCloudMachineId(), + _ => configuration["CloudMachine:ID"] ?? throw new Exception("CloudMachine:ID configuration value missing") + }; + Messaging = new MessagingServices(this); Storage = new StorageServices(this); } @@ -44,4 +71,50 @@ public CloudMachineClient(TokenCredential credential = default, IConfiguration c /// Gets the storage services. /// public StorageServices Storage { get; } + + /// + /// Retrieves the connection options for a specified client type and instance ID. + /// + /// + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override ClientConnection GetConnectionOptions(string connectionId) + { + return Connections[connectionId]; + } + + private static TokenCredential BuildCredentail(TokenCredential credential) + { + if (credential == default) + { + // This environment variable is set by the CloudMachine App Service feature during provisioning. + credential = Environment.GetEnvironmentVariable("CLOUDMACHINE_MANAGED_IDENTITY_CLIENT_ID") switch + { + string clientId when !string.IsNullOrEmpty(clientId) => new ManagedIdentityCredential(clientId), + _ => new ChainedTokenCredential(new AzureCliCredential(), new AzureDeveloperCliCredential()) + }; + } + + return credential; + } + + /// + /// Reads or creates the cloud machine ID. + /// + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public static string ReadOrCreateCloudMachineId() => AppConfigHelpers.ReadOrCreateCloudMachineId(); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => base.Equals(obj); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => base.GetHashCode(); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override string ToString() => Id; } diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs deleted file mode 100644 index 500365b346fcd..0000000000000 --- a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs +++ /dev/null @@ -1,104 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.ComponentModel; -using System.Diagnostics.CodeAnalysis; -using System.IO; -using System.Text.Json; -using System.Text.Json.Nodes; -using Azure.Core; -using Azure.Identity; -using Azure.Messaging.EventGrid.SystemEvents; -using Microsoft.Extensions.Configuration; - -namespace Azure.CloudMachine; - -/// -/// The cloud machine workspace. -/// -public class CloudMachineWorkspace : ClientWorkspace -{ - /// - /// subclient connections. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public ConnectionCollection Connections { get; } = []; - - /// - /// The cloud machine ID. - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public string Id { get; } - - /// - /// Initializes a new instance of the class. - /// - /// - /// - /// - /// - [SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "")] - public CloudMachineWorkspace(TokenCredential credential = default, IConfiguration configuration = default, IEnumerable connections = default) - : base(BuildCredentail(credential)) - { - if (connections != default) - { - Connections.AddRange(connections); - } - - Id = configuration switch - { - null => AppConfigHelpers.ReadOrCreateCloudMachineId(), - _ => configuration["CloudMachine:ID"] ?? throw new Exception("CloudMachine:ID configuration value missing") - }; - } - - private static TokenCredential BuildCredentail(TokenCredential credential) - { - if (credential == default) - { - // This environment variable is set by the CloudMachine App Service feature during provisioning. - credential = Environment.GetEnvironmentVariable("CLOUDMACHINE_MANAGED_IDENTITY_CLIENT_ID") switch - { - string clientId when !string.IsNullOrEmpty(clientId) => new ManagedIdentityCredential(clientId), - _ => new ChainedTokenCredential(new AzureCliCredential(), new AzureDeveloperCliCredential()) - }; - } - - return credential; - } - - /// - /// Retrieves the connection options for a specified client type and instance ID. - /// - /// - /// - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientConnection GetConnectionOptions(string connectionId) - { - return Connections[connectionId]; - } - - /// - /// Reads or creates the cloud machine ID. - /// - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public static string ReadOrCreateCloudMachineId() => AppConfigHelpers.ReadOrCreateCloudMachineId(); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => base.Equals(obj); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => base.GetHashCode(); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override string ToString() => Id; -} diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs index 2e3c0adb91383..07a1c2dfb4933 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs @@ -43,7 +43,7 @@ public CloudMachineInfrastructure(string? cmId = default) { if (cmId == default) { - cmId = CloudMachineWorkspace.ReadOrCreateCloudMachineId(); + cmId = CloudMachineClient.ReadOrCreateCloudMachineId(); } Id = cmId; diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/Core/TokenCredentialAuthenticationPolicy.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/TokenCredentialAuthenticationPolicy.cs similarity index 98% rename from sdk/cloudmachine/Azure.CloudMachine/src/Core/TokenCredentialAuthenticationPolicy.cs rename to sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/TokenCredentialAuthenticationPolicy.cs index ec19184950245..a2d4811fc8104 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/Core/TokenCredentialAuthenticationPolicy.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/TokenCredentialAuthenticationPolicy.cs @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Azure.Core; using System; using System.ClientModel.Primitives; using System.Collections.Generic; @@ -9,7 +8,7 @@ using System.Net; using System.Threading.Tasks; -namespace Azure.AI.OpenAI; +namespace Azure.Core; /// /// TokenCredentialAuthenticationPolicy is a pipeline policy that authenticates requests using a TokenCredential. @@ -99,7 +98,7 @@ private bool IsTokenFresh() private TokenRequestContext CreateRequestContext(PipelineRequest request) { - if (request.Headers.TryGetValue("x-ms-client-request-id", out string messageClientId)) + if (request.Headers.TryGetValue("x-ms-client-request-id", out string? messageClientId)) { return new TokenRequestContext(_scopes, messageClientId); } diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/Azd.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/Azd.cs index 9f5fcc7a1727d..387ed6fbbca00 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/Azd.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/Azd.cs @@ -32,7 +32,7 @@ public static void Init(CloudMachineInfrastructure infra, string? infraDirectory Directory.CreateDirectory(infraDirectory); infra.Build().Save(infraDirectory); - var cmid = CloudMachineWorkspace.ReadOrCreateCloudMachineId(); + var cmid = CloudMachineClient.ReadOrCreateCloudMachineId(); // main.bicep var location = new ProvisioningParameter("location", typeof(string)); diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs index 4685dda5683e5..63c4a9c0a3002 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs @@ -20,7 +20,7 @@ public static bool Execute(string[] args, Action? co if (args.Length < 1) return false; - string cmid = CloudMachineWorkspace.ReadOrCreateCloudMachineId(); + string cmid = CloudMachineClient.ReadOrCreateCloudMachineId(); CloudMachineInfrastructure cmi = new(cmid); if (configure != default) { From ab37175d373e89b4028e3740b3f150fa6b489167 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Mon, 2 Dec 2024 16:30:19 -0800 Subject: [PATCH 03/13] moved ConnectionCollection to Azure.Core --- .../Azure.CloudMachine/src/ConnectionCollection.cs | 3 +-- sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs | 1 + .../src/CloudMachineInfrastructure/CloudMachineFeature.cs | 1 + .../CloudMachineInfrastructure/CloudMachineInfrastructure.cs | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/ConnectionCollection.cs b/sdk/cloudmachine/Azure.CloudMachine/src/ConnectionCollection.cs index 1a5087da74e34..5bad8d7014f44 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/ConnectionCollection.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/ConnectionCollection.cs @@ -6,9 +6,8 @@ using System.Collections.ObjectModel; using System.Text.Json; using System.Text.Json.Serialization; -using Azure.Core; -namespace Azure.CloudMachine; +namespace Azure.Core; /// /// Represents the connection options for a client. diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs b/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs index 33e28a6dbde7c..a88fc124ef4a9 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs @@ -8,6 +8,7 @@ using System.Text.Json; using Azure.CloudMachine.KeyVault; using Azure.CloudMachine.OpenAI; +using Azure.Core; using Azure.Storage.Blobs; using NUnit.Framework; using OpenAI.Chat; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineFeature.cs index a43077e5db0b2..2b1b01d2f9979 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineFeature.cs @@ -5,6 +5,7 @@ using System.Collections.Generic; using System.ComponentModel; using Azure.CloudMachine; +using Azure.Core; using Azure.Provisioning.Primitives; namespace Azure.Provisioning.CloudMachine; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs index 07a1c2dfb4933..ba6d3bbeac4d4 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using Azure.Core; using Azure.Provisioning; using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Expressions; From 44e064dea706a82bf113d8725879a3b95eb7e8b5 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Mon, 2 Dec 2024 16:41:29 -0800 Subject: [PATCH 04/13] moved CM abstractions to Azure.CloudMachine.Core namespace --- .../src/CloudMachineClientExtensions.cs | 2 +- .../src/CloudMachineInfrastructure/CloudMachineFeature.cs | 3 +-- .../CloudMachineInfrastructure/CloudMachineInfrastructure.cs | 2 +- .../src/CloudMachineInfrastructure/FeatureCollection.cs | 3 +-- .../src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs | 1 - .../src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs | 1 - .../src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs | 2 +- .../src/FeaturesBuiltIn/ServiceBusTopicFeature.cs | 2 +- .../src/FeaturesBuiltIn/StorageAccountFeature.cs | 4 ---- .../FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs | 2 +- .../src/FeaturesExtensions/AppServiceFeature.cs | 2 +- .../src/FeaturesExtensions/KeyVaultFeature.cs | 3 +-- .../src/FeaturesExtensions/OpenAIFeature.cs | 5 ++--- .../src/FeaturesExtensions/OpenAIModelFeature.cs | 3 +-- 14 files changed, 12 insertions(+), 23 deletions(-) diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineClientExtensions.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineClientExtensions.cs index 7559dd4437623..930f78272650f 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineClientExtensions.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineClientExtensions.cs @@ -3,8 +3,8 @@ using System; using System.ComponentModel; +using Azure.CloudMachine.Core; using Azure.Core; -using Azure.Provisioning.CloudMachine; namespace Azure.CloudMachine; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineFeature.cs index 2b1b01d2f9979..ef8f00503640b 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineFeature.cs @@ -4,11 +4,10 @@ using System; using System.Collections.Generic; using System.ComponentModel; -using Azure.CloudMachine; using Azure.Core; using Azure.Provisioning.Primitives; -namespace Azure.Provisioning.CloudMachine; +namespace Azure.CloudMachine.Core; public abstract class CloudMachineFeature { diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs index ba6d3bbeac4d4..498a450396077 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs @@ -4,9 +4,9 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using Azure.CloudMachine.Core; using Azure.Core; using Azure.Provisioning; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Expressions; using Azure.Provisioning.Primitives; using Azure.Provisioning.Roles; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/FeatureCollection.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/FeatureCollection.cs index 07e24da9bd102..3780ed615f758 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/FeatureCollection.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/FeatureCollection.cs @@ -5,10 +5,9 @@ using System.Collections; using System.Collections.Generic; using System.Linq; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Primitives; -namespace Azure.CloudMachine; +namespace Azure.CloudMachine.Core; public class FeatureCollection : IEnumerable { diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs index 5f331be310e44..122ad3a60505c 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using Azure.CloudMachine.Core; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.EventGrid; using Azure.Provisioning.Expressions; using Azure.Provisioning.Primitives; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs index 749b82feadb4a..4c06295240500 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs @@ -3,7 +3,6 @@ using Azure.CloudMachine.Core; using Azure.Core; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Primitives; using Azure.Provisioning.ServiceBus; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs index dd757020c1844..e10600ad849be 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs @@ -2,8 +2,8 @@ // Licensed under the MIT License. using System; +using Azure.CloudMachine.Core; using Azure.Core; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Primitives; using Azure.Provisioning.ServiceBus; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusTopicFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusTopicFeature.cs index e547085e41375..0eb9c596bd196 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusTopicFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusTopicFeature.cs @@ -2,8 +2,8 @@ // Licensed under the MIT License. using System; +using Azure.CloudMachine.Core; using Azure.Core; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Primitives; using Azure.Provisioning.ServiceBus; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/StorageAccountFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/StorageAccountFeature.cs index 772ba9c7eaeb5..773e574d81355 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/StorageAccountFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/StorageAccountFeature.cs @@ -1,12 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System.Collections.Generic; -using System.Linq; using Azure.CloudMachine.Core; using Azure.Core; -using Azure.Provisioning; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Expressions; using Azure.Provisioning.Primitives; using Azure.Provisioning.Resources; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs index ffc8fe92c4ee0..1880fd1b98a4c 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.CloudMachine.Core; using Azure.Provisioning.Authorization; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.EventGrid; using Azure.Provisioning.Expressions; using Azure.Provisioning.Primitives; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/AppServiceFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/AppServiceFeature.cs index 83d771f27482c..4f9a308b1b6ee 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/AppServiceFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/AppServiceFeature.cs @@ -1,11 +1,11 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Expressions; using Azure.Provisioning.AppService; using Azure.Provisioning.Primitives; using Azure.Provisioning.Resources; +using Azure.CloudMachine.Core; namespace Azure.CloudMachine.AppService; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/KeyVaultFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/KeyVaultFeature.cs index 1e52c9d79ce2a..6b366260ec53c 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/KeyVaultFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/KeyVaultFeature.cs @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; +using Azure.CloudMachine.Core; using Azure.Core; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.Expressions; using Azure.Provisioning.KeyVault; using Azure.Provisioning.Primitives; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/OpenAIFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/OpenAIFeature.cs index 8ce12b0bf57a5..0e2a32898aa36 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/OpenAIFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/OpenAIFeature.cs @@ -1,9 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using System.Collections.Generic; + +using Azure.CloudMachine.Core; using Azure.Core; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.CognitiveServices; using Azure.Provisioning.Primitives; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/OpenAIModelFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/OpenAIModelFeature.cs index 6efcbd3b98924..01f6e33cdcb5d 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/OpenAIModelFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesExtensions/OpenAIModelFeature.cs @@ -2,10 +2,9 @@ // Licensed under the MIT License. using System; -using System.Diagnostics; using System.Linq; +using Azure.CloudMachine.Core; using Azure.Core; -using Azure.Provisioning.CloudMachine; using Azure.Provisioning.CognitiveServices; using Azure.Provisioning.Primitives; From 5a7f5bd6fa630dc6b59b0992a9370c84500661b3 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Tue, 3 Dec 2024 09:20:21 -0800 Subject: [PATCH 05/13] cleaned up namespaces --- .../src/Core/RestCLient/RestCallFailedException.cs | 2 +- .../src/Core/RestCLient/RestClient.cs | 2 +- .../src/Core/RestCLient/RestClientOptions.cs | 2 +- .../Azure.CloudMachine/src/GlobalSuppressions.cs | 5 ++--- .../CloudMachineInfrastructure.cs | 3 +++ .../src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs | 6 ++++-- .../src/FeaturesBuiltIn/InternalConstants.cs | 10 ---------- .../src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs | 4 ++-- .../FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs | 4 ++-- .../src/FeaturesBuiltIn/ServiceBusTopicFeature.cs | 4 ++-- .../src/FeaturesBuiltIn/StorageAccountFeature.cs | 2 +- .../SystemTopicEventSubscriptionFeature.cs | 3 ++- .../src/Tooling/CloudMachineCommands.cs | 2 +- 13 files changed, 22 insertions(+), 27 deletions(-) delete mode 100644 sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/InternalConstants.cs diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestCallFailedException.cs b/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestCallFailedException.cs index 22d7a0c98243c..91ebad31292f2 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestCallFailedException.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestCallFailedException.cs @@ -4,7 +4,7 @@ using System; using System.ClientModel.Primitives; -namespace Azure +namespace Azure.Core.Rest { /// /// Exception thrown when a REST call fails. diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestClient.cs b/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestClient.cs index 648044c383817..6ecbb64c72ca1 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestClient.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestClient.cs @@ -5,7 +5,7 @@ using System.ClientModel.Primitives; using System.ClientModel; -namespace Azure +namespace Azure.Core.Rest { /// /// A simple REST client that sends HTTP requests and receives responses. diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestClientOptions.cs b/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestClientOptions.cs index daa6df9758e40..d44bb2dea92fe 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestClientOptions.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/Core/RestCLient/RestClientOptions.cs @@ -3,7 +3,7 @@ using System.ClientModel.Primitives; -namespace Azure +namespace Azure.Core.Rest { /// /// Options for the REST client. diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/GlobalSuppressions.cs b/sdk/cloudmachine/Azure.CloudMachine/src/GlobalSuppressions.cs index 57ea0ca077129..8bb710807d489 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/GlobalSuppressions.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/GlobalSuppressions.cs @@ -2,6 +2,5 @@ // Licensed under the MIT License. using System.Diagnostics.CodeAnalysis; - -[assembly: SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "", Scope = "member", Target = "~M:Azure.RestClient.#ctor")] -[assembly: SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "", Scope = "member", Target = "~M:Azure.RestClient.#ctor(System.ClientModel.Primitives.PipelinePolicy)")] +[assembly: SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "", Scope = "member", Target = "~M:Azure.Core.Rest.RestClient.#ctor")] +[assembly: SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "", Scope = "member", Target = "~M:Azure.Core.Rest.RestClient.#ctor(System.ClientModel.Primitives.PipelinePolicy)")] diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs index 498a450396077..635077968ca14 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs @@ -5,6 +5,9 @@ using System.Collections.Generic; using System.ComponentModel; using Azure.CloudMachine.Core; +using Azure.CloudMachine.EventGrid; +using Azure.CloudMachine.ServiceBus; +using Azure.CloudMachine.Storage; using Azure.Core; using Azure.Provisioning; using Azure.Provisioning.Expressions; diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs index 122ad3a60505c..14723c51c54d0 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/EventGridSystemTopicFeature.cs @@ -8,13 +8,15 @@ using Azure.Provisioning.Resources; using Azure.Provisioning.Storage; -namespace Azure.CloudMachine; +namespace Azure.CloudMachine.EventGrid; internal class EventGridSystemTopicFeature(string topicName, CloudMachineFeature source, string topicType) : CloudMachineFeature { + internal const string EventGridTopicVersion = "2022-06-15"; + protected override ProvisionableResource EmitResources(CloudMachineInfrastructure infrastructure) { - var topic = new SystemTopic("cm_eventgrid_topic", InternalConstants.EventGridTopicVersion) + var topic = new SystemTopic("cm_eventgrid_topic", EventGridTopicVersion) { TopicType = topicType, Source = EnsureEmits(source).Id, diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/InternalConstants.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/InternalConstants.cs deleted file mode 100644 index 6387aa81b0015..0000000000000 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/InternalConstants.cs +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -namespace Azure.CloudMachine.Core -{ - internal static class InternalConstants - { - internal const string EventGridTopicVersion = "2022-06-15"; - } -} diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs index 4c06295240500..9df3f86fa3bc6 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusNamespaceFeature.cs @@ -6,9 +6,9 @@ using Azure.Provisioning.Primitives; using Azure.Provisioning.ServiceBus; -namespace Azure.CloudMachine; +namespace Azure.CloudMachine.ServiceBus; -public class ServiceBusNamespaceFeature(string name, ServiceBusSkuName sku = ServiceBusSkuName.Standard, ServiceBusSkuTier tier = ServiceBusSkuTier.Standard) : CloudMachineFeature +internal class ServiceBusNamespaceFeature(string name, ServiceBusSkuName sku = ServiceBusSkuName.Standard, ServiceBusSkuTier tier = ServiceBusSkuTier.Standard) : CloudMachineFeature { protected override ProvisionableResource EmitResources(CloudMachineInfrastructure infrastructure) { diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs index e10600ad849be..72bacde5671fa 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusSubscriptionFeature.cs @@ -7,9 +7,9 @@ using Azure.Provisioning.Primitives; using Azure.Provisioning.ServiceBus; -namespace Azure.CloudMachine; +namespace Azure.CloudMachine.ServiceBus; -public class ServiceBusSubscriptionFeature(string name, ServiceBusTopicFeature parent) : CloudMachineFeature +internal class ServiceBusSubscriptionFeature(string name, ServiceBusTopicFeature parent) : CloudMachineFeature { protected override ProvisionableResource EmitResources(CloudMachineInfrastructure infrastructure) { diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusTopicFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusTopicFeature.cs index 0eb9c596bd196..77a72f98b5005 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusTopicFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/ServiceBusTopicFeature.cs @@ -7,9 +7,9 @@ using Azure.Provisioning.Primitives; using Azure.Provisioning.ServiceBus; -namespace Azure.CloudMachine; +namespace Azure.CloudMachine.ServiceBus; -public class ServiceBusTopicFeature : CloudMachineFeature +internal class ServiceBusTopicFeature : CloudMachineFeature { public ServiceBusTopicFeature(string name, ServiceBusNamespaceFeature parent) { diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/StorageAccountFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/StorageAccountFeature.cs index 773e574d81355..86c6714dfd3b7 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/StorageAccountFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/StorageAccountFeature.cs @@ -8,7 +8,7 @@ using Azure.Provisioning.Resources; using Azure.Provisioning.Storage; -namespace Azure.CloudMachine; +namespace Azure.CloudMachine.Storage; internal class StorageAccountFeature : CloudMachineFeature { diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs index 1880fd1b98a4c..3a5d158980e5f 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/FeaturesBuiltIn/SystemTopicEventSubscriptionFeature.cs @@ -2,13 +2,14 @@ // Licensed under the MIT License. using Azure.CloudMachine.Core; +using Azure.CloudMachine.ServiceBus; using Azure.Provisioning.Authorization; using Azure.Provisioning.EventGrid; using Azure.Provisioning.Expressions; using Azure.Provisioning.Primitives; using Azure.Provisioning.ServiceBus; -namespace Azure.CloudMachine; +namespace Azure.CloudMachine.EventGrid; internal class SystemTopicEventSubscriptionFeature(string name, EventGridSystemTopicFeature parent, ServiceBusTopicFeature destination, ServiceBusNamespaceFeature parentNamespace) : CloudMachineFeature { diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs index 63c4a9c0a3002..164710e153320 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs @@ -7,8 +7,8 @@ using System.Collections.Generic; using System.IO; using System.Text.Json; -using Azure.AI.OpenAI; using Azure.Core; +using Azure.Core.Rest; using Azure.Identity; namespace Azure.CloudMachine; From 7b2b6a0b04b876b8183ad8ce82875cef4044d366 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Wed, 4 Dec 2024 09:34:50 -0800 Subject: [PATCH 06/13] redesigned commands such that they work with extension connections --- .../src/CloudMachineClient.cs | 2 +- .../tests/ConnectionTests.cs | 15 -------------- .../tests/GettingStarted.cs | 9 ++++----- .../src/CloudMachineClientExtensions.cs | 2 +- .../src/Tooling/CloudMachineCommands.cs | 20 ++++--------------- .../tests/CommandsTests.cs | 12 ++++++++++- 6 files changed, 21 insertions(+), 39 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs index 6ab18683b2c26..75745f0b9f606 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs @@ -45,7 +45,7 @@ protected CloudMachineClient() : /// public CloudMachineClient(TokenCredential credential = default, IConfiguration configuration = default, IEnumerable connections = default) #pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. - : base(credential) + : base(BuildCredentail(credential)) { if (connections != default) { diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs b/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs index a88fc124ef4a9..2cdad4d3d58f6 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs @@ -6,7 +6,6 @@ using System; using System.Linq; using System.Text.Json; -using Azure.CloudMachine.KeyVault; using Azure.CloudMachine.OpenAI; using Azure.Core; using Azure.Storage.Blobs; @@ -63,20 +62,6 @@ public void SingleClientAdd(string[] args) ChatClient chat = client.GetOpenAIChatClient(); } - [Test] - public void SingleClientConfigure() - { - CloudMachineClient client = new(); - client.Configure((infrastructure) => - { - infrastructure.AddFeature(new KeyVaultFeature()); - infrastructure.AddFeature(new OpenAIModelFeature("gpt-35-turbo", "0125")); - infrastructure.AddFeature(new OpenAIModelFeature("text-embedding-ada-002", "2", AIModelKind.Embedding)); - }); - ValidateClient(client); - var embeddings = client.GetOpenAIEmbeddingsClient(); - } - private static void ValidateClient(CloudMachineClient client) { ChatClient chat = client.GetOpenAIChatClient(); diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs b/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs index ee097e04ba377..1eccdc10f6262 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs @@ -17,16 +17,15 @@ public partial class CloudMachineTests [TestCase([new string[] { "-azd" }])] public void GettingStarted(string[] args) { - CloudMachineInfrastructure infra = new(); - infra.AddFeature(new OpenAIModelFeature("gpt-35-turbo", "0125")); + CloudMachineInfrastructure cm = new(); + cm.AddFeature(new OpenAIModelFeature("gpt-35-turbo", "0125")); if (args.Contains("-azd")) { - Azd.Init(infra); + Azd.Init(cm); return; } - // TODO: we need to allow newing up the client. - CloudMachineClient client = infra.GetClient(); + CloudMachineClient client = new(connections: cm.Connections); ChatClient chat = client.GetOpenAIChatClient(); string completion = chat.CompleteChat("List all noble gases.").AsText(); diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineClientExtensions.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineClientExtensions.cs index 930f78272650f..c735cc00e4258 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineClientExtensions.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineClientExtensions.cs @@ -10,7 +10,7 @@ namespace Azure.CloudMachine; public static class CloudMachineClientExtensions { - public static void Configure(this CloudMachineClient client, Action? configure = default) + private static void Configure(this CloudMachineClient client, Action? configure = default) { CloudMachineInfrastructure cmi = new(client.Id); if (configure != default) diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs index 164710e153320..a0116c5cf75cf 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs @@ -15,45 +15,33 @@ namespace Azure.CloudMachine; public static class CloudMachineCommands { - public static bool Execute(string[] args, Action? configure = default, bool exitProcessIfHandled = true) + public static bool TryExecuteCommand(this CloudMachineInfrastructure cmi, string[] args) { if (args.Length < 1) return false; string cmid = CloudMachineClient.ReadOrCreateCloudMachineId(); - CloudMachineInfrastructure cmi = new(cmid); - if (configure != default) - { - configure(cmi); - } if (args[0] == "-bicep") { Azd.Init(cmi); - return Handled(exitProcessIfHandled); + return true; } if (args[0] == "-tsp") { GenerateTsp(cmi.Endpoints); - return Handled(exitProcessIfHandled); + return true; } if (args[0] == "-ai") { string? option = (args.Length > 1) ? args[1] : default; ListAzureOpenaAIModels(cmid, option); - return Handled(exitProcessIfHandled); + return true; } return false; - - static bool Handled(bool exitProcessIfHandled) - { - if (exitProcessIfHandled) - Environment.Exit(0); - return true; - } } // this implements: https://learn.microsoft.com/en-us/rest/api/azureopenai/models/list diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/tests/CommandsTests.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/tests/CommandsTests.cs index 0afa31a6a375e..c6f116e99def1 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/tests/CommandsTests.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/tests/CommandsTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.CloudMachine.KeyVault; using NUnit.Framework; namespace Azure.CloudMachine.Tests; @@ -11,6 +12,15 @@ public class CommandsTests [Test] public void ListModels() { - CloudMachineCommands.Execute(["-ai", "chat"], exitProcessIfHandled: false); + CloudMachineInfrastructure cm = new(); + cm.TryExecuteCommand(["-ai", "chat"]); + } + + [Test] + public void GenerateBicep() + { + CloudMachineInfrastructure cm = new(); + cm.AddFeature(new KeyVaultFeature()); + cm.TryExecuteCommand(["-bicep"]); } } From 524f93a912f32c38d0340ebfcdb5eccef4bf792c Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Wed, 4 Dec 2024 09:40:00 -0800 Subject: [PATCH 07/13] merged --- .../Azure.CloudMachine/tests/GettingStarted.cs | 8 ++------ .../src/Tooling/CloudMachineCommands.cs | 2 +- .../tests/CommandsTests.cs | 3 ++- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs b/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs index 1eccdc10f6262..cf5db682e3424 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs @@ -19,13 +19,9 @@ public void GettingStarted(string[] args) { CloudMachineInfrastructure cm = new(); cm.AddFeature(new OpenAIModelFeature("gpt-35-turbo", "0125")); + if (cm.TryExecuteCommand(args)) return; - if (args.Contains("-azd")) { - Azd.Init(cm); - return; - } - - CloudMachineClient client = new(connections: cm.Connections); + CloudMachineClient client = cm.GetClient(); ChatClient chat = client.GetOpenAIChatClient(); string completion = chat.CompleteChat("List all noble gases.").AsText(); diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs index 7bb6368562b83..9419d1d65a6fb 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tooling/CloudMachineCommands.cs @@ -38,7 +38,7 @@ public static bool TryExecuteCommand(this CloudMachineInfrastructure cmi, string projName = args[1]; } Azd.InitDeployment(cmi, projName); - return Handled(exitProcessIfHandled); + return true; } if (args[0] == "-tsp") diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/tests/CommandsTests.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/tests/CommandsTests.cs index dfd8fcbd44a08..c0bd9d479a060 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/tests/CommandsTests.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/tests/CommandsTests.cs @@ -27,6 +27,7 @@ public void GenerateBicep() [Test] public void DoInit() { - CloudMachineCommands.Execute(["-init", "demo.csproj"], exitProcessIfHandled: false); + CloudMachineInfrastructure cm = new(); + cm.TryExecuteCommand(["-init", "demo.csproj"]); } } From 5f96f221fcd62f032f1f58dbc6c63452cd57fc44 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Wed, 4 Dec 2024 09:42:45 -0800 Subject: [PATCH 08/13] fixed tests --- sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs b/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs index cf5db682e3424..2e78760aec04f 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/GettingStarted.cs @@ -13,8 +13,7 @@ namespace Azure.CloudMachine.Tests; public partial class CloudMachineTests { - [Test] - [TestCase([new string[] { "-azd" }])] + [TestCase([new string[] { "-bicep" }])] public void GettingStarted(string[] args) { CloudMachineInfrastructure cm = new(); From 5f862aad715b7bf1ac7193a18d3c842edc096969 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Wed, 4 Dec 2024 09:55:10 -0800 Subject: [PATCH 09/13] small cleanup --- sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs | 2 ++ .../Azure.Provisioning.CloudMachine/src/Tsp/TypeSpecWriter.cs | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs index 75745f0b9f606..aba7d9aaa3796 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs @@ -36,6 +36,7 @@ protected CloudMachineClient() : Messaging = new MessagingServices(this); Storage = new StorageServices(this); } + #pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. /// /// Initializes a new instance of the class. @@ -43,6 +44,7 @@ protected CloudMachineClient() : /// The token credential. /// The configuration settings. /// + // TODO: we need to combine the configuration and the connections into a single parameter. public CloudMachineClient(TokenCredential credential = default, IConfiguration configuration = default, IEnumerable connections = default) #pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. : base(BuildCredentail(credential)) diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tsp/TypeSpecWriter.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tsp/TypeSpecWriter.cs index 2b1c6af5713b5..5aa90be3907c4 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tsp/TypeSpecWriter.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/Tsp/TypeSpecWriter.cs @@ -240,8 +240,7 @@ private static string ToTspType(this Type type) if (type == typeof(double)) return "float64"; - // TODO: - // return "safeint" if long is attributed with [SafeInt] + // TODO: return "safeint" if long is attributed with [SafeInt] // arrays if (type.IsClass) From cbb0a0650b9ec26d21322af91b31583d6740e71d Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Thu, 5 Dec 2024 10:32:26 -0800 Subject: [PATCH 10/13] configuration system works --- .../src/CloudMachineClient.cs | 46 ++++-- .../src/CloudMachineClientConfiguration.cs | 143 ++++++++++++++++++ .../src/ConnectionCollection.cs | 16 ++ .../tests/Azure.CloudMachine.Tests.csproj | 1 + .../tests/CloudMachineTests_rag.cs | 2 +- .../tests/ConnectionTests.cs | 44 +++++- .../CloudMachineInfrastructure.cs | 17 +++ .../src/GlobalSuppressions.cs | 2 +- 8 files changed, 258 insertions(+), 13 deletions(-) create mode 100644 sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClientConfiguration.cs diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs index aba7d9aaa3796..23927d4c22c39 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs @@ -2,7 +2,6 @@ // Licensed under the MIT License. using System; -using System.Collections.Generic; using System.ComponentModel; using Azure.Core; using Azure.Identity; @@ -31,8 +30,9 @@ public partial class CloudMachineClient : ClientWorkspace /// Initializes a new instance of the class for mocking purposes.. /// protected CloudMachineClient() : - this(BuildCredentail(default)) + this(credential: BuildCredentail(default)) { + Id = AppConfigHelpers.ReadOrCreateCloudMachineId(); Messaging = new MessagingServices(this); Storage = new StorageServices(this); } @@ -41,11 +41,42 @@ protected CloudMachineClient() : /// /// Initializes a new instance of the class. /// - /// The token credential. /// The configuration settings. + /// The token credential. + // TODO: we need to combine the configuration and the connections into a single parameter. + public CloudMachineClient(IConfiguration configuration, TokenCredential credential = default) +#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + : base(BuildCredentail(credential)) + { + Id = configuration["CloudMachine:ID"]; + if (Id == null) + { + Id = AppConfigHelpers.ReadOrCreateCloudMachineId(); + } + + IConfigurationSection connectionsSection = configuration.GetSection("CloudMachine:Connections"); + + foreach (IConfigurationSection connection in connectionsSection.GetChildren()) + { + string id = connection["Id"]; + if (id == null) continue; + string locator = connection["Locator"]; + + Connections.Add(new ClientConnection(id, locator, ClientAuthenticationMethod.EntraId)); + } + + Messaging = new MessagingServices(this); + Storage = new StorageServices(this); + } + +#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + /// + /// Initializes a new instance of the class. + /// /// + /// The token credential. // TODO: we need to combine the configuration and the connections into a single parameter. - public CloudMachineClient(TokenCredential credential = default, IConfiguration configuration = default, IEnumerable connections = default) + public CloudMachineClient(ConnectionCollection connections = default, TokenCredential credential = default) #pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. : base(BuildCredentail(credential)) { @@ -54,12 +85,7 @@ public CloudMachineClient(TokenCredential credential = default, IConfiguration c Connections.AddRange(connections); } - Id = configuration switch - { - null => AppConfigHelpers.ReadOrCreateCloudMachineId(), - _ => configuration["CloudMachine:ID"] ?? throw new Exception("CloudMachine:ID configuration value missing") - }; - + Id = AppConfigHelpers.ReadOrCreateCloudMachineId(); Messaging = new MessagingServices(this); Storage = new StorageServices(this); } diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClientConfiguration.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClientConfiguration.cs new file mode 100644 index 0000000000000..ba088a7744e24 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClientConfiguration.cs @@ -0,0 +1,143 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Collections.Generic; +using System; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Primitives; +using System.Linq; + +namespace Azure.Core; + +/// +/// extensions. +/// +public static class CloudMachineClientConfiguration +{ + /// + /// Adds a connection to the collection. + /// + /// + /// + /// + public static IConfigurationBuilder AddCloudMachineConnections(this IConfigurationBuilder builder, ConnectionCollection connections) + { + var source = new ConnectionCollectionConfigurationSource(connections); + builder.Add(source); + return builder; + } + /// + /// Adds a connection to the collection. + /// + /// + /// + /// + public static IConfigurationBuilder AddCloudMachineId(this IConfigurationBuilder builder, string cmid) + { + var source = new CmidConfigurationSource(cmid); + builder.Add(source); + return builder; + } +} + +internal class ConnectionCollectionConfigurationProvider : IConfigurationProvider +{ + private readonly ConnectionCollection _connections; + public ConnectionCollectionConfigurationProvider(ConnectionCollection connections) + => _connections = connections; + + public IEnumerable GetChildKeys(IEnumerable earlierKeys, string parentPath) + { + foreach (string earlierKey in earlierKeys) + { + yield return earlierKey; + } + foreach (ClientConnection connection in _connections) + { + yield return connection.Id; + } + } + + public IChangeToken GetReloadToken() => null; + public void Load() { } + public void Set(string key, string value) => throw new NotImplementedException(); + public bool TryGet(string key, out string value) + { + string[] path = key.Split(':'); + + if (path.Length != 4 || + !path[0].Equals("CloudMachine", StringComparison.InvariantCultureIgnoreCase) || + !path[1].Equals("Connections", StringComparison.InvariantCultureIgnoreCase)) + { + value = null; + return false; + } + + if (!_connections.Contains(path[2])) + { + value = null; + return false; + } + + string id = path[2]; + ClientConnection connection = _connections[id]; + var property = path[3].ToLowerInvariant(); + + switch (property) + { + case "id": + value = connection.Id; + return true; + case "locator": + value = connection.Locator; + return true; + case "authentication": + value = connection.Authentication.ToString(); + return true; + default: + value = null; + return false; + } + } +} +internal class ConnectionCollectionConfigurationSource : IConfigurationSource +{ + private readonly ConnectionCollection _connections; + public ConnectionCollectionConfigurationSource(ConnectionCollection connections) + => _connections = connections; + + public IConfigurationProvider Build(IConfigurationBuilder builder) + => new ConnectionCollectionConfigurationProvider(_connections); +} + +internal class CmidConfigurationProvider(string cmid) : IConfigurationProvider +{ + public IEnumerable GetChildKeys(IEnumerable earlierKeys, string parentPath) + { + if (parentPath.Equals("CloudMachine", StringComparison.InvariantCultureIgnoreCase)) + return earlierKeys.Append("ID"); // todo: should this check if ID is not already in earlier keys + else + return earlierKeys; + } + + public IChangeToken GetReloadToken() => null; + public void Load() {} + public void Set(string key, string value) + => new NotSupportedException(); + + public bool TryGet(string key, out string value) + { + if (!key.Equals("CloudMachine:ID", StringComparison.InvariantCultureIgnoreCase)) + { + value = null; + return false; + } + value = cmid; + return true; + } +} +internal class CmidConfigurationSource(string cmid) : IConfigurationSource +{ + public IConfigurationProvider Build(IConfigurationBuilder builder) + => new CmidConfigurationProvider(cmid); +} diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/ConnectionCollection.cs b/sdk/cloudmachine/Azure.CloudMachine/src/ConnectionCollection.cs index 5bad8d7014f44..3bdac3b4749e4 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/ConnectionCollection.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/ConnectionCollection.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Diagnostics; using System.Text.Json; using System.Text.Json.Serialization; @@ -13,6 +14,7 @@ namespace Azure.Core; /// Represents the connection options for a client. /// [JsonConverter(typeof(ConnectionCollectionConverter))] +[DebuggerTypeProxy(typeof(ConnectionCollectionViewer))] public class ConnectionCollection : KeyedCollection { /// @@ -29,6 +31,20 @@ internal void AddRange(IEnumerable connections) } } +internal class ConnectionCollectionViewer(ConnectionCollection connections) +{ + [DebuggerBrowsable(DebuggerBrowsableState.RootHidden)] + public ClientConnection[] Items + { + get + { + ClientConnection[] items = new ClientConnection[connections.Count]; + connections.CopyTo(items, 0); + return items; + } + } +} + internal class ConnectionCollectionConverter : JsonConverter { public override ConnectionCollection Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/Azure.CloudMachine.Tests.csproj b/sdk/cloudmachine/Azure.CloudMachine/tests/Azure.CloudMachine.Tests.csproj index 72514fb231b79..62bbcd8d0e934 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/tests/Azure.CloudMachine.Tests.csproj +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/Azure.CloudMachine.Tests.csproj @@ -3,6 +3,7 @@ 12 + diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/CloudMachineTests_rag.cs b/sdk/cloudmachine/Azure.CloudMachine/tests/CloudMachineTests_rag.cs index c4061f87c55ff..13a77362ff81a 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/tests/CloudMachineTests_rag.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/CloudMachineTests_rag.cs @@ -34,7 +34,7 @@ public void RagDemo() "Do you think I would like the weather there?", ]; - CloudMachineClient cm = new(default, new MockConfiguration("cmec4615e3fdfa44e")); + CloudMachineClient cm = new(new MockConfiguration("cmec4615e3fdfa44e"), default); var chat = cm.GetOpenAIChatClient(); var embeddings = cm.GetOpenAIEmbeddingsClient(); diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs b/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs index 2cdad4d3d58f6..6f90fcf8a7697 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/ConnectionTests.cs @@ -9,6 +9,7 @@ using Azure.CloudMachine.OpenAI; using Azure.Core; using Azure.Storage.Blobs; +using Microsoft.Extensions.Configuration; using NUnit.Framework; using OpenAI.Chat; @@ -44,7 +45,7 @@ public void TwoApps() // app 2 (no dependency on the CDK) ConnectionCollection deserializedConnections = JsonSerializer.Deserialize(serializedConnections)!; - CloudMachineClient client = new(connections: deserializedConnections); + CloudMachineClient client = new(deserializedConnections); ValidateClient(client); } @@ -62,6 +63,47 @@ public void SingleClientAdd(string[] args) ChatClient chat = client.GetOpenAIChatClient(); } + [Test] + public void ConfigurationDemo() + { + CloudMachineInfrastructure infra = new(); + infra.AddFeature(new OpenAIModelFeature("gpt-35-turbo", "0125")); + + IConfiguration configuration = new ConfigurationBuilder() + .AddCloudMachineInfrastructure(infra) + .Build(); + + CloudMachineClient client = new(configuration); + ChatClient chat = client.GetOpenAIChatClient(); + } + + [Test] + public void ConfigurationLowLevel() + { + ConnectionCollection connections = new(); + connections.Add(new ClientConnection( + id: "Azure.AI.OpenAI.AzureOpenAIClient", + locator: "https://cm2c54b6e4637f4b1.openai.azure.com", + auth: ClientAuthenticationMethod.EntraId)); + + IConfiguration configuration = new ConfigurationBuilder() + .AddCloudMachineConnections(connections) + .AddCloudMachineId("aaaa-bbbb-cccc-dddd") + .Build(); + + var locator = configuration["CloudMachine:Connections:Azure.AI.OpenAI.AzureOpenAIClient:Locator"]; + Assert.AreEqual("https://cm2c54b6e4637f4b1.openai.azure.com", locator); + var id = configuration["CloudMachine:Id"]; + Assert.AreEqual("aaaa-bbbb-cccc-dddd", id); + + CloudMachineClient client = new(configuration); + Assert.AreEqual("aaaa-bbbb-cccc-dddd", client.Id); + + ClientConnection connection = client.Connections["Azure.AI.OpenAI.AzureOpenAIClient"]; + Assert.AreEqual("https://cm2c54b6e4637f4b1.openai.azure.com", connection.Locator); + Assert.AreEqual("aaaa-bbbb-cccc-dddd", client.Id); + } + private static void ValidateClient(CloudMachineClient client) { ChatClient chat = client.GetOpenAIChatClient(); diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs index 23ec7843538f5..2e3a18146f988 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/CloudMachineInfrastructure/CloudMachineInfrastructure.cs @@ -13,6 +13,7 @@ using Azure.Provisioning.Expressions; using Azure.Provisioning.Primitives; using Azure.Provisioning.Roles; +using Microsoft.Extensions.Configuration; namespace Azure.CloudMachine; @@ -132,3 +133,19 @@ public ProvisioningPlan Build(ProvisioningBuildOptions? context = default) [EditorBrowsable(EditorBrowsableState.Never)] public override bool Equals(object? obj) => base.Equals(obj); } + +public static class CloudMachineInfrastructureConfiguration +{ + /// + /// Adds a connection to the collection. + /// + /// + /// + /// + public static IConfigurationBuilder AddCloudMachineInfrastructure(this IConfigurationBuilder builder, CloudMachineInfrastructure cm) + { + builder.AddCloudMachineConnections(cm.Connections); + builder.AddCloudMachineId(cm.Id); + return builder; + } +} diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/GlobalSuppressions.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/GlobalSuppressions.cs index 4416e7cc32abf..af70f99778e7c 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/GlobalSuppressions.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/src/GlobalSuppressions.cs @@ -5,4 +5,4 @@ [assembly: SuppressMessage("Usage", "AZC0005:DO provide protected parameterless constructor for mocking.", Justification = "", Scope = "type", Target = "~T:Azure.CloudMachine.CloudMachineClient")] [assembly: SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "", Scope = "member", Target = "~M:Azure.CloudMachine.CloudMachineClient.#ctor(Azure.Identity.DefaultAzureCredential,Microsoft.Extensions.Configuration.IConfiguration)")] -[assembly: SuppressMessage("Usage", "AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", Justification = "", Scope = "member", Target = "~M:Azure.CloudMachine.CloudMachineClient.#ctor(Azure.Core.TokenCredential,Microsoft.Extensions.Configuration.IConfiguration)")] +[assembly: SuppressMessage("AZC0007:DO provide a minimal constructor that takes only the parameters required to connect to the service.", "Usage", Justification = "", Scope = "member", Target = "~M:Azure.CloudMachine.CloudMachineClient.#ctor(Azure.Core.TokenCredential,Microsoft.Extensions.Configuration.IConfiguration)")] From 2b8cb07e2ee85c91c5acfdec2a04d25ac7ea63da Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Thu, 5 Dec 2024 11:05:27 -0800 Subject: [PATCH 11/13] generated apis --- .../api/Azure.CloudMachine.net8.0.cs | 87 ++++++++--------- .../api/Azure.CloudMachine.netstandard2.0.cs | 87 ++++++++--------- .../Azure.Provisioning.CloudMachine.net8.0.cs | 96 ++++++++----------- ...rovisioning.CloudMachine.netstandard2.0.cs | 96 ++++++++----------- 4 files changed, 160 insertions(+), 206 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs index 1e6b182bb3f11..bd0071ccb11b8 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs @@ -1,51 +1,16 @@ -namespace Azure -{ - public partial class RestCallFailedException : System.Exception - { - public RestCallFailedException(string message, System.ClientModel.Primitives.PipelineResponse response) { } - } - public partial class RestClient - { - public RestClient() { } - public RestClient(System.ClientModel.Primitives.PipelinePolicy auth) { } - public static Azure.RestClient Shared { get { throw null; } } - public System.ClientModel.Primitives.PipelineMessage Create(string method, System.Uri uri) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Get(string uri, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Patch(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Post(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Put(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Send(System.ClientModel.Primitives.PipelineMessage message, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - } - public partial class RestClientOptions : System.ClientModel.Primitives.ClientPipelineOptions - { - public RestClientOptions() { } - } -} -namespace Azure.AI.OpenAI -{ - public partial class TokenCredentialAuthenticationPolicy : System.ClientModel.Primitives.PipelinePolicy - { - public TokenCredentialAuthenticationPolicy(Azure.Core.TokenCredential credential, System.Collections.Generic.IEnumerable scopes, System.TimeSpan? refreshOffset = default(System.TimeSpan?)) { } - public override void Process(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList pipeline, int currentIndex) { } - public override System.Threading.Tasks.ValueTask ProcessAsync(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList pipeline, int currentIndex) { throw null; } - } -} namespace Azure.CloudMachine { - public partial class CloudMachineClient : Azure.CloudMachine.CloudMachineWorkspace - { - protected CloudMachineClient() : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration), default(System.Collections.Generic.IEnumerable)) { } - public CloudMachineClient(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null, System.Collections.Generic.IEnumerable connections = null) : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration), default(System.Collections.Generic.IEnumerable)) { } - public Azure.CloudMachine.MessagingServices Messaging { get { throw null; } } - public Azure.CloudMachine.StorageServices Storage { get { throw null; } } - } - public partial class CloudMachineWorkspace : Azure.Core.ClientWorkspace + public partial class CloudMachineClient : Azure.Core.ClientWorkspace { - public CloudMachineWorkspace(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null, System.Collections.Generic.IEnumerable connections = null) : base (default(Azure.Core.TokenCredential)) { } + protected CloudMachineClient() : base (default(Azure.Core.TokenCredential)) { } + public CloudMachineClient(Azure.Core.ConnectionCollection connections = null, Azure.Core.TokenCredential credential = null) : base (default(Azure.Core.TokenCredential)) { } + public CloudMachineClient(Microsoft.Extensions.Configuration.IConfiguration configuration, Azure.Core.TokenCredential credential = null) : base (default(Azure.Core.TokenCredential)) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.CloudMachine.ConnectionCollection Connections { get { throw null; } } + public Azure.Core.ConnectionCollection Connections { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public string Id { get { throw null; } } + public Azure.CloudMachine.MessagingServices Messaging { get { throw null; } } + public Azure.CloudMachine.StorageServices Storage { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override bool Equals(object obj) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -57,11 +22,6 @@ public CloudMachineWorkspace(Azure.Core.TokenCredential credential = null, Micro [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override string ToString() { throw null; } } - public partial class ConnectionCollection : System.Collections.ObjectModel.KeyedCollection - { - public ConnectionCollection() { } - protected override string GetKeyForItem(Azure.Core.ClientConnection item) { throw null; } - } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct MessagingServices { @@ -211,4 +171,37 @@ protected ClientWorkspace(Azure.Core.TokenCredential credential) { } public Azure.Core.ClientCache Subclients { get { throw null; } } public abstract Azure.Core.ClientConnection GetConnectionOptions(string connectionId); } + public static partial class CloudMachineClientConfiguration + { + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineConnections(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, Azure.Core.ConnectionCollection connections) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineId(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string cmid) { throw null; } + } + public partial class ConnectionCollection : System.Collections.ObjectModel.KeyedCollection + { + public ConnectionCollection() { } + protected override string GetKeyForItem(Azure.Core.ClientConnection item) { throw null; } + } +} +namespace Azure.Core.Rest +{ + public partial class RestCallFailedException : System.Exception + { + public RestCallFailedException(string message, System.ClientModel.Primitives.PipelineResponse response) { } + } + public partial class RestClient + { + public RestClient() { } + public RestClient(System.ClientModel.Primitives.PipelinePolicy auth) { } + public static Azure.Core.Rest.RestClient Shared { get { throw null; } } + public System.ClientModel.Primitives.PipelineMessage Create(string method, System.Uri uri) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Get(string uri, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Patch(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Post(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Put(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Send(System.ClientModel.Primitives.PipelineMessage message, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + } + public partial class RestClientOptions : System.ClientModel.Primitives.ClientPipelineOptions + { + public RestClientOptions() { } + } } diff --git a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs index 1e6b182bb3f11..bd0071ccb11b8 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs @@ -1,51 +1,16 @@ -namespace Azure -{ - public partial class RestCallFailedException : System.Exception - { - public RestCallFailedException(string message, System.ClientModel.Primitives.PipelineResponse response) { } - } - public partial class RestClient - { - public RestClient() { } - public RestClient(System.ClientModel.Primitives.PipelinePolicy auth) { } - public static Azure.RestClient Shared { get { throw null; } } - public System.ClientModel.Primitives.PipelineMessage Create(string method, System.Uri uri) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Get(string uri, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Patch(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Post(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Put(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - public System.ClientModel.Primitives.PipelineResponse Send(System.ClientModel.Primitives.PipelineMessage message, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } - } - public partial class RestClientOptions : System.ClientModel.Primitives.ClientPipelineOptions - { - public RestClientOptions() { } - } -} -namespace Azure.AI.OpenAI -{ - public partial class TokenCredentialAuthenticationPolicy : System.ClientModel.Primitives.PipelinePolicy - { - public TokenCredentialAuthenticationPolicy(Azure.Core.TokenCredential credential, System.Collections.Generic.IEnumerable scopes, System.TimeSpan? refreshOffset = default(System.TimeSpan?)) { } - public override void Process(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList pipeline, int currentIndex) { } - public override System.Threading.Tasks.ValueTask ProcessAsync(System.ClientModel.Primitives.PipelineMessage message, System.Collections.Generic.IReadOnlyList pipeline, int currentIndex) { throw null; } - } -} namespace Azure.CloudMachine { - public partial class CloudMachineClient : Azure.CloudMachine.CloudMachineWorkspace - { - protected CloudMachineClient() : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration), default(System.Collections.Generic.IEnumerable)) { } - public CloudMachineClient(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null, System.Collections.Generic.IEnumerable connections = null) : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration), default(System.Collections.Generic.IEnumerable)) { } - public Azure.CloudMachine.MessagingServices Messaging { get { throw null; } } - public Azure.CloudMachine.StorageServices Storage { get { throw null; } } - } - public partial class CloudMachineWorkspace : Azure.Core.ClientWorkspace + public partial class CloudMachineClient : Azure.Core.ClientWorkspace { - public CloudMachineWorkspace(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null, System.Collections.Generic.IEnumerable connections = null) : base (default(Azure.Core.TokenCredential)) { } + protected CloudMachineClient() : base (default(Azure.Core.TokenCredential)) { } + public CloudMachineClient(Azure.Core.ConnectionCollection connections = null, Azure.Core.TokenCredential credential = null) : base (default(Azure.Core.TokenCredential)) { } + public CloudMachineClient(Microsoft.Extensions.Configuration.IConfiguration configuration, Azure.Core.TokenCredential credential = null) : base (default(Azure.Core.TokenCredential)) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.CloudMachine.ConnectionCollection Connections { get { throw null; } } + public Azure.Core.ConnectionCollection Connections { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public string Id { get { throw null; } } + public Azure.CloudMachine.MessagingServices Messaging { get { throw null; } } + public Azure.CloudMachine.StorageServices Storage { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override bool Equals(object obj) { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -57,11 +22,6 @@ public CloudMachineWorkspace(Azure.Core.TokenCredential credential = null, Micro [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override string ToString() { throw null; } } - public partial class ConnectionCollection : System.Collections.ObjectModel.KeyedCollection - { - public ConnectionCollection() { } - protected override string GetKeyForItem(Azure.Core.ClientConnection item) { throw null; } - } [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] public readonly partial struct MessagingServices { @@ -211,4 +171,37 @@ protected ClientWorkspace(Azure.Core.TokenCredential credential) { } public Azure.Core.ClientCache Subclients { get { throw null; } } public abstract Azure.Core.ClientConnection GetConnectionOptions(string connectionId); } + public static partial class CloudMachineClientConfiguration + { + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineConnections(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, Azure.Core.ConnectionCollection connections) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineId(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string cmid) { throw null; } + } + public partial class ConnectionCollection : System.Collections.ObjectModel.KeyedCollection + { + public ConnectionCollection() { } + protected override string GetKeyForItem(Azure.Core.ClientConnection item) { throw null; } + } +} +namespace Azure.Core.Rest +{ + public partial class RestCallFailedException : System.Exception + { + public RestCallFailedException(string message, System.ClientModel.Primitives.PipelineResponse response) { } + } + public partial class RestClient + { + public RestClient() { } + public RestClient(System.ClientModel.Primitives.PipelinePolicy auth) { } + public static Azure.Core.Rest.RestClient Shared { get { throw null; } } + public System.ClientModel.Primitives.PipelineMessage Create(string method, System.Uri uri) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Get(string uri, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Patch(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Post(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Put(string uri, System.ClientModel.BinaryContent content, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + public System.ClientModel.Primitives.PipelineResponse Send(System.ClientModel.Primitives.PipelineMessage message, System.ClientModel.Primitives.RequestOptions options = null) { throw null; } + } + public partial class RestClientOptions : System.ClientModel.Primitives.ClientPipelineOptions + { + public RestClientOptions() { } + } } diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.net8.0.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.net8.0.cs index 3e3c5e0fb6113..6b1ae5a6fb4a4 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.net8.0.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.net8.0.cs @@ -8,28 +8,27 @@ public static void InitDeployment(Azure.CloudMachine.CloudMachineInfrastructure } public static partial class CloudMachineClientExtensions { - public static T AddFeature(this Azure.CloudMachine.CloudMachineClient client, T feature) where T : Azure.Provisioning.CloudMachine.CloudMachineFeature { throw null; } - public static void Configure(this Azure.CloudMachine.CloudMachineClient client, System.Action? configure = null) { } + public static T AddFeature(this Azure.CloudMachine.CloudMachineClient client, T feature) where T : Azure.CloudMachine.Core.CloudMachineFeature { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.CloudMachine.CloudMachineInfrastructure GetInfrastructure(this Azure.CloudMachine.CloudMachineClient client) { throw null; } } public static partial class CloudMachineCommands { - public static bool Execute(string[] args, System.Action? configure = null, bool exitProcessIfHandled = true) { throw null; } + public static bool TryExecuteCommand(this Azure.CloudMachine.CloudMachineInfrastructure cmi, string[] args) { throw null; } } public partial class CloudMachineInfrastructure { public CloudMachineInfrastructure(string? cmId = null) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.CloudMachine.ConnectionCollection Connections { get { throw null; } } - public Azure.CloudMachine.FeatureCollection Features { get { throw null; } } + public Azure.Core.ConnectionCollection Connections { get { throw null; } } + public Azure.CloudMachine.Core.FeatureCollection Features { get { throw null; } } public string Id { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Provisioning.Roles.UserAssignedIdentity Identity { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Provisioning.ProvisioningParameter PrincipalIdParameter { get { throw null; } } public void AddEndpoints() { } - public T AddFeature(T feature) where T : Azure.Provisioning.CloudMachine.CloudMachineFeature { throw null; } + public T AddFeature(T feature) where T : Azure.CloudMachine.Core.CloudMachineFeature { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void AddResource(Azure.Provisioning.Primitives.NamedProvisionableConstruct resource) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -42,49 +41,54 @@ public void AddResource(Azure.Provisioning.Primitives.NamedProvisionableConstruc [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override string ToString() { throw null; } } - public partial class FeatureCollection : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + public static partial class CloudMachineInfrastructureConfiguration { - internal FeatureCollection() { } - public System.Collections.Generic.IEnumerable FindAll() where T : Azure.Provisioning.CloudMachine.CloudMachineFeature { throw null; } - public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } - public partial class ServiceBusNamespaceFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature - { - public ServiceBusNamespaceFeature(string name, Azure.Provisioning.ServiceBus.ServiceBusSkuName sku = Azure.Provisioning.ServiceBus.ServiceBusSkuName.Standard, Azure.Provisioning.ServiceBus.ServiceBusSkuTier tier = Azure.Provisioning.ServiceBus.ServiceBusSkuTier.Standard) { } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } - } - public partial class ServiceBusSubscriptionFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature - { - public ServiceBusSubscriptionFeature(string name, Azure.CloudMachine.ServiceBusTopicFeature parent) { } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } - } - public partial class ServiceBusTopicFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature - { - public ServiceBusTopicFeature(string name, Azure.CloudMachine.ServiceBusNamespaceFeature parent) { } - public string Name { get { throw null; } } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineInfrastructure(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, Azure.CloudMachine.CloudMachineInfrastructure cm) { throw null; } } } namespace Azure.CloudMachine.AppService { - public partial class AppServiceFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature + public partial class AppServiceFeature : Azure.CloudMachine.Core.CloudMachineFeature { public AppServiceFeature() { } public Azure.Provisioning.AppService.AppServiceSkuDescription Sku { get { throw null; } set { } } protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } } } +namespace Azure.CloudMachine.Core +{ + public abstract partial class CloudMachineFeature + { + protected CloudMachineFeature() { } + protected internal System.Collections.Generic.Dictionary RequiredSystemRoles { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public Azure.Provisioning.Primitives.ProvisionableResource Resource { get { throw null; } } + protected internal virtual void EmitConnections(Azure.Core.ConnectionCollection connections, string cmId) { } + protected internal virtual void EmitFeatures(Azure.CloudMachine.Core.FeatureCollection features, string cmId) { } + protected abstract Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure cm); + protected static T EnsureEmits(Azure.CloudMachine.Core.CloudMachineFeature feature) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string ToString() { throw null; } + } + public partial class FeatureCollection : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + internal FeatureCollection() { } + public System.Collections.Generic.IEnumerable FindAll() where T : Azure.CloudMachine.Core.CloudMachineFeature { throw null; } + public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } +} namespace Azure.CloudMachine.KeyVault { - public partial class KeyVaultFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature + public partial class KeyVaultFeature : Azure.CloudMachine.Core.CloudMachineFeature { public KeyVaultFeature(Azure.Provisioning.KeyVault.KeyVaultSku? sku = null) { } public Azure.Provisioning.KeyVault.KeyVaultSku Sku { get { throw null; } set { } } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } + protected internal override void EmitConnections(Azure.Core.ConnectionCollection connections, string cmId) { } protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } } } @@ -95,36 +99,16 @@ public enum AIModelKind Chat = 0, Embedding = 1, } - public partial class OpenAIModelFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature + public partial class OpenAIModelFeature : Azure.CloudMachine.Core.CloudMachineFeature { public OpenAIModelFeature(string model, string modelVersion, Azure.CloudMachine.OpenAI.AIModelKind kind = Azure.CloudMachine.OpenAI.AIModelKind.Chat) { } public string Model { get { throw null; } } public string ModelVersion { get { throw null; } } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected internal override void EmitFeatures(Azure.CloudMachine.FeatureCollection features, string cmId) { } + protected internal override void EmitConnections(Azure.Core.ConnectionCollection connections, string cmId) { } + protected internal override void EmitFeatures(Azure.CloudMachine.Core.FeatureCollection features, string cmId) { } protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure cm) { throw null; } } } -namespace Azure.Provisioning.CloudMachine -{ - public abstract partial class CloudMachineFeature - { - protected CloudMachineFeature() { } - protected internal System.Collections.Generic.Dictionary RequiredSystemRoles { get { throw null; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.Provisioning.Primitives.ProvisionableResource Resource { get { throw null; } } - protected internal virtual void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected internal virtual void EmitFeatures(Azure.CloudMachine.FeatureCollection features, string cmId) { } - protected abstract Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure cm); - protected static T EnsureEmits(Azure.Provisioning.CloudMachine.CloudMachineFeature feature) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object? obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override string ToString() { throw null; } - } -} namespace System.ClientModel.TypeSpec { public static partial class TypeSpecWriter diff --git a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.netstandard2.0.cs b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.netstandard2.0.cs index 3e3c5e0fb6113..6b1ae5a6fb4a4 100644 --- a/sdk/cloudmachine/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.netstandard2.0.cs +++ b/sdk/cloudmachine/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.netstandard2.0.cs @@ -8,28 +8,27 @@ public static void InitDeployment(Azure.CloudMachine.CloudMachineInfrastructure } public static partial class CloudMachineClientExtensions { - public static T AddFeature(this Azure.CloudMachine.CloudMachineClient client, T feature) where T : Azure.Provisioning.CloudMachine.CloudMachineFeature { throw null; } - public static void Configure(this Azure.CloudMachine.CloudMachineClient client, System.Action? configure = null) { } + public static T AddFeature(this Azure.CloudMachine.CloudMachineClient client, T feature) where T : Azure.CloudMachine.Core.CloudMachineFeature { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public static Azure.CloudMachine.CloudMachineInfrastructure GetInfrastructure(this Azure.CloudMachine.CloudMachineClient client) { throw null; } } public static partial class CloudMachineCommands { - public static bool Execute(string[] args, System.Action? configure = null, bool exitProcessIfHandled = true) { throw null; } + public static bool TryExecuteCommand(this Azure.CloudMachine.CloudMachineInfrastructure cmi, string[] args) { throw null; } } public partial class CloudMachineInfrastructure { public CloudMachineInfrastructure(string? cmId = null) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.CloudMachine.ConnectionCollection Connections { get { throw null; } } - public Azure.CloudMachine.FeatureCollection Features { get { throw null; } } + public Azure.Core.ConnectionCollection Connections { get { throw null; } } + public Azure.CloudMachine.Core.FeatureCollection Features { get { throw null; } } public string Id { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Provisioning.Roles.UserAssignedIdentity Identity { get { throw null; } } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public Azure.Provisioning.ProvisioningParameter PrincipalIdParameter { get { throw null; } } public void AddEndpoints() { } - public T AddFeature(T feature) where T : Azure.Provisioning.CloudMachine.CloudMachineFeature { throw null; } + public T AddFeature(T feature) where T : Azure.CloudMachine.Core.CloudMachineFeature { throw null; } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public void AddResource(Azure.Provisioning.Primitives.NamedProvisionableConstruct resource) { } [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] @@ -42,49 +41,54 @@ public void AddResource(Azure.Provisioning.Primitives.NamedProvisionableConstruc [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] public override string ToString() { throw null; } } - public partial class FeatureCollection : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + public static partial class CloudMachineInfrastructureConfiguration { - internal FeatureCollection() { } - public System.Collections.Generic.IEnumerable FindAll() where T : Azure.Provisioning.CloudMachine.CloudMachineFeature { throw null; } - public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } - System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } - } - public partial class ServiceBusNamespaceFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature - { - public ServiceBusNamespaceFeature(string name, Azure.Provisioning.ServiceBus.ServiceBusSkuName sku = Azure.Provisioning.ServiceBus.ServiceBusSkuName.Standard, Azure.Provisioning.ServiceBus.ServiceBusSkuTier tier = Azure.Provisioning.ServiceBus.ServiceBusSkuTier.Standard) { } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } - } - public partial class ServiceBusSubscriptionFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature - { - public ServiceBusSubscriptionFeature(string name, Azure.CloudMachine.ServiceBusTopicFeature parent) { } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } - } - public partial class ServiceBusTopicFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature - { - public ServiceBusTopicFeature(string name, Azure.CloudMachine.ServiceBusNamespaceFeature parent) { } - public string Name { get { throw null; } } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineInfrastructure(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, Azure.CloudMachine.CloudMachineInfrastructure cm) { throw null; } } } namespace Azure.CloudMachine.AppService { - public partial class AppServiceFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature + public partial class AppServiceFeature : Azure.CloudMachine.Core.CloudMachineFeature { public AppServiceFeature() { } public Azure.Provisioning.AppService.AppServiceSkuDescription Sku { get { throw null; } set { } } protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } } } +namespace Azure.CloudMachine.Core +{ + public abstract partial class CloudMachineFeature + { + protected CloudMachineFeature() { } + protected internal System.Collections.Generic.Dictionary RequiredSystemRoles { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public Azure.Provisioning.Primitives.ProvisionableResource Resource { get { throw null; } } + protected internal virtual void EmitConnections(Azure.Core.ConnectionCollection connections, string cmId) { } + protected internal virtual void EmitFeatures(Azure.CloudMachine.Core.FeatureCollection features, string cmId) { } + protected abstract Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure cm); + protected static T EnsureEmits(Azure.CloudMachine.Core.CloudMachineFeature feature) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string ToString() { throw null; } + } + public partial class FeatureCollection : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + internal FeatureCollection() { } + public System.Collections.Generic.IEnumerable FindAll() where T : Azure.CloudMachine.Core.CloudMachineFeature { throw null; } + public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } +} namespace Azure.CloudMachine.KeyVault { - public partial class KeyVaultFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature + public partial class KeyVaultFeature : Azure.CloudMachine.Core.CloudMachineFeature { public KeyVaultFeature(Azure.Provisioning.KeyVault.KeyVaultSku? sku = null) { } public Azure.Provisioning.KeyVault.KeyVaultSku Sku { get { throw null; } set { } } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } + protected internal override void EmitConnections(Azure.Core.ConnectionCollection connections, string cmId) { } protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure infrastructure) { throw null; } } } @@ -95,36 +99,16 @@ public enum AIModelKind Chat = 0, Embedding = 1, } - public partial class OpenAIModelFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature + public partial class OpenAIModelFeature : Azure.CloudMachine.Core.CloudMachineFeature { public OpenAIModelFeature(string model, string modelVersion, Azure.CloudMachine.OpenAI.AIModelKind kind = Azure.CloudMachine.OpenAI.AIModelKind.Chat) { } public string Model { get { throw null; } } public string ModelVersion { get { throw null; } } - protected internal override void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected internal override void EmitFeatures(Azure.CloudMachine.FeatureCollection features, string cmId) { } + protected internal override void EmitConnections(Azure.Core.ConnectionCollection connections, string cmId) { } + protected internal override void EmitFeatures(Azure.CloudMachine.Core.FeatureCollection features, string cmId) { } protected override Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure cm) { throw null; } } } -namespace Azure.Provisioning.CloudMachine -{ - public abstract partial class CloudMachineFeature - { - protected CloudMachineFeature() { } - protected internal System.Collections.Generic.Dictionary RequiredSystemRoles { get { throw null; } } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.Provisioning.Primitives.ProvisionableResource Resource { get { throw null; } } - protected internal virtual void EmitConnections(Azure.CloudMachine.ConnectionCollection connections, string cmId) { } - protected internal virtual void EmitFeatures(Azure.CloudMachine.FeatureCollection features, string cmId) { } - protected abstract Azure.Provisioning.Primitives.ProvisionableResource EmitResources(Azure.CloudMachine.CloudMachineInfrastructure cm); - protected static T EnsureEmits(Azure.Provisioning.CloudMachine.CloudMachineFeature feature) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object? obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override string ToString() { throw null; } - } -} namespace System.ClientModel.TypeSpec { public static partial class TypeSpecWriter From 2c892335746bbc676787aafc7d16268a73481d48 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Thu, 5 Dec 2024 11:52:03 -0800 Subject: [PATCH 12/13] fixed spelling --- .../Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs | 2 +- .../api/Azure.CloudMachine.netstandard2.0.cs | 2 +- .../src/CloudMachineClientConfiguration.cs | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs index bd0071ccb11b8..a53334d90ff63 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.net8.0.cs @@ -174,7 +174,7 @@ protected ClientWorkspace(Azure.Core.TokenCredential credential) { } public static partial class CloudMachineClientConfiguration { public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineConnections(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, Azure.Core.ConnectionCollection connections) { throw null; } - public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineId(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string cmid) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineId(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string id) { throw null; } } public partial class ConnectionCollection : System.Collections.ObjectModel.KeyedCollection { diff --git a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs index bd0071ccb11b8..a53334d90ff63 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs @@ -174,7 +174,7 @@ protected ClientWorkspace(Azure.Core.TokenCredential credential) { } public static partial class CloudMachineClientConfiguration { public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineConnections(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, Azure.Core.ConnectionCollection connections) { throw null; } - public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineId(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string cmid) { throw null; } + public static Microsoft.Extensions.Configuration.IConfigurationBuilder AddCloudMachineId(this Microsoft.Extensions.Configuration.IConfigurationBuilder builder, string id) { throw null; } } public partial class ConnectionCollection : System.Collections.ObjectModel.KeyedCollection { diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClientConfiguration.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClientConfiguration.cs index ba088a7744e24..7055da3b61708 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClientConfiguration.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClientConfiguration.cs @@ -30,11 +30,11 @@ public static IConfigurationBuilder AddCloudMachineConnections(this IConfigurati /// Adds a connection to the collection. /// /// - /// + /// /// - public static IConfigurationBuilder AddCloudMachineId(this IConfigurationBuilder builder, string cmid) + public static IConfigurationBuilder AddCloudMachineId(this IConfigurationBuilder builder, string id) { - var source = new CmidConfigurationSource(cmid); + var source = new CmidConfigurationSource(id); builder.Add(source); return builder; } From 08dffb662c742ca5c3f865ea17e0e717da871a6e Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Thu, 5 Dec 2024 13:15:29 -0800 Subject: [PATCH 13/13] pr feedback --- .../Azure.CloudMachine/src/CloudMachineClient.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs index 23927d4c22c39..30da8dcdffa5a 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs @@ -30,7 +30,7 @@ public partial class CloudMachineClient : ClientWorkspace /// Initializes a new instance of the class for mocking purposes.. /// protected CloudMachineClient() : - this(credential: BuildCredentail(default)) + this(credential: BuildCredential(default)) { Id = AppConfigHelpers.ReadOrCreateCloudMachineId(); Messaging = new MessagingServices(this); @@ -43,10 +43,9 @@ protected CloudMachineClient() : /// /// The configuration settings. /// The token credential. - // TODO: we need to combine the configuration and the connections into a single parameter. public CloudMachineClient(IConfiguration configuration, TokenCredential credential = default) #pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. - : base(BuildCredentail(credential)) + : base(BuildCredential(credential)) { Id = configuration["CloudMachine:ID"]; if (Id == null) @@ -78,7 +77,7 @@ public CloudMachineClient(IConfiguration configuration, TokenCredential credenti // TODO: we need to combine the configuration and the connections into a single parameter. public CloudMachineClient(ConnectionCollection connections = default, TokenCredential credential = default) #pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. - : base(BuildCredentail(credential)) + : base(BuildCredential(credential)) { if (connections != default) { @@ -112,7 +111,7 @@ public override ClientConnection GetConnectionOptions(string connectionId) return Connections[connectionId]; } - private static TokenCredential BuildCredentail(TokenCredential credential) + private static TokenCredential BuildCredential(TokenCredential credential) { if (credential == default) {