From d80a9b0eee46afc9bdc4a936b7a0b8bf6e9defc3 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Fri, 1 Nov 2024 12:35:26 -0700 Subject: [PATCH 1/2] fixed some bugs --- .../Azure.CloudMachine.sln | 18 +++++++++++++++ .../src/AzureSdkExtensions/OpenAIFeature.cs | 23 ++++++++++++++++--- .../CDKLevel3/CloudMachineInfrastructure.cs | 6 ++++- .../tests/CloudMachineTests.cs | 14 +++++------ 4 files changed, 50 insertions(+), 11 deletions(-) diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/Azure.CloudMachine.sln b/sdk/provisioning/Azure.Provisioning.CloudMachine/Azure.CloudMachine.sln index 4a3ca5dfef4e7..82d692c72b964 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/Azure.CloudMachine.sln +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/Azure.CloudMachine.sln @@ -7,6 +7,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.CloudMac EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.CloudMachine.Tests", "tests\Azure.Provisioning.CloudMachine.Tests.csproj", "{46DCEF27-4157-4FB6-A283-B8484EC45665}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.CloudMachine", "..\..\cloudmachine\Azure.CloudMachine\src\Azure.CloudMachine.csproj", "{AE9C0E9B-27D9-4220-98DA-0CB6A7936277}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.CloudMachine.Tests", "..\..\cloudmachine\Azure.CloudMachine\tests\Azure.CloudMachine.Tests.csproj", "{246D5F77-0151-40C5-8644-26A468A57CDC}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Azure.Provisioning.Deployment", "..\Azure.Provisioning.Deployment\src\Azure.Provisioning.Deployment.csproj", "{4562F8C1-9FE3-4B68-BBB2-D052B49C915A}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -21,6 +27,18 @@ Global {46DCEF27-4157-4FB6-A283-B8484EC45665}.Debug|Any CPU.Build.0 = Debug|Any CPU {46DCEF27-4157-4FB6-A283-B8484EC45665}.Release|Any CPU.ActiveCfg = Release|Any CPU {46DCEF27-4157-4FB6-A283-B8484EC45665}.Release|Any CPU.Build.0 = Release|Any CPU + {AE9C0E9B-27D9-4220-98DA-0CB6A7936277}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AE9C0E9B-27D9-4220-98DA-0CB6A7936277}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AE9C0E9B-27D9-4220-98DA-0CB6A7936277}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AE9C0E9B-27D9-4220-98DA-0CB6A7936277}.Release|Any CPU.Build.0 = Release|Any CPU + {246D5F77-0151-40C5-8644-26A468A57CDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {246D5F77-0151-40C5-8644-26A468A57CDC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {246D5F77-0151-40C5-8644-26A468A57CDC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {246D5F77-0151-40C5-8644-26A468A57CDC}.Release|Any CPU.Build.0 = Release|Any CPU + {4562F8C1-9FE3-4B68-BBB2-D052B49C915A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4562F8C1-9FE3-4B68-BBB2-D052B49C915A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4562F8C1-9FE3-4B68-BBB2-D052B49C915A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4562F8C1-9FE3-4B68-BBB2-D052B49C915A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs index 41daf588304a5..e15a0183fb26c 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs @@ -2,8 +2,13 @@ // 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; @@ -44,7 +49,7 @@ public override void AddTo(CloudMachineInfrastructure cloudMachine) CognitiveServicesAccountDeployment? chat = default; if (Chat != default) { - chat = new("openai_deployment_chat", "2023-05-01") + chat = new("openai_deployment_chat", "2024-06-01-preview") { Parent = cognitiveServices, Name = cloudMachine.Id, @@ -55,15 +60,22 @@ public override void AddTo(CloudMachineInfrastructure cloudMachine) Name = Chat.Model, Format = "OpenAI", Version = Chat.ModelVersion - } + }, + VersionUpgradeOption = DeploymentModelVersionUpgradeOption.OnceNewDefaultVersionAvailable, + RaiPolicyName = "Microsoft.DefaultV2", }, + Sku = new CognitiveServicesSku + { + Capacity = 120, + Name = "Standard" + } }; cloudMachine.AddResource(chat); } if (Embeddings != null) { - CognitiveServicesAccountDeployment embeddings = new("openai_deployment_embedding", "2023-05-01") + CognitiveServicesAccountDeployment embeddings = new("openai_deployment_embedding", "2024-06-01-preview") { Parent = cognitiveServices, Name = $"{cloudMachine.Id}-embedding", @@ -76,6 +88,11 @@ public override void AddTo(CloudMachineInfrastructure cloudMachine) Version = Embeddings.ModelVersion } }, + Sku = new CognitiveServicesSku + { + Capacity = 120, + Name = "Standard" + } }; // Ensure that additional deployments, are chained using DependsOn. diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/CloudMachineInfrastructure.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/CloudMachineInfrastructure.cs index ac9f5093a161a..913169a1dbdb5 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/CloudMachineInfrastructure.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/CDKLevel3/CloudMachineInfrastructure.cs @@ -168,7 +168,11 @@ public CloudMachineInfrastructure(string cmId) { TopicType = "Microsoft.Storage.StorageAccounts", Source = _storage.Id, - Identity = managedServiceIdentity, + Identity = new() + { + ManagedServiceIdentityType = ManagedServiceIdentityType.UserAssigned, + UserAssignedIdentities = { { BicepFunction.Interpolate($"{Identity.Id}").Compile().ToString(), new UserAssignedIdentityDetails() } } + }, Name = _cmid }; _eventGridSubscription_blobs = new("cm_eventgrid_subscription_blob", "2022-06-15") diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs index 123937308de65..2ea24eab3a09f 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs @@ -18,17 +18,17 @@ public class CloudMachineTests { [Theory] [TestCase([new string[] { "-bicep" }])] - [TestCase([new string[] { "" }])] + [TestCase([new string[] { }])] public void Provisioning(string[] args) { 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") - }); + //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") + //}); }); } } From f92650be9c82fcf6f62f20befb315b1d76402953 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Fri, 1 Nov 2024 12:38:17 -0700 Subject: [PATCH 2/2] fixes --- .../src/AzureSdkExtensions/OpenAIFeature.cs | 5 ----- .../tests/CloudMachineTests.cs | 12 ++++++------ 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/src/AzureSdkExtensions/OpenAIFeature.cs index e15a0183fb26c..676f2554d7831 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; diff --git a/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs b/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs index 2ea24eab3a09f..3a8a6f8d20c24 100644 --- a/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs +++ b/sdk/provisioning/Azure.Provisioning.CloudMachine/tests/CloudMachineTests.cs @@ -23,12 +23,12 @@ public void Provisioning(string[] args) { 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") - //}); + 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") + }); }); } }