From 67d9ae16d7ca61b290ceed083df2e86d5d055f4a Mon Sep 17 00:00:00 2001 From: Amit Chauhan <70937115+achauhan-scc@users.noreply.github.com> Date: Wed, 9 Oct 2024 10:17:23 +0530 Subject: [PATCH] upgrading aml nuget package (#3411) --- .../Assets/Code/CodeOperations.cs | 12 ++--- .../Assets/Component/ComponentOperations.cs | 24 ++++----- .../Assets/Data/DataOperations.cs | 46 ++++++++-------- .../Environment/EnvironmentOperations.cs | 14 ++--- .../Assets/Model/ModelOperations.cs | 16 +++--- .../AzureML-Samples-CSharp.csproj | 6 +-- .../Batch/BatchEndpointOperations.cs | 51 +++++++++--------- .../Online/ManagedOnlineEndpointOperations.cs | 53 ++++++++++--------- 8 files changed, 112 insertions(+), 110 deletions(-) diff --git a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Code/CodeOperations.cs b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Code/CodeOperations.cs index cebd1365fa9..b69712eb02a 100644 --- a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Code/CodeOperations.cs +++ b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Code/CodeOperations.cs @@ -19,7 +19,7 @@ internal class CodeOperations /// /// // - public static async Task GetOrCreateCodeVersionAsync( + public static async Task GetOrCreateCodeVersionAsync( ArmClient armClient, ResourceGroupResource resourceGroup, string workspaceName, @@ -32,13 +32,13 @@ public static async Task GetOrCreateCodeVersionAsync( string resourceId = $"{ws.Id}/codes/{codeName}"; var id = new ResourceIdentifier(resourceId); - CodeContainerResource codeContainerDataResource = armClient.GetCodeContainerResource(id); + MachineLearningCodeContainerResource codeContainerDataResource = armClient.GetMachineLearningCodeContainerResource(id); - CodeVersionProperties properties = new CodeVersionProperties { CodeUri = new Uri(codeUri) }; - CodeVersionData data = new CodeVersionData(properties); + MachineLearningCodeVersionProperties properties = new MachineLearningCodeVersionProperties { CodeUri = new Uri(codeUri) }; + MachineLearningCodeVersionData data = new MachineLearningCodeVersionData(properties); - ArmOperation CodeVersionResourceOperation = await codeContainerDataResource.GetCodeVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); - CodeVersionResource codeVersionResource = CodeVersionResourceOperation.Value; + ArmOperation CodeVersionResourceOperation = await codeContainerDataResource.GetMachineLearningCodeVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningCodeVersionResource codeVersionResource = CodeVersionResourceOperation.Value; Console.WriteLine($"codeVersionResource {codeVersionResource.Data.Id} created."); return codeVersionResource; diff --git a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Component/ComponentOperations.cs b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Component/ComponentOperations.cs index 4ea1a1f3162..8deb6e8bd11 100644 --- a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Component/ComponentOperations.cs +++ b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Component/ComponentOperations.cs @@ -20,7 +20,7 @@ internal class ComponentOperations /// /// // - public static async Task GetOrCreateComponentVersionAsync( + public static async Task GetOrCreateComponentVersionAsync( ArmClient armClient, ResourceGroupResource resourceGroup, string workspaceName, @@ -34,7 +34,7 @@ public static async Task GetOrCreateComponentVersionAs string resourceId = $"{ws.Id}/components/{componentName}"; var id = new ResourceIdentifier(resourceId); - ComponentContainerResource componentContainerResource = armClient.GetComponentContainerResource(id); + MachineLearningComponentContainerResource componentContainerResource = armClient.GetMachineLearningComponentContainerResource(id); JObject jsonObject = JObject.Parse(@"{ '$schema': 'https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json', @@ -80,11 +80,11 @@ public static async Task GetOrCreateComponentVersionAs }, }"); - ComponentVersionProperties properties = new ComponentVersionProperties { ComponentSpec = new BinaryData(jsonObject.ToString()) }; - ComponentVersionData data = new ComponentVersionData(properties); + MachineLearningComponentVersionProperties properties = new MachineLearningComponentVersionProperties { ComponentSpec = new BinaryData(jsonObject.ToString()) }; + MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(properties); - ArmOperation componentVersionResourceOperation = await componentContainerResource.GetComponentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); - ComponentVersionResource componentVersionResource = componentVersionResourceOperation.Value; + ArmOperation componentVersionResourceOperation = await componentContainerResource.GetMachineLearningComponentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningComponentVersionResource componentVersionResource = componentVersionResourceOperation.Value; Console.WriteLine($"ComponentVersionResource {componentVersionResource.Id} created."); return componentVersionResource; } @@ -102,7 +102,7 @@ public static async Task GetOrCreateComponentVersionAs /// /// // - public static async Task GetOrCreateComponentVersion_Pipeline_Async( + public static async Task GetOrCreateComponentVersion_Pipeline_Async( ArmClient armClient, ResourceGroupResource resourceGroup, string workspaceName, @@ -116,7 +116,7 @@ public static async Task GetOrCreateComponentVersion_P string resourceId = $"{ws.Id}/components/{componentName}"; var id = new ResourceIdentifier(resourceId); - ComponentContainerResource componentContainerResource = armClient.GetComponentContainerResource(id); + MachineLearningComponentContainerResource componentContainerResource = armClient.GetMachineLearningComponentContainerResource(id); JObject jsonObject = JObject.Parse(@"{ '$schema': 'https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json', @@ -150,11 +150,11 @@ public static async Task GetOrCreateComponentVersion_P }, }"); - ComponentVersionProperties properties = new ComponentVersionProperties { ComponentSpec = new BinaryData(jsonObject.ToString()) }; - ComponentVersionData data = new ComponentVersionData(properties); + MachineLearningComponentVersionProperties properties = new MachineLearningComponentVersionProperties { ComponentSpec = new BinaryData(jsonObject.ToString()) }; + MachineLearningComponentVersionData data = new MachineLearningComponentVersionData(properties); - ArmOperation componentVersionResourceOperation = await componentContainerResource.GetComponentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); - ComponentVersionResource componentVersionResource = componentVersionResourceOperation.Value; + ArmOperation componentVersionResourceOperation = await componentContainerResource.GetMachineLearningComponentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningComponentVersionResource componentVersionResource = componentVersionResourceOperation.Value; Console.WriteLine($"ComponentVersionResource {componentVersionResource.Id} created."); return componentVersionResource; } diff --git a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Data/DataOperations.cs b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Data/DataOperations.cs index a9a913b19fc..c78efde95b2 100644 --- a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Data/DataOperations.cs +++ b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Data/DataOperations.cs @@ -19,7 +19,7 @@ internal class DataOperations /// /// // - public static async Task GetOrCreateDataVersionAsync( + public static async Task GetOrCreateDataVersionAsync( ArmClient armClient, ResourceGroupResource resourceGroup, string workspaceName, @@ -30,16 +30,16 @@ public static async Task GetOrCreateDataVersionAsync( MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); string resourceId = $"{ws.Id}/data/{dataName}"; var id = new ResourceIdentifier(resourceId); - DataContainerResource dataContainerResource = armClient.GetDataContainerResource(id); + MachineLearningDataContainerResource dataContainerResource = armClient.GetMachineLearningDataContainerResource(id); - bool exists = await dataContainerResource.GetDataVersionBases().ExistsAsync(version); + bool exists = await dataContainerResource.GetMachineLearningDataVersions().ExistsAsync(version); - DataVersionBaseResource dataVersionBaseResource; + MachineLearningDataVersionResource dataVersionBaseResource; if (exists) { Console.WriteLine($"DataVersionBaseResource {dataName} exists."); - dataVersionBaseResource = await dataContainerResource.GetDataVersionBases().GetAsync(version); + dataVersionBaseResource = await dataContainerResource.GetMachineLearningDataVersions().GetAsync(version); Console.WriteLine($"DataVersionBaseResource details: {dataVersionBaseResource.Data.Id}"); } else @@ -47,7 +47,7 @@ public static async Task GetOrCreateDataVersionAsync( Console.WriteLine($"Creating DataVersionBaseResource {dataName}"); // UriFolderDataVersion, or UriFileDataVersion or MLTableData - DataVersionBaseProperties properties = new UriFileDataVersion(new Uri("https://pipelinedata.blob.core.windows.net/sampledata/nytaxi/")) + MachineLearningDataVersionProperties properties = new MachineLearningUriFileDataVersion(new Uri("https://pipelinedata.blob.core.windows.net/sampledata/nytaxi/")) { Description = "Test description", Tags = new Dictionary { { "tag-name-1", "tag-value-1" } }, @@ -56,9 +56,9 @@ public static async Task GetOrCreateDataVersionAsync( IsArchived = false, }; - DataVersionBaseData data = new DataVersionBaseData(properties); + MachineLearningDataVersionData data = new MachineLearningDataVersionData(properties); - ArmOperation dataVersionBaseResourceOperation = await dataContainerResource.GetDataVersionBases().CreateOrUpdateAsync(WaitUntil.Completed, version, data); + ArmOperation dataVersionBaseResourceOperation = await dataContainerResource.GetMachineLearningDataVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); dataVersionBaseResource = dataVersionBaseResourceOperation.Value; Console.WriteLine($"DataVersionBaseResource {dataVersionBaseResource.Data.Id} created."); } @@ -77,9 +77,9 @@ public static async Task ListDataAsync( { Console.WriteLine("Listing Datasets in the workspace..."); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - DataContainerCollection dataContainerCollection = ws.GetDataContainers(); - AsyncPageable response = dataContainerCollection.GetAllAsync(); - await foreach (DataContainerResource dataContainerResource in response) + MachineLearningDataContainerCollection dataContainerCollection = ws.GetMachineLearningDataContainers(); + AsyncPageable response = dataContainerCollection.GetAllAsync(); + await foreach (MachineLearningDataContainerResource dataContainerResource in response) { Console.WriteLine(dataContainerResource.Data.Name); } @@ -99,34 +99,34 @@ public static async Task ListDatastoreAsync( { Console.WriteLine("Listing Datastore in the workspace..."); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - DatastoreCollection datastoreCollection = ws.GetDatastores(); - AsyncPageable response = datastoreCollection.GetAllAsync(); - await foreach (DatastoreResource datastoreResource in response) + MachineLearningDatastoreCollection datastoreCollection = ws.GetMachineLearningDatastores(); + AsyncPageable response = datastoreCollection.GetAllAsync(); + await foreach (MachineLearningDatastoreResource datastoreResource in response) { - DatastoreProperties properties = datastoreResource.Data.Properties; + MachineLearningDatastoreProperties properties = datastoreResource.Data.Properties; switch (properties) { - case AzureFileDatastore: - AzureFileDatastore azureFileDatastore = (AzureFileDatastore)datastoreResource.Data.Properties; + case MachineLearningAzureFileDatastore: + MachineLearningAzureFileDatastore azureFileDatastore = (MachineLearningAzureFileDatastore)datastoreResource.Data.Properties; Console.WriteLine($"AccountName {azureFileDatastore.AccountName}"); Console.WriteLine($"FileShareName {azureFileDatastore.FileShareName}"); Console.WriteLine($"Endpoint {azureFileDatastore.Endpoint}"); break; - case AzureBlobDatastore: - AzureBlobDatastore azureBlobDatastore = (AzureBlobDatastore)datastoreResource.Data.Properties; + case MachineLearningAzureBlobDatastore: + MachineLearningAzureBlobDatastore azureBlobDatastore = (MachineLearningAzureBlobDatastore)datastoreResource.Data.Properties; Console.WriteLine($"AccountName {azureBlobDatastore.AccountName}"); Console.WriteLine($"ContainerName {azureBlobDatastore.ContainerName}"); Console.WriteLine($"Endpoint {azureBlobDatastore.Endpoint}"); break; - case AzureDataLakeGen1Datastore: - AzureDataLakeGen1Datastore azureDataLakeGen1Datastore = (AzureDataLakeGen1Datastore)datastoreResource.Data.Properties; + case MachineLearningAzureDataLakeGen1Datastore: + MachineLearningAzureDataLakeGen1Datastore azureDataLakeGen1Datastore = (MachineLearningAzureDataLakeGen1Datastore)datastoreResource.Data.Properties; Console.WriteLine($"StoreName {azureDataLakeGen1Datastore.StoreName}"); break; - case AzureDataLakeGen2Datastore: - AzureDataLakeGen2Datastore azureDataLakeGen2Datastore = (AzureDataLakeGen2Datastore)datastoreResource.Data.Properties; + case MachineLearningAzureDataLakeGen2Datastore: + MachineLearningAzureDataLakeGen2Datastore azureDataLakeGen2Datastore = (MachineLearningAzureDataLakeGen2Datastore)datastoreResource.Data.Properties; Console.WriteLine($"AccountName {azureDataLakeGen2Datastore.AccountName}"); Console.WriteLine($"Filesystem {azureDataLakeGen2Datastore.Filesystem}"); Console.WriteLine($"Endpoint {azureDataLakeGen2Datastore.Endpoint}"); diff --git a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Environment/EnvironmentOperations.cs b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Environment/EnvironmentOperations.cs index 9dbe3b15653..4d6979bb60f 100644 --- a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Environment/EnvironmentOperations.cs +++ b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Environment/EnvironmentOperations.cs @@ -20,7 +20,7 @@ internal class EnvironmentOperations /// /// // - public static async Task GetOrCreateEnvironmentVersionAsync( + public static async Task GetOrCreateEnvironmentVersionAsync( ArmClient armClient, ResourceGroupResource resourceGroup, string workspaceName, @@ -32,7 +32,7 @@ public static async Task GetOrCreateEnvironmentVersi string resourceId = $"{ws.Id}/environments/{environmentName}"; var id = new ResourceIdentifier(resourceId); - EnvironmentContainerResource environmentContainerResource = armClient.GetEnvironmentContainerResource(id); + MachineLearningEnvironmentContainerResource environmentContainerResource = armClient.GetMachineLearningEnvironmentContainerResource(id); var condaDependences = new JObject(); condaDependences["channels"] = new JArray() { "conda-forge" }; @@ -60,20 +60,20 @@ public static async Task GetOrCreateEnvironmentVersi condaDependences["dependencies"] = dependencies; Console.WriteLine($"condaDependences: {condaDependences}"); - EnvironmentVersionProperties properties = new EnvironmentVersionProperties + MachineLearningEnvironmentVersionProperties properties = new MachineLearningEnvironmentVersionProperties { Description = "Test", CondaFile = condaDependences.ToString(), Tags = { { "key1", "value1" }, { "key2", "value2" } }, - OSType = OperatingSystemType.Linux, + OSType = MachineLearningOperatingSystemType.Linux, IsAnonymous = false, Image = "mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04", }; - EnvironmentVersionData data = new EnvironmentVersionData(properties); + MachineLearningEnvironmentVersionData data = new MachineLearningEnvironmentVersionData(properties); - ArmOperation environmentVersionResourceOperation = await environmentContainerResource.GetEnvironmentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); - EnvironmentVersionResource environmentVersionResource = environmentVersionResourceOperation.Value; + ArmOperation environmentVersionResourceOperation = await environmentContainerResource.GetMachineLearningEnvironmentVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningEnvironmentVersionResource environmentVersionResource = environmentVersionResourceOperation.Value; Console.WriteLine($"EnvironmentVersionResource {environmentVersionResource.Data.Id} created."); return environmentVersionResource; diff --git a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Model/ModelOperations.cs b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Model/ModelOperations.cs index 3b4e1eceba1..ac5eafc3fd3 100644 --- a/sdk/dotnet/AzureML-Samples-CSharp/Assets/Model/ModelOperations.cs +++ b/sdk/dotnet/AzureML-Samples-CSharp/Assets/Model/ModelOperations.cs @@ -19,7 +19,7 @@ class ModelOperations /// /// // - public static async Task GetOrCreateModelVersionAsync( + public static async Task GetOrCreateModelVersionAsync( ArmClient armClient, ResourceGroupResource resourceGroup, string workspaceName, @@ -32,25 +32,25 @@ public static async Task GetOrCreateModelVersionAsync( string resourceId = $"{ws.Id}/models/{modelName}"; var id = new ResourceIdentifier(resourceId); - ModelContainerResource modelContainerResource = armClient.GetModelContainerResource(id); + MachineLearningModelContainerResource modelContainerResource = armClient.GetMachineLearningModelContainerResource(id); - ModelVersionProperties properties = new ModelVersionProperties + MachineLearningModelVersionProperties properties = new MachineLearningModelVersionProperties { JobName = "TestJob", Description = "Test Description for ModelContainer", Tags = new Dictionary { { "tag-name-1", "tag-value-1" } }, IsAnonymous = false, Properties = new Dictionary { { "property-name-1", "property-value-1" } }, - Flavors = new Dictionary() { { "python_function", new FlavorData { Data = new Dictionary() { { "loader_module", "test" } } } } }, + Flavors = new Dictionary() { { "python_function", new MachineLearningFlavorData { Data = new Dictionary() { { "loader_module", "test" } } } } }, IsArchived = false, - ModelType = ModelType.CustomModel, + ModelType = "CustomModel", ModelUri = new Uri(modelUri), }; - ModelVersionData data = new ModelVersionData(properties); + MachineLearningModelVersionData data = new MachineLearningModelVersionData(properties); - ArmOperation ModelVersionResourceOperation = await modelContainerResource.GetModelVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); - ModelVersionResource modelVersionResource = ModelVersionResourceOperation.Value; + ArmOperation ModelVersionResourceOperation = await modelContainerResource.GetMachineLearningModelVersions().CreateOrUpdateAsync(WaitUntil.Completed, version, data); + MachineLearningModelVersionResource modelVersionResource = ModelVersionResourceOperation.Value; Console.WriteLine($"ModelVersionResource {modelVersionResource.Data.Id} created."); return modelVersionResource; diff --git a/sdk/dotnet/AzureML-Samples-CSharp/AzureML-Samples-CSharp.csproj b/sdk/dotnet/AzureML-Samples-CSharp/AzureML-Samples-CSharp.csproj index 362359edc47..80d8b9c79d6 100644 --- a/sdk/dotnet/AzureML-Samples-CSharp/AzureML-Samples-CSharp.csproj +++ b/sdk/dotnet/AzureML-Samples-CSharp/AzureML-Samples-CSharp.csproj @@ -13,9 +13,9 @@ - - - + + + diff --git a/sdk/dotnet/AzureML-Samples-CSharp/Endpoints/Batch/BatchEndpointOperations.cs b/sdk/dotnet/AzureML-Samples-CSharp/Endpoints/Batch/BatchEndpointOperations.cs index 04c603b7e0a..3057783c4ed 100644 --- a/sdk/dotnet/AzureML-Samples-CSharp/Endpoints/Batch/BatchEndpointOperations.cs +++ b/sdk/dotnet/AzureML-Samples-CSharp/Endpoints/Batch/BatchEndpointOperations.cs @@ -1,4 +1,5 @@ -using Azure.ResourceManager; +using Azure.Core; +using Azure.ResourceManager; using Azure.ResourceManager.MachineLearning; using Azure.ResourceManager.MachineLearning.Models; using Azure.ResourceManager.Resources; @@ -19,7 +20,7 @@ internal class BatchEndpointOperations /// Location. /// // - public static async Task GetOrCreateBatchEndpointAsync( + public static async Task GetOrCreateBatchEndpointAsync( ResourceGroupResource resourceGroup, string workspaceName, string endpointName, @@ -27,26 +28,26 @@ public static async Task GetOrCreateBatchEndpointAsync( { Console.WriteLine("Creating a BatchEndpoint..."); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - bool exists = await ws.GetBatchEndpoints().ExistsAsync(endpointName); + bool exists = await ws.GetMachineLearningBatchEndpoints().ExistsAsync(endpointName); - BatchEndpointResource endpointResource; + MachineLearningBatchEndpointResource endpointResource; if (exists) { Console.WriteLine($"BatchEndpoint {endpointName} exists."); - endpointResource = await ws.GetBatchEndpoints().GetAsync(endpointName); + endpointResource = await ws.GetMachineLearningBatchEndpoints().GetAsync(endpointName); Console.WriteLine($"BatchEndpointResource details: {endpointResource.Data.Id}"); } else { Console.WriteLine($"BatchEndpoint {endpointName} does not exist."); - BatchEndpointProperties properties = new BatchEndpointProperties(EndpointAuthMode.AADToken) + MachineLearningBatchEndpointProperties properties = new MachineLearningBatchEndpointProperties(MachineLearningEndpointAuthMode.AadToken) { Description = "test batch endpoint", Properties = { { "additionalProp1", "value1" } }, }; - BatchEndpointData data = new BatchEndpointData(location, properties) + MachineLearningBatchEndpointData data = new MachineLearningBatchEndpointData(location, properties) { Kind = "BatchSample", Sku = new MachineLearningSku("Default") @@ -59,7 +60,7 @@ public static async Task GetOrCreateBatchEndpointAsync( Identity = new ManagedServiceIdentity(ResourceManager.Models.ManagedServiceIdentityType.SystemAssigned), }; - ArmOperation endpointResourceOperation = await ws.GetBatchEndpoints().CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); + ArmOperation endpointResourceOperation = await ws.GetMachineLearningBatchEndpoints().CreateOrUpdateAsync(WaitUntil.Completed, endpointName, data); endpointResource = endpointResourceOperation.Value; Console.WriteLine($"BatchEndpointResource {endpointResource.Data.Id} created."); } @@ -85,7 +86,7 @@ public static async Task GetOrCreateBatchEndpointAsync( /// /// // - public static async Task GetOrCreateBatchDeploymentAsync( + public static async Task GetOrCreateBatchDeploymentAsync( ResourceGroupResource resourceGroup, string workspaceName, string endpointName, @@ -98,53 +99,53 @@ public static async Task GetOrCreateBatchDeploymentAsyn { Console.WriteLine("Creating a BatchDeployment..."); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - BatchEndpointResource endpointResource = await ws.GetBatchEndpoints().GetAsync(endpointName); + MachineLearningBatchEndpointResource endpointResource = await ws.GetMachineLearningBatchEndpoints().GetAsync(endpointName); Console.WriteLine(endpointResource.Data.Id); - bool exists = await endpointResource.GetBatchDeployments().ExistsAsync(deploymentName); + bool exists = await endpointResource.GetMachineLearningBatchDeployments().ExistsAsync(deploymentName); - BatchDeploymentResource deploymentResource; + MachineLearningBatchDeploymentResource deploymentResource; if (exists) { Console.WriteLine($"BatchDeployment {deploymentName} exists."); - deploymentResource = await endpointResource.GetBatchDeployments().GetAsync(deploymentName); + deploymentResource = await endpointResource.GetMachineLearningBatchDeployments().GetAsync(deploymentName); Console.WriteLine($"BatchDeploymentResource details: {deploymentResource.Data.Id}"); } else { Console.WriteLine($"BatchDeployment {deploymentName} does not exist."); - BatchDeploymentProperties properties = new BatchDeploymentProperties + MachineLearningBatchDeploymentProperties properties = new MachineLearningBatchDeploymentProperties { Description = "This is a batch deployment", ErrorThreshold = 10, MaxConcurrencyPerInstance = 5, - LoggingLevel = BatchLoggingLevel.Info, + LoggingLevel = MachineLearningBatchLoggingLevel.Info, MiniBatchSize = 10, OutputFileName = "mypredictions.csv", - OutputAction = BatchOutputAction.AppendRow, + OutputAction = MachineLearningBatchOutputAction.AppendRow, Properties = { { "additionalProp1", "value1" } }, EnvironmentId = environmentId, Compute = computeId, - Resources = new ResourceConfiguration { InstanceCount = 1, }, + Resources = new MachineLearningDeploymentResourceConfiguration { InstanceCount = 1, }, EnvironmentVariables = new Dictionary { { "TestVariable", "TestValue" }, }, - RetrySettings = new BatchRetrySettings + RetrySettings = new MachineLearningBatchRetrySettings { MaxRetries = 4, Timeout = new TimeSpan(0, 3, 0), }, - CodeConfiguration = new CodeConfiguration("main.py") + CodeConfiguration = new MachineLearningCodeConfiguration("main.py") { - CodeId = codeArtifactId, + CodeId = new ResourceIdentifier(codeArtifactId), }, - Model = new IdAssetReference(modelId), + Model = new MachineLearningIdAssetReference(new ResourceIdentifier(modelId)), }; - BatchDeploymentData data = new BatchDeploymentData(location, properties) + MachineLearningBatchDeploymentData data = new MachineLearningBatchDeploymentData(location, properties) { Kind = "SampleBatchDeployment", Sku = new MachineLearningSku("Default") @@ -156,7 +157,7 @@ public static async Task GetOrCreateBatchDeploymentAsyn }, }; - ArmOperation endpointResourceOperation = await endpointResource.GetBatchDeployments().CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + ArmOperation endpointResourceOperation = await endpointResource.GetMachineLearningBatchDeployments().CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); deploymentResource = endpointResourceOperation.Value; Console.WriteLine($"BatchDeploymentResource {deploymentResource.Data.Id} created."); } @@ -178,9 +179,9 @@ public static async Task ListBatchDeploymentsAsync( { Console.WriteLine("Listing all Batch deployments in the workspace..."); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - foreach (var edp in ws.GetBatchEndpoints().GetAll()) + foreach (var edp in ws.GetMachineLearningBatchEndpoints().GetAll()) { - foreach (var dep in edp.GetBatchDeployments().GetAll()) + foreach (var dep in edp.GetMachineLearningBatchDeployments().GetAll()) { Console.WriteLine(dep.Data.Name); } diff --git a/sdk/dotnet/AzureML-Samples-CSharp/Endpoints/Online/ManagedOnlineEndpointOperations.cs b/sdk/dotnet/AzureML-Samples-CSharp/Endpoints/Online/ManagedOnlineEndpointOperations.cs index cfa0b2c2ce1..9a92493bbe6 100644 --- a/sdk/dotnet/AzureML-Samples-CSharp/Endpoints/Online/ManagedOnlineEndpointOperations.cs +++ b/sdk/dotnet/AzureML-Samples-CSharp/Endpoints/Online/ManagedOnlineEndpointOperations.cs @@ -1,4 +1,5 @@ -using Azure.MachineLearning.Samples.Shared; +using Azure.Core; +using Azure.MachineLearning.Samples.Shared; using Azure.ResourceManager; using Azure.ResourceManager.MachineLearning; using Azure.ResourceManager.MachineLearning.Models; @@ -20,7 +21,7 @@ internal class ManagedOnlineEndpointOperations /// /// // - public static async Task GetOrCreateOnlineEndpointAsync( + public static async Task GetOrCreateOnlineEndpointAsync( ResourceGroupResource resourceGroup, string workspaceName, string endpointName, @@ -28,19 +29,19 @@ public static async Task GetOrCreateOnlineEndpointAsync( { Console.WriteLine("Creating an OnlineEndpoint..."); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - bool exists = await ws.GetOnlineEndpoints().ExistsAsync(endpointName); + bool exists = await ws.GetMachineLearningOnlineEndpoints().ExistsAsync(endpointName); - OnlineEndpointResource endpointResource; + MachineLearningOnlineEndpointResource endpointResource; if (exists) { Console.WriteLine($"OnlineEndpoint {endpointName} exists."); - endpointResource = await ws.GetOnlineEndpoints().GetAsync(endpointName); + endpointResource = await ws.GetMachineLearningOnlineEndpoints().GetAsync(endpointName); Console.WriteLine($"OnlineEndpointResource details: {endpointResource.Data.Id}"); } else { Console.WriteLine($"OnlineEndpoint {endpointName} does not exist."); - OnlineEndpointProperties properties = new OnlineEndpointProperties(EndpointAuthMode.AMLToken) + MachineLearningOnlineEndpointProperties properties = new MachineLearningOnlineEndpointProperties(MachineLearningEndpointAuthMode.AmlToken) { //ARM resource ID of the compute if it exists. //Compute = "", @@ -54,7 +55,7 @@ public static async Task GetOrCreateOnlineEndpointAsync( }; // ManagedServiceIdentity Identity = new ManagedServiceIdentity(ManagedServiceIdentityType.SystemAssigned); - OnlineEndpointData OnlineEndpointData = new OnlineEndpointData(location, properties) + MachineLearningOnlineEndpointData OnlineEndpointData = new MachineLearningOnlineEndpointData(location, properties) { Kind = "SampleKind", // Identity = ManagedServiceIdentity(Azure.ResourceManager.MachineLearningServices.Models.ManagedServiceIdentityType.SystemAssigned), @@ -70,7 +71,7 @@ public static async Task GetOrCreateOnlineEndpointAsync( }; // new OnlineEndpointTrackedResourceData(Location.WestUS2, properties) { Kind = "SampleKind", Identity = identity }; - ArmOperation endpointResourceOperation = await ws.GetOnlineEndpoints().CreateOrUpdateAsync(WaitUntil.Completed, endpointName, OnlineEndpointData); + ArmOperation endpointResourceOperation = await ws.GetMachineLearningOnlineEndpoints().CreateOrUpdateAsync(WaitUntil.Completed, endpointName, OnlineEndpointData); endpointResource = endpointResourceOperation.Value; Console.WriteLine($"OnlineEndpointResource {endpointResource.Data.Id} created."); } @@ -94,7 +95,7 @@ public static async Task GetOrCreateOnlineEndpointAsync( /// /// // - public static async Task GetOrCreateOnlineDeploymentAsync( + public static async Task GetOrCreateOnlineDeploymentAsync( ResourceGroupResource resourceGroup, string workspaceName, string endpointName, @@ -106,19 +107,19 @@ public static async Task GetOrCreateOnlineDeploymentAs { Console.WriteLine("Creating a OnlineDeployment..."); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - OnlineEndpointResource endpointResource = await ws.GetOnlineEndpoints().GetAsync(endpointName); + MachineLearningOnlineEndpointResource endpointResource = await ws.GetMachineLearningOnlineEndpoints().GetAsync(endpointName); Console.WriteLine(endpointResource.Data.Id); - bool exists = await endpointResource.GetOnlineDeployments().ExistsAsync(deploymentName); + bool exists = await endpointResource.GetMachineLearningOnlineDeployments().ExistsAsync(deploymentName); // https://docs.microsoft.com/azure/machine-learning/how-to-troubleshoot-online-endpoints - OnlineDeploymentResource deploymentResource; + MachineLearningOnlineDeploymentResource deploymentResource; if (exists) { Console.WriteLine($"OnlineDeployment {deploymentName} exists."); - deploymentResource = await endpointResource.GetOnlineDeployments().GetAsync(deploymentName); + deploymentResource = await endpointResource.GetMachineLearningOnlineDeployments().GetAsync(deploymentName); Console.WriteLine($"OnlineDeploymentResource details: {deploymentResource.Data.Id}"); } else @@ -136,27 +137,27 @@ public static async Task GetOrCreateOnlineDeploymentAs //scaleSettings = new DefaultScaleSettings(); - var managedOnlineDeploymentDetails = new ManagedOnlineDeployment + var managedOnlineDeploymentDetails = new MachineLearningManagedOnlineDeployment { Description = "This is a test online deployment", // EgressPublicNetworkAccess=EgressPublicNetworkAccessType.Disabled, // The path to mount the model in custom container. // Custom model mount path for curated environments is not supported // ModelMountPath = "/var/mountpath", - PrivateNetworkConnection = false, + EgressPublicNetworkAccess = MachineLearningEgressPublicNetworkAccessType.Disabled, Properties = { { "additionalProp1", "value1" } }, EnvironmentId = environmentId, EnvironmentVariables = new Dictionary { { "TestVariable", "TestValue" } }, - RequestSettings = new OnlineRequestSettings + RequestSettings = new MachineLearningOnlineRequestSettings { MaxQueueWait = TimeSpan.FromMilliseconds(30), RequestTimeout = TimeSpan.FromMilliseconds(60), MaxConcurrentRequestsPerInstance = 3, }, - LivenessProbe = new ProbeSettings + LivenessProbe = new MachineLearningProbeSettings { FailureThreshold = 10, SuccessThreshold = 1, @@ -165,7 +166,7 @@ public static async Task GetOrCreateOnlineDeploymentAs Period = TimeSpan.FromSeconds(2), }, // Only for ManagedOnlineDeployment - ReadinessProbe = new ProbeSettings + ReadinessProbe = new MachineLearningProbeSettings { FailureThreshold = 10, SuccessThreshold = 1, @@ -174,16 +175,16 @@ public static async Task GetOrCreateOnlineDeploymentAs Period = TimeSpan.FromSeconds(2), }, AppInsightsEnabled = false, - CodeConfiguration = new CodeConfiguration("main.py") + CodeConfiguration = new MachineLearningCodeConfiguration("main.py") { - CodeId = codeArtifactId, + CodeId = new ResourceIdentifier(codeArtifactId), }, InstanceType = "Standard_F2s_v2", Model = modelId, // ScaleSettings = new DefaultScaleSettings(), }; - OnlineDeploymentData data = new OnlineDeploymentData(location, managedOnlineDeploymentDetails) + MachineLearningOnlineDeploymentData data = new MachineLearningOnlineDeploymentData(location, managedOnlineDeploymentDetails) { Kind = "SampleKindDeployment", Sku = new MachineLearningSku("Default") @@ -195,7 +196,7 @@ public static async Task GetOrCreateOnlineDeploymentAs }, }; - ArmOperation deploymentResourceOperation = await endpointResource.GetOnlineDeployments().CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); + ArmOperation deploymentResourceOperation = await endpointResource.GetMachineLearningOnlineDeployments().CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, data); deploymentResource = deploymentResourceOperation.Value; Console.WriteLine($"OnlineDeploymentResource {deploymentResource.Data.Id} created."); } @@ -217,9 +218,9 @@ public static async Task ListOnlineDeploymentsAsync( { Console.WriteLine("Listing all Online deployments in the workspace..."); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - foreach (var edp in ws.GetOnlineEndpoints().GetAll()) + foreach (var edp in ws.GetMachineLearningOnlineEndpoints().GetAll()) { - foreach (var dep in edp.GetOnlineDeployments().GetAll()) + foreach (var dep in edp.GetMachineLearningOnlineDeployments().GetAll()) { Console.WriteLine(dep.Data.Name); } @@ -252,12 +253,12 @@ private static async Task InvokeOnlineEndpoint( }"); MachineLearningWorkspaceResource ws = await resourceGroup.GetMachineLearningWorkspaces().GetAsync(workspaceName); - bool exists = await ws.GetOnlineEndpoints().ExistsAsync(endpointName); + bool exists = await ws.GetMachineLearningOnlineEndpoints().ExistsAsync(endpointName); if (exists) { Console.WriteLine($"OnlineEndpoint {endpointName} exists."); - OnlineEndpointResource endpointResource = await ws.GetOnlineEndpoints().GetAsync(endpointName); + MachineLearningOnlineEndpointResource endpointResource = await ws.GetMachineLearningOnlineEndpoints().GetAsync(endpointName); Console.WriteLine($"OnlineEndpointResource details: {endpointResource.Data.Id}"); var scoringUri = endpointResource.Data.Properties.ScoringUri;