From 229eaa27032d9129b7e3d10f136da5b596b9e3c3 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 31 Oct 2024 15:55:29 -0500 Subject: [PATCH 1/8] Move types to new package --- sdk/cloudmachine/Azure.CloudMachine.sln | 34 +++ .../Azure.CloudMachine/CHANGELOG.md | 11 + .../Azure.CloudMachine/Directory.Build.props | 6 + .../Directory.Build.targets | 6 + sdk/cloudmachine/Azure.CloudMachine/README.md | 57 +++++ .../api/Azure.CloudMachine.netstandard2.0.cs | 43 ++++ .../Azure.CloudMachine/samples/README.md | 12 + .../src/Azure.CloudMachine.csproj | 24 ++ .../Azure.CloudMachine/src}/ClientCache.cs | 4 +- .../src}/ClientWorkspace.cs | 10 +- .../src}/CloudMachineClient.cs | 6 +- .../src}/CloudMachineWorkspace.cs | 0 .../src/CoreServices}/MessagingServices.cs | 3 +- .../src/CoreServices}/StorageFile.cs | 6 +- .../src/CoreServices}/StorageServices.cs | 12 +- .../src/extensions/AzureOpenAIExtensions.cs | 75 ++++++ .../src/extensions/KeyVaultExtensions.cs | 21 ++ .../src/properties/AssemblyInfo.cs | 13 + .../tests/Azure.CloudMachine.Tests.csproj | 14 + .../tests/CloudMachineTests.cs | 160 ++++++++++++ sdk/cloudmachine/ci.yml | 53 ++++ sdk/cloudmachine/tests.yml | 17 ++ .../src/AzureSdkExtensions/KeyVaultFeature.cs | 16 -- .../src/AzureSdkExtensions/OpenAIFeature.cs | 70 ----- .../src/Properties/AssemblyInfo.cs | 1 + .../tests/CloudMachineTests.cs | 242 +++++++++--------- 26 files changed, 690 insertions(+), 226 deletions(-) create mode 100644 sdk/cloudmachine/Azure.CloudMachine.sln create mode 100644 sdk/cloudmachine/Azure.CloudMachine/CHANGELOG.md create mode 100644 sdk/cloudmachine/Azure.CloudMachine/Directory.Build.props create mode 100644 sdk/cloudmachine/Azure.CloudMachine/Directory.Build.targets create mode 100644 sdk/cloudmachine/Azure.CloudMachine/README.md create mode 100644 sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs create mode 100644 sdk/cloudmachine/Azure.CloudMachine/samples/README.md create mode 100644 sdk/cloudmachine/Azure.CloudMachine/src/Azure.CloudMachine.csproj rename sdk/{provisioning/Azure.Provisioning.CloudMachine/src/Core => cloudmachine/Azure.CloudMachine/src}/ClientCache.cs (83%) rename sdk/{provisioning/Azure.Provisioning.CloudMachine/src/Core => cloudmachine/Azure.CloudMachine/src}/ClientWorkspace.cs (84%) rename sdk/{provisioning/Azure.Provisioning.CloudMachine/src/OFX => cloudmachine/Azure.CloudMachine/src}/CloudMachineClient.cs (54%) rename sdk/{provisioning/Azure.Provisioning.CloudMachine/src/OFX => cloudmachine/Azure.CloudMachine/src}/CloudMachineWorkspace.cs (100%) rename sdk/{provisioning/Azure.Provisioning.CloudMachine/src/OFX => cloudmachine/Azure.CloudMachine/src/CoreServices}/MessagingServices.cs (97%) rename sdk/{provisioning/Azure.Provisioning.CloudMachine/src/OFX => cloudmachine/Azure.CloudMachine/src/CoreServices}/StorageFile.cs (91%) rename sdk/{provisioning/Azure.Provisioning.CloudMachine/src/OFX => cloudmachine/Azure.CloudMachine/src/CoreServices}/StorageServices.cs (93%) create mode 100644 sdk/cloudmachine/Azure.CloudMachine/src/extensions/AzureOpenAIExtensions.cs create mode 100644 sdk/cloudmachine/Azure.CloudMachine/src/extensions/KeyVaultExtensions.cs create mode 100644 sdk/cloudmachine/Azure.CloudMachine/src/properties/AssemblyInfo.cs create mode 100644 sdk/cloudmachine/Azure.CloudMachine/tests/Azure.CloudMachine.Tests.csproj create mode 100644 sdk/cloudmachine/Azure.CloudMachine/tests/CloudMachineTests.cs create mode 100644 sdk/cloudmachine/ci.yml create mode 100644 sdk/cloudmachine/tests.yml diff --git a/sdk/cloudmachine/Azure.CloudMachine.sln b/sdk/cloudmachine/Azure.CloudMachine.sln new file mode 100644 index 000000000000..c35251a1e5e9 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31903.59 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure.CloudMachine", "Azure.CloudMachine", "{780138CF-68C6-4323-982F-F18989E2FA86}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.CloudMachine", "Azure.CloudMachine\src\Azure.CloudMachine.csproj", "{0EA29D2F-41E0-4826-9CD4-111109A2CFF7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.CloudMachine.Tests", "Azure.CloudMachine\tests\Azure.CloudMachine.Tests.csproj", "{8C1A29AE-E357-4C40-ACCC-7215FBFB368C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0EA29D2F-41E0-4826-9CD4-111109A2CFF7}.Release|Any CPU.Build.0 = Release|Any CPU + {8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C1A29AE-E357-4C40-ACCC-7215FBFB368C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {0EA29D2F-41E0-4826-9CD4-111109A2CFF7} = {780138CF-68C6-4323-982F-F18989E2FA86} + {8C1A29AE-E357-4C40-ACCC-7215FBFB368C} = {780138CF-68C6-4323-982F-F18989E2FA86} + EndGlobalSection +EndGlobal diff --git a/sdk/cloudmachine/Azure.CloudMachine/CHANGELOG.md b/sdk/cloudmachine/Azure.CloudMachine/CHANGELOG.md new file mode 100644 index 000000000000..13dd08af78ab --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/CHANGELOG.md @@ -0,0 +1,11 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes diff --git a/sdk/cloudmachine/Azure.CloudMachine/Directory.Build.props b/sdk/cloudmachine/Azure.CloudMachine/Directory.Build.props new file mode 100644 index 000000000000..1a9611bd4924 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/Directory.Build.props @@ -0,0 +1,6 @@ + + + + diff --git a/sdk/cloudmachine/Azure.CloudMachine/Directory.Build.targets b/sdk/cloudmachine/Azure.CloudMachine/Directory.Build.targets new file mode 100644 index 000000000000..8ef52e10af65 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/Directory.Build.targets @@ -0,0 +1,6 @@ + + + + + diff --git a/sdk/cloudmachine/Azure.CloudMachine/README.md b/sdk/cloudmachine/Azure.CloudMachine/README.md new file mode 100644 index 000000000000..803fbbdea847 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/README.md @@ -0,0 +1,57 @@ +# Azure CloudMachine client library for .NET + +TODO + +## Getting started + +### Install the package + +Install the client library for .NET with [NuGet](https://www.nuget.org/ ): + +```dotnetcli +dotnet add package Azure.CloudMachine --prerelease +``` + +### Prerequisites + +> You must have an [Azure subscription](https://azure.microsoft.com/free/dotnet/). + +### Authenticate the Client + +## Key concepts + +TODO + +## Examples + +## Troubleshooting + +- File an issue via [GitHub Issues](https://github.com/Azure/azure-sdk-for-net/issues). +- Check [previous questions](https://stackoverflow.com/questions/tagged/azure+.net) or ask new ones on Stack Overflow using Azure and .NET tags. + +## Next steps + +## Contributing + +For details on contributing to this repository, see the [contributing +guide][cg]. + +This project welcomes contributions and suggestions. Most contributions +require you to agree to a Contributor License Agreement (CLA) declaring +that you have the right to, and actually do, grant us the rights to use +your contribution. For details, visit . + +When you submit a pull request, a CLA-bot will automatically determine +whether you need to provide a CLA and decorate the PR appropriately +(for example, label, comment). Follow the instructions provided by the +bot. You'll only need to do this action once across all repositories +using our CLA. + +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For +more information, see the [Code of Conduct FAQ][coc_faq] or contact + with any other questions or comments. + + +[cg]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/resourcemanager/Azure.ResourceManager/docs/CONTRIBUTING.md +[coc]: https://opensource.microsoft.com/codeofconduct/ +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ diff --git a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs new file mode 100644 index 000000000000..28cd3bda804d --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs @@ -0,0 +1,43 @@ +namespace Azure.Template +{ + public partial class TemplateClient + { + protected TemplateClient() { } + public TemplateClient(string vaultBaseUrl, Azure.Core.TokenCredential credential) { } + public TemplateClient(string vaultBaseUrl, Azure.Core.TokenCredential credential, Azure.Template.TemplateClientOptions options) { } + public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } + public virtual Azure.Response GetSecret(string secretName, Azure.RequestContext context) { throw null; } + public virtual System.Threading.Tasks.Task GetSecretAsync(string secretName, Azure.RequestContext context) { throw null; } + public virtual Azure.Response GetSecretValue(string secretName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> GetSecretValueAsync(string secretName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class TemplateClientOptions : Azure.Core.ClientOptions + { + public TemplateClientOptions(Azure.Template.TemplateClientOptions.ServiceVersion version = Azure.Template.TemplateClientOptions.ServiceVersion.V7_0) { } + public enum ServiceVersion + { + V7_0 = 1, + } + } +} +namespace Azure.Template.Models +{ + public partial class SecretBundle + { + internal SecretBundle() { } + public string ContentType { get { throw null; } } + public string Id { get { throw null; } } + public string Kid { get { throw null; } } + public bool? Managed { get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } + public string Value { get { throw null; } } + } +} +namespace Microsoft.Extensions.Azure +{ + public static partial class TemplateClientBuilderExtensions + { + public static Azure.Core.Extensions.IAzureClientBuilder AddTemplateClient(this TBuilder builder, string vaultBaseUrl) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; } + public static Azure.Core.Extensions.IAzureClientBuilder AddTemplateClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + } +} diff --git a/sdk/cloudmachine/Azure.CloudMachine/samples/README.md b/sdk/cloudmachine/Azure.CloudMachine/samples/README.md new file mode 100644 index 000000000000..e6bbe8bac48e --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/samples/README.md @@ -0,0 +1,12 @@ +--- +page_type: sample +languages: +- csharp +products: +# Including relevant stubs from https://review.docs.microsoft.com/help/contribute/metadata-taxonomies#product +- azure +name: Azure.CloudMachine samples for .NET +description: Samples for the Azure.CloudMachine client library. +--- + +# Azure.CloudMachine Samples diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/Azure.CloudMachine.csproj b/sdk/cloudmachine/Azure.CloudMachine/src/Azure.CloudMachine.csproj new file mode 100644 index 000000000000..f25f12e99354 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/src/Azure.CloudMachine.csproj @@ -0,0 +1,24 @@ + + + + Azure.CloudMachine simplifies getting started with Azure in .NET. + 1.0.0-beta.1 + $(RequiredTargetFrameworks) + 12 + + + CS1591 + + + + + + + + + + + + + + diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Core/ClientCache.cs b/sdk/cloudmachine/Azure.CloudMachine/src/ClientCache.cs similarity index 83% rename from sdk/provisioning/Azure.Provisioning.CloudMachine/src/Core/ClientCache.cs rename to sdk/cloudmachine/Azure.CloudMachine/src/ClientCache.cs index 235fcba38d1d..8d81ce1be027 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Core/ClientCache.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/ClientCache.cs @@ -9,9 +9,9 @@ namespace Azure.Core; // TODO: this is a very demo implementation. We need to do better public class ClientCache { - private readonly Dictionary<(Type, string?), object> _clients = new Dictionary<(Type, string?), object>(); + private readonly Dictionary<(Type, string), object> _clients = new Dictionary<(Type, string), object>(); - public T Get(Func value, string? id = default) where T: class + public T Get(Func value, string id = default) where T: class { var client = (typeof(T), id); lock (_clients) diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Core/ClientWorkspace.cs b/sdk/cloudmachine/Azure.CloudMachine/src/ClientWorkspace.cs similarity index 84% rename from sdk/provisioning/Azure.Provisioning.CloudMachine/src/Core/ClientWorkspace.cs rename to sdk/cloudmachine/Azure.CloudMachine/src/ClientWorkspace.cs index a40d2d5aae1f..1b1427005dd8 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Core/ClientWorkspace.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/ClientWorkspace.cs @@ -8,7 +8,7 @@ namespace Azure.Core; public abstract class ClientWorkspace { - public abstract ClientConnectionOptions GetConnectionOptions(Type clientType, string? instanceId = default); + public abstract ClientConnectionOptions GetConnectionOptions(Type clientType, string instanceId = default); [EditorBrowsable(EditorBrowsableState.Never)] public ClientCache Subclients { get; } = new ClientCache(); @@ -36,10 +36,10 @@ public ClientConnectionOptions(string subclientId) public ClientConnectionKind ConnectionKind { get; } - public Uri? Endpoint { get; } - public string? Id { get; } - public string? ApiKeyCredential { get; } - public TokenCredential? TokenCredential { get; } + public Uri Endpoint { get; } + public string Id { get; } + public string ApiKeyCredential { get; } + public TokenCredential TokenCredential { get; } } public enum ClientConnectionKind diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineClient.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs similarity index 54% rename from sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineClient.cs rename to sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs index 39f84a1327c1..2388de380e6a 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineClient.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineClient.cs @@ -8,7 +8,11 @@ namespace Azure.CloudMachine; public partial class CloudMachineClient : CloudMachineWorkspace { - public CloudMachineClient(TokenCredential? credential = default, IConfiguration? configuration = default) + protected CloudMachineClient() + { } +#pragma warning disable AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. + public CloudMachineClient(TokenCredential credential = default, IConfiguration configuration = default) +#pragma warning restore AZC0007 // DO provide a minimal constructor that takes only the parameters required to connect to the service. : base(credential, configuration) { Messaging = new MessagingServices(this); diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineWorkspace.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs similarity index 100% rename from sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/CloudMachineWorkspace.cs rename to sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/MessagingServices.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/MessagingServices.cs similarity index 97% rename from sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/MessagingServices.cs rename to sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/MessagingServices.cs index a67fd23f9961..423bf6092356 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/MessagingServices.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/MessagingServices.cs @@ -5,7 +5,6 @@ using System.Threading.Tasks; using Azure.Core; using Azure.Messaging.ServiceBus; -using Azure.Provisioning.CloudMachine; namespace Azure.CloudMachine; @@ -85,7 +84,7 @@ private ServiceBusProcessor CreateProcessor() ClientConnectionOptions connection = _cm.GetConnectionOptions(typeof(ServiceBusSender)); ServiceBusProcessor processor = client.CreateProcessor( connection.Id, - CloudMachineInfrastructure.SB_PRIVATE_SUB, + "cm_servicebus_subscription_private", new() { ReceiveMode = ServiceBusReceiveMode.PeekLock, MaxConcurrentCalls = 5 }); processor.ProcessErrorAsync += (args) => throw new Exception("error processing event", args.Exception); return processor; diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/StorageFile.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/StorageFile.cs similarity index 91% rename from sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/StorageFile.cs rename to sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/StorageFile.cs index 95518bfe3e77..d0f02f5d6feb 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/StorageFile.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/StorageFile.cs @@ -9,7 +9,7 @@ namespace Azure.CloudMachine; public class StorageFile { - private readonly Response? _response; + private readonly Response _response; private StorageServices _storage; public string Path { get; internal set; } @@ -24,7 +24,7 @@ public class StorageFile /// /// /// returns null if the file is not created as a return value of a service method call. - public static implicit operator Response?(StorageFile result) => result._response; + public static implicit operator Response(StorageFile result) => result._response; public CancellationToken CancellationToken { get; internal set; } @@ -46,7 +46,7 @@ public void Delete() // public Uri ShareFile(AccessPermissions permissions, TimeSpan expiresAfter) // => _storage.ShareFile(Path, permissions, expiresAfter); - internal StorageFile(StorageServices storage, string path, string requestId, Response? response = default) + internal StorageFile(StorageServices storage, string path, string requestId, Response response = default) { _storage = storage; Path = path; diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/StorageServices.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/StorageServices.cs similarity index 93% rename from sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/StorageServices.cs rename to sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/StorageServices.cs index 51c1077e21df..5a3a6576026e 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/OFX/StorageServices.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CoreServices/StorageServices.cs @@ -43,7 +43,7 @@ private BlobContainerClient GetContainer(string containerName) return container; } - public string UploadJson(object json, string? name = default, bool overwrite = false) + public string UploadJson(object json, string name = default, bool overwrite = false) { BlobContainerClient container = GetDefaultContainer(); @@ -61,7 +61,7 @@ public string UploadJson(object json, string? name = default, bool overwrite = f return name; } - public string UploadStream(Stream fileStream, string? name = default, bool overwrite = false) + public string UploadStream(Stream fileStream, string name = default, bool overwrite = false) { BlobContainerClient container = GetDefaultContainer(); @@ -79,7 +79,7 @@ public string UploadStream(Stream fileStream, string? name = default, bool overw return name; } - public string UploadBinaryData(BinaryData data, string? name = default, bool overwrite = false) + public string UploadBinaryData(BinaryData data, string name = default, bool overwrite = false) { BlobContainerClient container = GetDefaultContainer(); if (name == default) @@ -96,9 +96,9 @@ public string UploadBinaryData(BinaryData data, string? name = default, bool ove return name; } - public string UploadBytes(byte[] bytes, string? name = default, bool overwrite = false) + public string UploadBytes(byte[] bytes, string name = default, bool overwrite = false) => UploadBinaryData(BinaryData.FromBytes(bytes), name, overwrite); - public string UploadBytes(ReadOnlyMemory bytes, string? name = default, bool overwrite = false) + public string UploadBytes(ReadOnlyMemory bytes, string name = default, bool overwrite = false) => UploadBinaryData(BinaryData.FromBytes(bytes), name, overwrite); public BinaryData DownloadBlob(string path) @@ -114,7 +114,7 @@ public void DeleteBlob(string path) blob.DeleteIfExists(); } - private BlobClient GetBlobClientFromPath(string path, string? containerName) + private BlobClient GetBlobClientFromPath(string path, string containerName) { var _blobContainer = GetDefaultContainer(); var blobPath = ConvertPathToBlobPath(path, _blobContainer); diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/extensions/AzureOpenAIExtensions.cs b/sdk/cloudmachine/Azure.CloudMachine/src/extensions/AzureOpenAIExtensions.cs new file mode 100644 index 000000000000..14f1265e1939 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/src/extensions/AzureOpenAIExtensions.cs @@ -0,0 +1,75 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.ClientModel; +using Azure.AI.OpenAI; +using Azure.Core; +using OpenAI.Chat; +using OpenAI.Embeddings; + +namespace Azure.CloudMachine.OpenAI; + +public static class AzureOpenAIExtensions +{ + public static ChatClient GetOpenAIChatClient(this ClientWorkspace workspace) + { + ChatClient chatClient = workspace.Subclients.Get(() => + { + AzureOpenAIClient aoiaClient = workspace.Subclients.Get(() => CreateAzureOpenAIClient(workspace)); + return workspace.CreateChatClient(aoiaClient); + }); + + return chatClient; + } + + public static EmbeddingClient GetOpenAIEmbeddingsClient(this ClientWorkspace workspace) + { + EmbeddingClient embeddingsClient = workspace.Subclients.Get(() => + { + AzureOpenAIClient aoiaClient = workspace.Subclients.Get(() => CreateAzureOpenAIClient(workspace)); + return workspace.CreateEmbeddingsClient(aoiaClient); + }); + + return embeddingsClient; + } + + //public static EmbeddingKnowledgebase CreateEmbeddingKnowledgebase(this ClientWorkspace workspace) + //{ + // EmbeddingClient embeddingsClient = workspace.GetOpenAIEmbeddingsClient(); + // return new EmbeddingKnowledgebase(embeddingsClient); + //} + + //public static OpenAIConversation CreateOpenAIConversation(this ClientWorkspace workspace) + //{ + // ChatClient chatClient = workspace.GetOpenAIChatClient(); + // EmbeddingKnowledgebase knowledgebase = workspace.CreateEmbeddingKnowledgebase(); + // return new OpenAIConversation(chatClient, [], knowledgebase); + //} + + private static AzureOpenAIClient CreateAzureOpenAIClient(this ClientWorkspace workspace) + { + ClientConnectionOptions connection = workspace.GetConnectionOptions(typeof(AzureOpenAIClient)); + if (connection.ConnectionKind == ClientConnectionKind.EntraId) + { + return new(connection.Endpoint, connection.TokenCredential); + } + else + { + return new(connection.Endpoint, new ApiKeyCredential(connection.ApiKeyCredential!)); + } + } + + private static ChatClient CreateChatClient(this ClientWorkspace workspace, AzureOpenAIClient client) + { + ClientConnectionOptions connection = workspace.GetConnectionOptions(typeof(ChatClient)); + ChatClient chat = client.GetChatClient(connection.Id); + return chat; + } + + private static EmbeddingClient CreateEmbeddingsClient(this ClientWorkspace workspace, AzureOpenAIClient client) + { + ClientConnectionOptions connection = workspace.GetConnectionOptions(typeof(EmbeddingClient)); + EmbeddingClient embeddings = client.GetEmbeddingClient(connection.Id); + return embeddings; + } +} diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/extensions/KeyVaultExtensions.cs b/sdk/cloudmachine/Azure.CloudMachine/src/extensions/KeyVaultExtensions.cs new file mode 100644 index 000000000000..e6ccc68add15 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/src/extensions/KeyVaultExtensions.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using Azure.Core; +using Azure.Security.KeyVault.Secrets; + +namespace Azure.CloudMachine.KeyVault; + +public static class KeyVaultExtensions +{ + public static SecretClient GetKeyVaultSecretsClient(this ClientWorkspace workspace) + { + ClientConnectionOptions connection = workspace.GetConnectionOptions(typeof(SecretClient)); + if (connection.ConnectionKind == ClientConnectionKind.EntraId) + { + return new(connection.Endpoint, connection.TokenCredential); + } + throw new Exception("API key not supported"); + } +} diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/properties/AssemblyInfo.cs b/sdk/cloudmachine/Azure.CloudMachine/src/properties/AssemblyInfo.cs new file mode 100644 index 000000000000..46a8dfc2e1c2 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/src/properties/AssemblyInfo.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Runtime.CompilerServices; + +// Replace with test project/test project public key and uncomment to make internal members visible to +// your test project. If not needed, this can be deleted. +[assembly: InternalsVisibleTo("Azure.CloudMachine.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100d15ddcb29688295338af4b7686603fe614abd555e09efba8fb88ee09e1f7b1ccaeed2e8f823fa9eef3fdd60217fc012ea67d2479751a0b8c087a4185541b851bd8b16f8d91b840e51b1cb0ba6fe647997e57429265e85ef62d565db50a69ae1647d54d7bd855e4db3d8a91510e5bcbd0edfbbecaa20a7bd9ae74593daa7b11b4")] + +// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment. +// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers +// for the list of possible values. +// [assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.CloudMachine")] diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/Azure.CloudMachine.Tests.csproj b/sdk/cloudmachine/Azure.CloudMachine/tests/Azure.CloudMachine.Tests.csproj new file mode 100644 index 000000000000..7743315c7873 --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/Azure.CloudMachine.Tests.csproj @@ -0,0 +1,14 @@ + + + 12 + + + + + + + + + + + diff --git a/sdk/cloudmachine/Azure.CloudMachine/tests/CloudMachineTests.cs b/sdk/cloudmachine/Azure.CloudMachine/tests/CloudMachineTests.cs new file mode 100644 index 000000000000..992befe970fc --- /dev/null +++ b/sdk/cloudmachine/Azure.CloudMachine/tests/CloudMachineTests.cs @@ -0,0 +1,160 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable enable + +using System; +using System.Threading; +using Azure.Provisioning.CloudMachine; +using Azure.Provisioning.CloudMachine.KeyVault; +using Azure.Provisioning.CloudMachine.OpenAI; +using Azure.Security.KeyVault.Secrets; +using Azure.CloudMachine.OpenAI; +using Azure.CloudMachine.KeyVault; +using NUnit.Framework; +using OpenAI.Chat; + +namespace Azure.CloudMachine.Tests; + +public class CloudMachineTests +{ + [Test] + [TestCase([new string[] { "-bicep" }])] + [TestCase([new string[] { "" }])] + public void Provisioning(string[] args) + { + if (CloudMachineInfrastructure.Configure(args, (cm) => + { + cm.AddFeature(new KeyVaultFeature()); + cm.AddFeature(new OpenAIFeature() // TODO: rework it such that models can be added as features + { + Chat = new AIModel("gpt-35-turbo", "0125"), + Embeddings = new AIModel("text-embedding-ada-002", "2") + }); + })) + return; + + CloudMachineWorkspace cm = new(); + Console.WriteLine(cm.Id); + var embeddings = cm.GetOpenAIEmbeddingsClient(); + } + + [Ignore("no recordings yet")] + [Test] + [TestCase([new string[] { "-bicep" }])] + [TestCase([new string[] { "" }])] + public void Storage(string[] args) + { + ManualResetEventSlim eventSlim = new(false); + if (CloudMachineInfrastructure.Configure(args, (cm) => + { + })) + return; + + CloudMachineClient cm = new(); + + cm.Storage.WhenBlobUploaded((StorageFile file) => + { + var data = file.Download(); + Console.WriteLine(data.ToString()); + Assert.AreEqual("{\"Foo\":5,\"Bar\":true}", data.ToString()); + eventSlim.Set(); + }); + var uploaded = cm.Storage.UploadJson(new + { + Foo = 5, + Bar = true + }); + BinaryData downloaded = cm.Storage.DownloadBlob(uploaded); + Console.WriteLine(downloaded.ToString()); + eventSlim.Wait(); + } + + [Ignore("no recordings yet")] + [Test] + [TestCase([new string[] { "-bicep" }])] + [TestCase([new string[] { "" }])] + public void OpenAI(string[] args) + { + if (CloudMachineInfrastructure.Configure(args, (cm) => + { + cm.AddFeature(new OpenAIFeature() { + Chat = new AIModel("gpt-35-turbo", "0125") + }); + })) + return; + + CloudMachineWorkspace cm = new(); + ChatClient chat = cm.GetOpenAIChatClient(); + ChatCompletion completion = chat.CompleteChat("Is Azure programming easy?"); + + ChatMessageContent content = completion.Content; + foreach (ChatMessageContentPart part in content) + { + Console.WriteLine(part.Text); + } + } + + [Ignore("no recordings yet")] + [Test] + [TestCase([new string[] { "-bicep" }])] + [TestCase([new string[] { "" }])] + public void KeyVault(string[] args) + { + if (CloudMachineInfrastructure.Configure(args, (cm) => + { + cm.AddFeature(new KeyVaultFeature()); + })) + return; + + CloudMachineWorkspace cm = new(); + SecretClient secrets = cm.GetKeyVaultSecretsClient(); + secrets.SetSecret("testsecret", "don't tell anybody"); + } + + [Ignore("no recordings yet")] + [Test] + [TestCase([new string[] { "-bicep" }])] + [TestCase([new string[] { "" }])] + public void Messaging(string[] args) + { + if (CloudMachineInfrastructure.Configure(args)) + return; + + CloudMachineClient cm = new(); + cm.Messaging.WhenMessageReceived(message => + { + Console.WriteLine(message); + Assert.True(message != null); + }); + cm.Messaging.SendMessage(new + { + Foo = 5, + Bar = true + }); + } + + [Ignore("no recordings yet")] + [Test] + [TestCase([new string[] { "-bicep" }])] + [TestCase([new string[] { "" }])] + public void Demo(string[] args) + { + if (CloudMachineInfrastructure.Configure(args)) + return; + + CloudMachineClient cm = new(); + + // setup + cm.Messaging.WhenMessageReceived((string message) => cm.Storage.UploadBinaryData(BinaryData.FromString(message))); + cm.Storage.WhenBlobUploaded((StorageFile file) => + { + var content = file.Download(); + ChatCompletion completion = cm.GetOpenAIChatClient().CompleteChat(content.ToString()); + Console.WriteLine(completion.Content[0].Text); + }); + + // go! + cm.Messaging.SendMessage("Tell me something about Redmond, WA."); + } +} diff --git a/sdk/cloudmachine/ci.yml b/sdk/cloudmachine/ci.yml new file mode 100644 index 000000000000..95b51890061f --- /dev/null +++ b/sdk/cloudmachine/ci.yml @@ -0,0 +1,53 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - main + - hotfix/* + - release/* + paths: + include: + - sdk/cloudmachine/ +#if (false) + # The following paths should only be included in template/ci.yml, and removed from any other SDKs which copy this file. + # The surrounding conditions should accomplish that when installed with `dotnet new azsdk`. + # eng/common code changes trigger template pipeline for basic checking. + - eng/common/ +#endif + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/cloudmachine/ +#if (false) + # The following paths should only be included in template/ci.yml, and removed from any other SDKs which copy this file. + # The surrounding conditions should accomplish that when installed with `dotnet new azsdk`. + # eng/common code changes trigger template pipeline for basic checking. + - eng/common/ +#endif + +# Switch to canary to test canary 1es branch. 1es template validation will set this parameter +# to canary on run. +parameters: +- name: oneESTemplateTag + type: string + default: release + values: + - release + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: cloudmachine + oneESTemplateTag: ${{ parameters.oneESTemplateTag }} + ArtifactName: packages + Artifacts: + - name: Azure.CloudMachine + safeName: AzureCloudMachine diff --git a/sdk/cloudmachine/tests.yml b/sdk/cloudmachine/tests.yml new file mode 100644 index 000000000000..72959bed1222 --- /dev/null +++ b/sdk/cloudmachine/tests.yml @@ -0,0 +1,17 @@ +trigger: none + +# Switch to canary to test canary 1es branch. 1es template validation will set this parameter +# to canary on run. +parameters: +- name: oneESTemplateTag + type: string + default: release + values: + - release + +extends: + template: /eng/pipelines/templates/stages/archetype-sdk-tests.yml + parameters: + ServiceDirectory: cloudmachine + SupportedClouds: 'Public' + oneESTemplateTag: ${{ parameters.oneESTemplateTag }} diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/KeyVaultFeature.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/KeyVaultFeature.cs index 84af47188c4e..710612ab1594 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/KeyVaultFeature.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/KeyVaultFeature.cs @@ -1,12 +1,9 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -using System; -using Azure.Core; using Azure.Provisioning.Authorization; using Azure.Provisioning.Expressions; using Azure.Provisioning.KeyVault; -using Azure.Security.KeyVault.Secrets; namespace Azure.Provisioning.CloudMachine.KeyVault; @@ -61,16 +58,3 @@ public override void AddTo(CloudMachineInfrastructure infrastructure) infrastructure.AddResource(kvMiRoleAssignment); } } - -public static class KeyVaultExtensions -{ - public static SecretClient GetKeyVaultSecretsClient(this ClientWorkspace workspace) - { - ClientConnectionOptions connection = workspace.GetConnectionOptions(typeof(SecretClient)); - if (connection.ConnectionKind == ClientConnectionKind.EntraId) - { - return new(connection.Endpoint, connection.TokenCredential); - } - throw new Exception("API key not supported"); - } -} diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs index 5d4e782d1033..41daf588304a 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs @@ -2,13 +2,8 @@ // Licensed under the MIT License. using System; -using System.ClientModel; -using Azure.AI.OpenAI; -using Azure.Core; using Azure.Provisioning.Authorization; using Azure.Provisioning.CognitiveServices; -using OpenAI.Chat; -using OpenAI.Embeddings; namespace Azure.Provisioning.CloudMachine.OpenAI; @@ -93,68 +88,3 @@ public override void AddTo(CloudMachineInfrastructure cloudMachine) } } } - -public static class AzureOpenAIExtensions -{ - public static ChatClient GetOpenAIChatClient(this ClientWorkspace workspace) - { - ChatClient chatClient = workspace.Subclients.Get(() => - { - AzureOpenAIClient aoiaClient = workspace.Subclients.Get(() => CreateAzureOpenAIClient(workspace)); - return workspace.CreateChatClient(aoiaClient); - }); - - return chatClient; - } - - public static EmbeddingClient GetOpenAIEmbeddingsClient(this ClientWorkspace workspace) - { - EmbeddingClient embeddingsClient = workspace.Subclients.Get(() => - { - AzureOpenAIClient aoiaClient = workspace.Subclients.Get(() => CreateAzureOpenAIClient(workspace)); - return workspace.CreateEmbeddingsClient(aoiaClient); - }); - - return embeddingsClient; - } - - //public static EmbeddingKnowledgebase CreateEmbeddingKnowledgebase(this ClientWorkspace workspace) - //{ - // EmbeddingClient embeddingsClient = workspace.GetOpenAIEmbeddingsClient(); - // return new EmbeddingKnowledgebase(embeddingsClient); - //} - - //public static OpenAIConversation CreateOpenAIConversation(this ClientWorkspace workspace) - //{ - // ChatClient chatClient = workspace.GetOpenAIChatClient(); - // EmbeddingKnowledgebase knowledgebase = workspace.CreateEmbeddingKnowledgebase(); - // return new OpenAIConversation(chatClient, [], knowledgebase); - //} - - private static AzureOpenAIClient CreateAzureOpenAIClient(this ClientWorkspace workspace) - { - ClientConnectionOptions connection = workspace.GetConnectionOptions(typeof(AzureOpenAIClient)); - if (connection.ConnectionKind == ClientConnectionKind.EntraId) - { - return new(connection.Endpoint, connection.TokenCredential); - } - else - { - return new(connection.Endpoint, new ApiKeyCredential(connection.ApiKeyCredential!)); - } - } - - private static ChatClient CreateChatClient(this ClientWorkspace workspace, AzureOpenAIClient client) - { - ClientConnectionOptions connection = workspace.GetConnectionOptions(typeof(ChatClient)); - ChatClient chat = client.GetChatClient(connection.Id); - return chat; - } - - private static EmbeddingClient CreateEmbeddingsClient(this ClientWorkspace workspace, AzureOpenAIClient client) - { - ClientConnectionOptions connection = workspace.GetConnectionOptions(typeof(EmbeddingClient)); - EmbeddingClient embeddings = client.GetEmbeddingClient(connection.Id); - return embeddings; - } -} diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Properties/AssemblyInfo.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Properties/AssemblyInfo.cs index cb4f52ab2e07..fc4d79c9f57f 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Properties/AssemblyInfo.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/Properties/AssemblyInfo.cs @@ -2,3 +2,4 @@ // Licensed under the MIT License. using System.Diagnostics.CodeAnalysis; +using System.Runtime.CompilerServices; diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs index 90cd1a109ff1..ead109ba9dd3 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs @@ -32,127 +32,127 @@ public void Provisioning(string[] args) })) return; - CloudMachineWorkspace cm = new(); - Console.WriteLine(cm.Id); - var embeddings = cm.GetOpenAIEmbeddingsClient(); + // CloudMachineWorkspace cm = new(); + // Console.WriteLine(cm.Id); + // var embeddings = cm.GetOpenAIEmbeddingsClient(); } - [Ignore("no recordings yet")] - [Theory] - [TestCase([new string[] { "-bicep" }])] - [TestCase([new string[] { "" }])] - public void Storage(string[] args) - { - ManualResetEventSlim eventSlim = new(false); - if (CloudMachineInfrastructure.Configure(args, (cm) => - { - })) - return; - - CloudMachineClient cm = new(); - - cm.Storage.WhenBlobUploaded((StorageFile file) => - { - var data = file.Download(); - Console.WriteLine(data.ToString()); - Assert.AreEqual("{\"Foo\":5,\"Bar\":true}", data.ToString()); - eventSlim.Set(); - }); - var uploaded = cm.Storage.UploadJson(new - { - Foo = 5, - Bar = true - }); - BinaryData downloaded = cm.Storage.DownloadBlob(uploaded); - Console.WriteLine(downloaded.ToString()); - eventSlim.Wait(); - } - - [Ignore("no recordings yet")] - [Theory] - [TestCase([new string[] { "-bicep" }])] - [TestCase([new string[] { "" }])] - public void OpenAI(string[] args) - { - if (CloudMachineInfrastructure.Configure(args, (cm) => - { - cm.AddFeature(new OpenAIFeature() { - Chat = new AIModel("gpt-35-turbo", "0125") - }); - })) - return; - - CloudMachineWorkspace cm = new(); - ChatClient chat = cm.GetOpenAIChatClient(); - ChatCompletion completion = chat.CompleteChat("Is Azure programming easy?"); - - ChatMessageContent content = completion.Content; - foreach (ChatMessageContentPart part in content) - { - Console.WriteLine(part.Text); - } - } - - [Ignore("no recordings yet")] - [Theory] - [TestCase([new string[] { "-bicep" }])] - [TestCase([new string[] { "" }])] - public void KeyVault(string[] args) - { - if (CloudMachineInfrastructure.Configure(args, (cm) => - { - cm.AddFeature(new KeyVaultFeature()); - })) - return; - - CloudMachineWorkspace cm = new(); - SecretClient secrets = cm.GetKeyVaultSecretsClient(); - secrets.SetSecret("testsecret", "don't tell anybody"); - } - - [Ignore("no recordings yet")] - [Theory] - [TestCase([new string[] { "-bicep" }])] - [TestCase([new string[] { "" }])] - public void Messaging(string[] args) - { - if (CloudMachineInfrastructure.Configure(args)) - return; - - CloudMachineClient cm = new(); - cm.Messaging.WhenMessageReceived(message => - { - Console.WriteLine(message); - Assert.True(message != null); - }); - cm.Messaging.SendMessage(new - { - Foo = 5, - Bar = true - }); - } - - [Ignore("no recordings yet")] - [Theory] - [TestCase([new string[] { "-bicep" }])] - [TestCase([new string[] { "" }])] - public void Demo(string[] args) - { - if (CloudMachineInfrastructure.Configure(args)) - return; - - CloudMachineClient cm = new(); - - // setup - cm.Messaging.WhenMessageReceived((string message) => cm.Storage.UploadBinaryData(BinaryData.FromString(message))); - cm.Storage.WhenBlobUploaded((StorageFile file) => - { - var content = file.Download(); - ChatCompletion completion = cm.GetOpenAIChatClient().CompleteChat(content.ToString()); - Console.WriteLine(completion.Content[0].Text); - }); - - // go! - cm.Messaging.SendMessage("Tell me something about Redmond, WA."); - } + // [Ignore("no recordings yet")] + // [Theory] + // [TestCase([new string[] { "-bicep" }])] + // [TestCase([new string[] { "" }])] + // public void Storage(string[] args) + // { + // ManualResetEventSlim eventSlim = new(false); + // if (CloudMachineInfrastructure.Configure(args, (cm) => + // { + // })) + // return; + + // CloudMachineClient cm = new(); + + // cm.Storage.WhenBlobUploaded((StorageFile file) => + // { + // var data = file.Download(); + // Console.WriteLine(data.ToString()); + // Assert.AreEqual("{\"Foo\":5,\"Bar\":true}", data.ToString()); + // eventSlim.Set(); + // }); + // var uploaded = cm.Storage.UploadJson(new + // { + // Foo = 5, + // Bar = true + // }); + // BinaryData downloaded = cm.Storage.DownloadBlob(uploaded); + // Console.WriteLine(downloaded.ToString()); + // eventSlim.Wait(); + // } + + // [Ignore("no recordings yet")] + // [Theory] + // [TestCase([new string[] { "-bicep" }])] + // [TestCase([new string[] { "" }])] + // public void OpenAI(string[] args) + // { + // if (CloudMachineInfrastructure.Configure(args, (cm) => + // { + // cm.AddFeature(new OpenAIFeature() { + // Chat = new AIModel("gpt-35-turbo", "0125") + // }); + // })) + // return; + + // CloudMachineWorkspace cm = new(); + // ChatClient chat = cm.GetOpenAIChatClient(); + // ChatCompletion completion = chat.CompleteChat("Is Azure programming easy?"); + + // ChatMessageContent content = completion.Content; + // foreach (ChatMessageContentPart part in content) + // { + // Console.WriteLine(part.Text); + // } + // } + + // [Ignore("no recordings yet")] + // [Theory] + // [TestCase([new string[] { "-bicep" }])] + // [TestCase([new string[] { "" }])] + // public void KeyVault(string[] args) + // { + // if (CloudMachineInfrastructure.Configure(args, (cm) => + // { + // cm.AddFeature(new KeyVaultFeature()); + // })) + // return; + + // CloudMachineWorkspace cm = new(); + // SecretClient secrets = cm.GetKeyVaultSecretsClient(); + // secrets.SetSecret("testsecret", "don't tell anybody"); + // } + + // [Ignore("no recordings yet")] + // [Theory] + // [TestCase([new string[] { "-bicep" }])] + // [TestCase([new string[] { "" }])] + // public void Messaging(string[] args) + // { + // if (CloudMachineInfrastructure.Configure(args)) + // return; + + // CloudMachineClient cm = new(); + // cm.Messaging.WhenMessageReceived(message => + // { + // Console.WriteLine(message); + // Assert.True(message != null); + // }); + // cm.Messaging.SendMessage(new + // { + // Foo = 5, + // Bar = true + // }); + // } + + // [Ignore("no recordings yet")] + // [Theory] + // [TestCase([new string[] { "-bicep" }])] + // [TestCase([new string[] { "" }])] + // public void Demo(string[] args) + // { + // if (CloudMachineInfrastructure.Configure(args)) + // return; + + // CloudMachineClient cm = new(); + + // // setup + // cm.Messaging.WhenMessageReceived((string message) => cm.Storage.UploadBinaryData(BinaryData.FromString(message))); + // cm.Storage.WhenBlobUploaded((StorageFile file) => + // { + // var content = file.Download(); + // ChatCompletion completion = cm.GetOpenAIChatClient().CompleteChat(content.ToString()); + // Console.WriteLine(completion.Content[0].Text); + // }); + + // // go! + // cm.Messaging.SendMessage("Tell me something about Redmond, WA."); + // } } From ac127ac17deecc4dde36a82339635e6ce7cf01b5 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 31 Oct 2024 15:59:06 -0500 Subject: [PATCH 2/8] fixup workspace --- .../src/CloudMachineWorkspace.cs | 97 +++++++++++++++++-- 1 file changed, 88 insertions(+), 9 deletions(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs index 52f734326472..a2c8537e55db 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/src/CloudMachineWorkspace.cs @@ -4,9 +4,11 @@ using System; 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.Provisioning.CloudMachine; using Microsoft.Extensions.Configuration; namespace Azure.CloudMachine; @@ -22,30 +24,30 @@ public class CloudMachineWorkspace : ClientWorkspace public string Id { get; } [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) + public CloudMachineWorkspace(TokenCredential credential = default, IConfiguration configuration = default) { if (credential != default) { Credential = credential; } - string? cmid; + string cmid; if (configuration == default) { - cmid = AzdHelpers.ReadOrCreateCmid(); + cmid = ReadOrCreateCmid(); } else { cmid = configuration["CloudMachine:ID"]; if (cmid == null) - throw new Exception("CloudMachine:ID configuration value missing"); + throw new Exception("CloudMachine:ID configuration value missing"); } Id = cmid!; } [EditorBrowsable(EditorBrowsableState.Never)] - public override ClientConnectionOptions GetConnectionOptions(Type clientType, string? instanceId = default) + public override ClientConnectionOptions GetConnectionOptions(Type clientType, string instanceId = default) { string clientId = clientType.FullName; switch (clientId) @@ -55,10 +57,12 @@ public override ClientConnectionOptions GetConnectionOptions(Type clientType, st case "Azure.Messaging.ServiceBus.ServiceBusClient": return new ClientConnectionOptions(new($"https://{this.Id}.servicebus.windows.net"), Credential); case "Azure.Messaging.ServiceBus.ServiceBusSender": - if (instanceId == default) instanceId = CloudMachineInfrastructure.SB_PRIVATE_TOPIC; + if (instanceId == default) + instanceId = "cm_servicebus_subscription_private"; return new ClientConnectionOptions(instanceId); case "Azure.Storage.Blobs.BlobContainerClient": - if (instanceId == default) instanceId = "default"; + if (instanceId == default) + instanceId = "default"; return new ClientConnectionOptions(new($"https://{this.Id}.blob.core.windows.net/{instanceId}"), Credential); case "Azure.AI.OpenAI.AzureOpenAIClient": return new ClientConnectionOptions(new($"https://{this.Id}.openai.azure.com"), Credential); @@ -72,9 +76,84 @@ public override ClientConnectionOptions GetConnectionOptions(Type clientType, st } [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object? obj) => base.Equals(obj); + 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; + + // TODO: Decide if this should live here. + internal static string ReadOrCreateCmid() + { + string appsettings = Path.Combine(".", "appsettings.json"); + + string cmid; + if (!File.Exists(appsettings)) + { + cmid = GenerateCloudMachineId(); + + using FileStream file = File.OpenWrite(appsettings); + Utf8JsonWriter writer = new Utf8JsonWriter(file); + writer.WriteStartObject(); + writer.WritePropertyName("CloudMachine"u8); + writer.WriteStartObject(); + writer.WriteString("ID"u8, cmid); + writer.WriteEndObject(); + writer.WriteEndObject(); + writer.Flush(); + return cmid; + } + + using FileStream json = File.OpenRead(appsettings); + using JsonDocument jd = JsonDocument.Parse(json); + JsonElement je = jd.RootElement; + // attempt to read CM configuration from existing configuration file + if (je.TryGetProperty("CloudMachine"u8, out JsonElement cm)) + { + if (!cm.TryGetProperty("ID"u8, out JsonElement id)) + { + throw new NotImplementedException(); + } + cmid = id.GetString(); + if (cmid == null) + throw new NotImplementedException(); + return cmid; + } + else + { // add CM configuration to existing file + json.Seek(0, SeekOrigin.Begin); + JsonNode root = JsonNode.Parse(json); + json.Close(); + if (root is null || root is not JsonObject obj) + throw new InvalidOperationException("Existing appsettings.json is not a valid JSON object"); + + var cmProperties = new JsonObject(); + cmid = GenerateCloudMachineId(); + cmProperties.Add("ID", cmid); + obj.Add("CloudMachine", cmProperties); + + using FileStream file = File.OpenWrite(appsettings); + JsonWriterOptions writerOptions = new() + { + Indented = true, + }; + Utf8JsonWriter writer = new(file, writerOptions); + JsonSerializerOptions options = new() + { + WriteIndented = true, + }; + root.WriteTo(writer, options); + writer.Flush(); + } + + return cmid; + + static string GenerateCloudMachineId() + { + var guid = Guid.NewGuid(); + var guidString = guid.ToString("N"); + var cnId = "cm" + guidString.Substring(0, 15); // we can increase it to 20, but the template name cannot be that long + return cnId; + } + } } From 78dcd8e98cc69fde4cb0b04ba6f222dc25d8a6fa Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 31 Oct 2024 16:02:05 -0500 Subject: [PATCH 3/8] cleanup tests --- .../tests/CloudMachineTests.cs | 128 +----------------- 1 file changed, 2 insertions(+), 126 deletions(-) diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs index ead109ba9dd3..123937308de6 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs @@ -21,7 +21,7 @@ public class CloudMachineTests [TestCase([new string[] { "" }])] public void Provisioning(string[] args) { - if (CloudMachineInfrastructure.Configure(args, (cm) => + CloudMachineInfrastructure.Configure(args, (cm) => { cm.AddFeature(new KeyVaultFeature()); cm.AddFeature(new OpenAIFeature() // TODO: rework it such that models can be added as features @@ -29,130 +29,6 @@ public void Provisioning(string[] args) Chat = new AIModel("gpt-35-turbo", "0125"), Embeddings = new AIModel("text-embedding-ada-002", "2") }); - })) - return; - - // CloudMachineWorkspace cm = new(); - // Console.WriteLine(cm.Id); - // var embeddings = cm.GetOpenAIEmbeddingsClient(); + }); } - - // [Ignore("no recordings yet")] - // [Theory] - // [TestCase([new string[] { "-bicep" }])] - // [TestCase([new string[] { "" }])] - // public void Storage(string[] args) - // { - // ManualResetEventSlim eventSlim = new(false); - // if (CloudMachineInfrastructure.Configure(args, (cm) => - // { - // })) - // return; - - // CloudMachineClient cm = new(); - - // cm.Storage.WhenBlobUploaded((StorageFile file) => - // { - // var data = file.Download(); - // Console.WriteLine(data.ToString()); - // Assert.AreEqual("{\"Foo\":5,\"Bar\":true}", data.ToString()); - // eventSlim.Set(); - // }); - // var uploaded = cm.Storage.UploadJson(new - // { - // Foo = 5, - // Bar = true - // }); - // BinaryData downloaded = cm.Storage.DownloadBlob(uploaded); - // Console.WriteLine(downloaded.ToString()); - // eventSlim.Wait(); - // } - - // [Ignore("no recordings yet")] - // [Theory] - // [TestCase([new string[] { "-bicep" }])] - // [TestCase([new string[] { "" }])] - // public void OpenAI(string[] args) - // { - // if (CloudMachineInfrastructure.Configure(args, (cm) => - // { - // cm.AddFeature(new OpenAIFeature() { - // Chat = new AIModel("gpt-35-turbo", "0125") - // }); - // })) - // return; - - // CloudMachineWorkspace cm = new(); - // ChatClient chat = cm.GetOpenAIChatClient(); - // ChatCompletion completion = chat.CompleteChat("Is Azure programming easy?"); - - // ChatMessageContent content = completion.Content; - // foreach (ChatMessageContentPart part in content) - // { - // Console.WriteLine(part.Text); - // } - // } - - // [Ignore("no recordings yet")] - // [Theory] - // [TestCase([new string[] { "-bicep" }])] - // [TestCase([new string[] { "" }])] - // public void KeyVault(string[] args) - // { - // if (CloudMachineInfrastructure.Configure(args, (cm) => - // { - // cm.AddFeature(new KeyVaultFeature()); - // })) - // return; - - // CloudMachineWorkspace cm = new(); - // SecretClient secrets = cm.GetKeyVaultSecretsClient(); - // secrets.SetSecret("testsecret", "don't tell anybody"); - // } - - // [Ignore("no recordings yet")] - // [Theory] - // [TestCase([new string[] { "-bicep" }])] - // [TestCase([new string[] { "" }])] - // public void Messaging(string[] args) - // { - // if (CloudMachineInfrastructure.Configure(args)) - // return; - - // CloudMachineClient cm = new(); - // cm.Messaging.WhenMessageReceived(message => - // { - // Console.WriteLine(message); - // Assert.True(message != null); - // }); - // cm.Messaging.SendMessage(new - // { - // Foo = 5, - // Bar = true - // }); - // } - - // [Ignore("no recordings yet")] - // [Theory] - // [TestCase([new string[] { "-bicep" }])] - // [TestCase([new string[] { "" }])] - // public void Demo(string[] args) - // { - // if (CloudMachineInfrastructure.Configure(args)) - // return; - - // CloudMachineClient cm = new(); - - // // setup - // cm.Messaging.WhenMessageReceived((string message) => cm.Storage.UploadBinaryData(BinaryData.FromString(message))); - // cm.Storage.WhenBlobUploaded((StorageFile file) => - // { - // var content = file.Download(); - // ChatCompletion completion = cm.GetOpenAIChatClient().CompleteChat(content.ToString()); - // Console.WriteLine(completion.Content[0].Text); - // }); - - // // go! - // cm.Messaging.SendMessage("Tell me something about Redmond, WA."); - // } } From 232a80fbff226ed3015985aa271d8c3463c9badb Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 31 Oct 2024 16:19:48 -0500 Subject: [PATCH 4/8] export --- .../api/Azure.CloudMachine.netstandard2.0.cs | 127 ++++++++++++++---- ...rovisioning.CloudMachine.netstandard2.0.cs | 105 --------------- 2 files changed, 98 insertions(+), 134 deletions(-) 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 28cd3bda804d..b4b677372e74 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs +++ b/sdk/cloudmachine/Azure.CloudMachine/api/Azure.CloudMachine.netstandard2.0.cs @@ -1,43 +1,112 @@ -namespace Azure.Template +namespace Azure.CloudMachine { - public partial class TemplateClient + public partial class CloudMachineClient : Azure.CloudMachine.CloudMachineWorkspace { - protected TemplateClient() { } - public TemplateClient(string vaultBaseUrl, Azure.Core.TokenCredential credential) { } - public TemplateClient(string vaultBaseUrl, Azure.Core.TokenCredential credential, Azure.Template.TemplateClientOptions options) { } - public virtual Azure.Core.Pipeline.HttpPipeline Pipeline { get { throw null; } } - public virtual Azure.Response GetSecret(string secretName, Azure.RequestContext context) { throw null; } - public virtual System.Threading.Tasks.Task GetSecretAsync(string secretName, Azure.RequestContext context) { throw null; } - public virtual Azure.Response GetSecretValue(string secretName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> GetSecretValueAsync(string secretName, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + protected CloudMachineClient() : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration)) { } + public CloudMachineClient(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null) : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration)) { } + public Azure.CloudMachine.MessagingServices Messaging { get { throw null; } } + public Azure.CloudMachine.StorageServices Storage { get { throw null; } } } - public partial class TemplateClientOptions : Azure.Core.ClientOptions + public partial class CloudMachineWorkspace : Azure.Core.ClientWorkspace { - public TemplateClientOptions(Azure.Template.TemplateClientOptions.ServiceVersion version = Azure.Template.TemplateClientOptions.ServiceVersion.V7_0) { } - public enum ServiceVersion - { - V7_0 = 1, - } + public CloudMachineWorkspace(Azure.Core.TokenCredential credential = null, Microsoft.Extensions.Configuration.IConfiguration configuration = null) { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public string Id { 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)] + public override Azure.Core.ClientConnectionOptions GetConnectionOptions(System.Type clientType, string instanceId = null) { 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; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct MessagingServices + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public void SendMessage(object serializable) { } + public void WhenMessageReceived(System.Action received) { } + } + public partial class StorageFile + { + internal StorageFile() { } + public System.Threading.CancellationToken CancellationToken { get { throw null; } } + public string Path { get { throw null; } } + public string RequestId { get { throw null; } } + public void Delete() { } + public System.BinaryData Download() { 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; } + public static implicit operator Azure.Response (Azure.CloudMachine.StorageFile result) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct StorageServices + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public void DeleteBlob(string path) { } + public System.BinaryData DownloadBlob(string path) { throw null; } + public string UploadBinaryData(System.BinaryData data, string name = null, bool overwrite = false) { throw null; } + public string UploadBytes(byte[] bytes, string name = null, bool overwrite = false) { throw null; } + public string UploadBytes(System.ReadOnlyMemory bytes, string name = null, bool overwrite = false) { throw null; } + public string UploadJson(object json, string name = null, bool overwrite = false) { throw null; } + public string UploadStream(System.IO.Stream fileStream, string name = null, bool overwrite = false) { throw null; } + public void WhenBlobUploaded(System.Action function) { } } } -namespace Azure.Template.Models +namespace Azure.CloudMachine.KeyVault { - public partial class SecretBundle + public static partial class KeyVaultExtensions { - internal SecretBundle() { } - public string ContentType { get { throw null; } } - public string Id { get { throw null; } } - public string Kid { get { throw null; } } - public bool? Managed { get { throw null; } } - public System.Collections.Generic.IReadOnlyDictionary Tags { get { throw null; } } - public string Value { get { throw null; } } + public static Azure.Security.KeyVault.Secrets.SecretClient GetKeyVaultSecretsClient(this Azure.Core.ClientWorkspace workspace) { throw null; } } } -namespace Microsoft.Extensions.Azure +namespace Azure.CloudMachine.OpenAI { - public static partial class TemplateClientBuilderExtensions + public static partial class AzureOpenAIExtensions + { + public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; } + public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; } + } +} +namespace Azure.Core +{ + public partial class ClientCache + { + public ClientCache() { } + public T Get(System.Func value, string id = null) where T : class { throw null; } + } + public enum ClientConnectionKind + { + EntraId = 0, + ApiKey = 1, + OutOfBand = 2, + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ClientConnectionOptions + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ClientConnectionOptions(string subclientId) { throw null; } + public ClientConnectionOptions(System.Uri endpoint, Azure.Core.TokenCredential credential) { throw null; } + public ClientConnectionOptions(System.Uri endpoint, string apiKey) { throw null; } + public string ApiKeyCredential { get { throw null; } } + public Azure.Core.ClientConnectionKind ConnectionKind { get { throw null; } } + public System.Uri Endpoint { get { throw null; } } + public string Id { get { throw null; } } + public Azure.Core.TokenCredential TokenCredential { get { throw null; } } + } + public abstract partial class ClientWorkspace { - public static Azure.Core.Extensions.IAzureClientBuilder AddTemplateClient(this TBuilder builder, string vaultBaseUrl) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithCredential { throw null; } - public static Azure.Core.Extensions.IAzureClientBuilder AddTemplateClient(this TBuilder builder, TConfiguration configuration) where TBuilder : Azure.Core.Extensions.IAzureClientFactoryBuilderWithConfiguration { throw null; } + protected ClientWorkspace() { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public Azure.Core.ClientCache Subclients { get { throw null; } } + public abstract Azure.Core.ClientConnectionOptions GetConnectionOptions(System.Type clientType, string instanceId = null); } } diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.netstandard2.0.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.netstandard2.0.cs index 1d40883d684b..779bd3221f8f 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.netstandard2.0.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/api/Azure.Provisioning.CloudMachine.netstandard2.0.cs @@ -1,64 +1,3 @@ -namespace Azure.CloudMachine -{ - public partial class CloudMachineClient : Azure.CloudMachine.CloudMachineWorkspace - { - public CloudMachineClient(Azure.Core.TokenCredential? credential = null, Microsoft.Extensions.Configuration.IConfiguration? configuration = null) : base (default(Azure.Core.TokenCredential), default(Microsoft.Extensions.Configuration.IConfiguration)) { } - public Azure.CloudMachine.MessagingServices Messaging { get { throw null; } } - public Azure.CloudMachine.StorageServices Storage { get { throw null; } } - } - public partial class CloudMachineWorkspace : Azure.Core.ClientWorkspace - { - public CloudMachineWorkspace(Azure.Core.TokenCredential? credential = null, Microsoft.Extensions.Configuration.IConfiguration? configuration = null) { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public string Id { 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)] - public override Azure.Core.ClientConnectionOptions GetConnectionOptions(System.Type clientType, string? instanceId = null) { 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; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct MessagingServices - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public void SendMessage(object serializable) { } - public void WhenMessageReceived(System.Action received) { } - } - public partial class StorageFile - { - internal StorageFile() { } - public System.Threading.CancellationToken CancellationToken { get { throw null; } } - public string Path { get { throw null; } } - public string RequestId { get { throw null; } } - public void Delete() { } - public System.BinaryData Download() { 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; } - public static implicit operator Azure.Response (Azure.CloudMachine.StorageFile result) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override string ToString() { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct StorageServices - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public void DeleteBlob(string path) { } - public System.BinaryData DownloadBlob(string path) { throw null; } - public string UploadBinaryData(System.BinaryData data, string? name = null, bool overwrite = false) { throw null; } - public string UploadBytes(byte[] bytes, string? name = null, bool overwrite = false) { throw null; } - public string UploadBytes(System.ReadOnlyMemory bytes, string? name = null, bool overwrite = false) { throw null; } - public string UploadJson(object json, string? name = null, bool overwrite = false) { throw null; } - public string UploadStream(System.IO.Stream fileStream, string? name = null, bool overwrite = false) { throw null; } - public void WhenBlobUploaded(System.Action function) { } - } -} namespace Azure.CloudMachine.OpenAI { public partial class EmbeddingKnowledgebase @@ -72,41 +11,6 @@ internal OpenAIConversation() { } public string Say(string message) { throw null; } } } -namespace Azure.Core -{ - public partial class ClientCache - { - public ClientCache() { } - public T Get(System.Func value, string? id = null) where T : class { throw null; } - } - public enum ClientConnectionKind - { - EntraId = 0, - ApiKey = 1, - OutOfBand = 2, - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct ClientConnectionOptions - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public ClientConnectionOptions(string subclientId) { throw null; } - public ClientConnectionOptions(System.Uri endpoint, Azure.Core.TokenCredential credential) { throw null; } - public ClientConnectionOptions(System.Uri endpoint, string apiKey) { throw null; } - public string? ApiKeyCredential { get { throw null; } } - public Azure.Core.ClientConnectionKind ConnectionKind { get { throw null; } } - public System.Uri? Endpoint { get { throw null; } } - public string? Id { get { throw null; } } - public Azure.Core.TokenCredential? TokenCredential { get { throw null; } } - } - public abstract partial class ClientWorkspace - { - protected ClientWorkspace() { } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public Azure.Core.ClientCache Subclients { get { throw null; } } - public abstract Azure.Core.ClientConnectionOptions GetConnectionOptions(System.Type clientType, string? instanceId = null); - } -} namespace Azure.Provisioning.CloudMachine { public abstract partial class CloudMachineFeature @@ -130,10 +34,6 @@ public void AddResource(Azure.Provisioning.Primitives.NamedProvisionableConstruc } namespace Azure.Provisioning.CloudMachine.KeyVault { - public static partial class KeyVaultExtensions - { - public static Azure.Security.KeyVault.Secrets.SecretClient GetKeyVaultSecretsClient(this Azure.Core.ClientWorkspace workspace) { throw null; } - } public partial class KeyVaultFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature { public KeyVaultFeature(Azure.Provisioning.KeyVault.KeyVaultSku? sku = null) { } @@ -149,11 +49,6 @@ public AIModel(string model, string modelVersion) { } public string Model { get { throw null; } } public string ModelVersion { get { throw null; } } } - public static partial class AzureOpenAIExtensions - { - public static OpenAI.Chat.ChatClient GetOpenAIChatClient(this Azure.Core.ClientWorkspace workspace) { throw null; } - public static OpenAI.Embeddings.EmbeddingClient GetOpenAIEmbeddingsClient(this Azure.Core.ClientWorkspace workspace) { throw null; } - } public partial class OpenAIFeature : Azure.Provisioning.CloudMachine.CloudMachineFeature { public OpenAIFeature() { } From 61a5ac3ab4e537322f825b90b000032f9f9340a4 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 31 Oct 2024 16:48:35 -0500 Subject: [PATCH 5/8] Update README.md --- sdk/cloudmachine/Azure.CloudMachine/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/cloudmachine/Azure.CloudMachine/README.md b/sdk/cloudmachine/Azure.CloudMachine/README.md index 803fbbdea847..adeb39be8d9c 100644 --- a/sdk/cloudmachine/Azure.CloudMachine/README.md +++ b/sdk/cloudmachine/Azure.CloudMachine/README.md @@ -20,7 +20,7 @@ dotnet add package Azure.CloudMachine --prerelease ## Key concepts -TODO +TODO. ## Examples From 71b951297be3f56abf8a96ed61ae8bc9b0d6151e Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 31 Oct 2024 17:11:45 -0500 Subject: [PATCH 6/8] update codeowners --- .github/CODEOWNERS | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 635a36092482..dc2c72700fb2 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -180,6 +180,12 @@ # ServiceLabel: %Bot Service # ServiceOwners: @sgellock +# PRLabel: %CloudMachine +/sdk/cloudmachine/ @christothes @KrzysztofCwalina + +# ServiceLabel: %ProvCloudMachineisioning +# AzureSdkOwners: @christothes @KrzysztofCwalina + # PRLabel: %Cognitive - Language /sdk/cognitivelanguage/ @quentinRobinson @bidisha-c From 608d1530593acb8b66a7d7006fa9b1be408284f0 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 31 Oct 2024 17:54:59 -0500 Subject: [PATCH 7/8] Update .github/CODEOWNERS Co-authored-by: Jesse Squire --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index dc2c72700fb2..d3d7f6b39f38 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -180,7 +180,7 @@ # ServiceLabel: %Bot Service # ServiceOwners: @sgellock -# PRLabel: %CloudMachine +# PRLabel: %Cloud Machine /sdk/cloudmachine/ @christothes @KrzysztofCwalina # ServiceLabel: %ProvCloudMachineisioning From 72c2e5755815418f2f41c6a9b01c9d49ccdeae24 Mon Sep 17 00:00:00 2001 From: Christopher Scott Date: Thu, 31 Oct 2024 17:55:21 -0500 Subject: [PATCH 8/8] Update .github/CODEOWNERS Co-authored-by: Jesse Squire --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index d3d7f6b39f38..873d3d8353d3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -183,7 +183,7 @@ # PRLabel: %Cloud Machine /sdk/cloudmachine/ @christothes @KrzysztofCwalina -# ServiceLabel: %ProvCloudMachineisioning +# ServiceLabel: %Cloud Machine # AzureSdkOwners: @christothes @KrzysztofCwalina # PRLabel: %Cognitive - Language