public override async Task <Microsoft.Azure.Management.BatchAI.Fluent.IBatchAIWorkspace> CreateResourceAsync(CancellationToken cancellationToken) { WorkspaceCreateParameters createParameters = new WorkspaceCreateParameters(); createParameters.Location = this.RegionName; createParameters.Tags = this.Inner.Tags; SetInner(await this.Manager.Inner.Workspaces.CreateAsync(ResourceGroupName, Name, createParameters, cancellationToken)); return(this); }
public void TestClusterCreationAndDeletion() { var handler1 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler2 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; string workspaceName = "testclustercreationanddeletion_testworkspace"; string clusterName = "testclustercreationanddeletion_testcluster"; using (MockContext context = MockContext.Start(this.GetType())) { var client = Helpers.GetBatchAIClient(context, handler1); var rgClient = Helpers.GetResourceManagementClient(context, handler2); string rgName = Helpers.CreateResourceGroup(rgClient); var createParams = new ClusterCreateParameters() { ScaleSettings = new ScaleSettings() { Manual = new ManualScaleSettings() { TargetNodeCount = 1 } }, VmSize = "STANDARD_D1", UserAccountSettings = new UserAccountSettings() { AdminUserName = Helpers.ADMIN_USER_NAME, AdminUserPassword = Helpers.ADMIN_USER_PASSWORD, }, }; var workspaceCreateParams = new WorkspaceCreateParameters() { Location = Helpers.LOCATION, }; Workspace workspace = client.Workspaces.Create(rgName, workspaceName, workspaceCreateParams); Cluster cluster = client.Clusters.Create(rgName, workspaceName, clusterName, createParams); Helpers.VerifyClusterProperties(clusterName, createParams, cluster); client.Clusters.Delete(rgName, workspaceName, clusterName); } }
public void TestJobCreationAndDeletion() { string workspaceName = "testjobcreationanddeletion_workspace"; string clusterName = "testjobcreationanddeletion_cluster"; string expName = "testjobcreationanddeletion_experiment"; string jobName = "testjobcreationanddeletion_testjob"; var handler1 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; var handler2 = new RecordedDelegatingHandler { StatusCodeToReturn = HttpStatusCode.OK }; using (MockContext context = MockContext.Start(this.GetType())) { var client = Helpers.GetBatchAIClient(context, handler1); var rgClient = Helpers.GetResourceManagementClient(context, handler2); string rgName = Helpers.CreateResourceGroup(rgClient); var clusterCreateParams = new ClusterCreateParameters() { ScaleSettings = new ScaleSettings() { Manual = new ManualScaleSettings() { TargetNodeCount = 1 } }, VmSize = "STANDARD_D1", UserAccountSettings = new UserAccountSettings() { AdminUserName = Helpers.ADMIN_USER_NAME, AdminUserPassword = Helpers.ADMIN_USER_PASSWORD, }, }; var workspaceCreateParams = new WorkspaceCreateParameters() { Location = Helpers.LOCATION, }; Workspace workspace = client.Workspaces.Create(rgName, workspaceName, workspaceCreateParams); Cluster cluster = client.Clusters.Create(rgName, workspaceName, clusterName, clusterCreateParams); Helpers.WaitAllNodesToBeIdle(client, rgName, workspaceName, clusterName); Experiment experiment = client.Experiments.Create(rgName, workspaceName, expName); var jobCreateParams = new JobCreateParameters() { Cluster = new ResourceId(cluster.Id), NodeCount = 1, CustomToolkitSettings = new CustomToolkitSettings() { CommandLine = "echo Hello" }, StdOutErrPathPrefix = "$AZ_BATCHAI_JOB_TEMP", }; client.Jobs.Create(rgName, workspaceName, expName, jobName, jobCreateParams); Helpers.WaitJobSucceeded(client, rgName, workspaceName, expName, jobName); client.Clusters.Delete(rgName, workspaceName, clusterName); client.Jobs.Delete(rgName, workspaceName, expName, jobName); } }
/// <summary> /// Creates a Workspace. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> /// <param name='workspaceName'> /// The name of the workspace. Workspace names can only contain a combination /// of alphanumeric characters along with dash (-) and underscore (_). The name /// must be from 1 through 64 characters long. /// </param> /// <param name='parameters'> /// Workspace creation parameters. /// </param> /// <param name='cancellationToken'> /// The cancellation token. /// </param> public static async Task <Workspace> BeginCreateAsync(this IWorkspacesOperations operations, string resourceGroupName, string workspaceName, WorkspaceCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) { using (var _result = await operations.BeginCreateWithHttpMessagesAsync(resourceGroupName, workspaceName, parameters, null, cancellationToken).ConfigureAwait(false)) { return(_result.Body); } }
/// <summary> /// Creates a Workspace. /// </summary> /// <param name='operations'> /// The operations group for this extension method. /// </param> /// <param name='resourceGroupName'> /// Name of the resource group to which the resource belongs. /// </param> /// <param name='workspaceName'> /// The name of the workspace. Workspace names can only contain a combination /// of alphanumeric characters along with dash (-) and underscore (_). The name /// must be from 1 through 64 characters long. /// </param> /// <param name='parameters'> /// Workspace creation parameters. /// </param> public static Workspace BeginCreate(this IWorkspacesOperations operations, string resourceGroupName, string workspaceName, WorkspaceCreateParameters parameters) { return(operations.BeginCreateAsync(resourceGroupName, workspaceName, parameters).GetAwaiter().GetResult()); }