• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Models.BatchClient类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.Azure.Commands.Batch.Models.BatchClient的典型用法代码示例。如果您正苦于以下问题:C# BatchClient类的具体用法?C# BatchClient怎么用?C# BatchClient使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BatchClient类属于Microsoft.Azure.Commands.Batch.Models命名空间,在下文中一共展示了BatchClient类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: GetBatchAccountContextWithKeys

        /// <summary>
        /// Get Batch Context with keys
        /// </summary>
        public static BatchAccountContext GetBatchAccountContextWithKeys(BatchController controller, string accountName)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);
            BatchAccountContext context = client.ListKeys(null, accountName);

            return context;
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:10,代码来源:ScenarioTestHelpers.cs


示例2: TerminateJob

        /// <summary>
        /// Terminates a job
        /// </summary>
        public static void TerminateJob(BatchController controller, BatchAccountContext context, string jobId)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            TerminateJobParameters parameters = new TerminateJobParameters(context, jobId, null);

            client.TerminateJob(parameters);
        }
开发者ID:kjohn-msft,项目名称:azure-powershell,代码行数:11,代码来源:ScenarioTestHelpers.cs


示例3: WaitForIdleComputeNode

        /// <summary>
        /// Waits for a compute node to get to the idle state
        /// </summary>
        public static void WaitForIdleComputeNode(BatchController controller, BatchAccountContext context, string poolId, string computeNodeId)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListComputeNodeOptions options = new ListComputeNodeOptions(context, poolId, null, behaviors)
            {
                ComputeNodeId = computeNodeId
            };

            DateTime timeout = DateTime.Now.AddMinutes(2);
            PSComputeNode computeNode = client.ListComputeNodes(options).First();
            if (computeNode.State != ComputeNodeState.Idle)
            {
                if (DateTime.Now > timeout)
                {
                    throw new TimeoutException("Timed out waiting for idle compute node");
                }

                Sleep(5000);
                computeNode = client.ListComputeNodes(options).First();
            }
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:27,代码来源:ScenarioTestHelpers.cs


示例4: CreateTestTask

        /// <summary>
        /// Creates a test task for use in Scenario tests.
        /// </summary>
        public static void CreateTestTask(BatchController controller, BatchAccountContext context, string jobId, string taskId, string cmdLine = "cmd /c dir /s")
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            NewTaskParameters parameters = new NewTaskParameters(context, jobId, null, taskId, behaviors)
            {
                CommandLine = cmdLine,
                RunElevated = true
            };
            
            client.CreateTask(parameters);
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:17,代码来源:ScenarioTestHelpers.cs


示例5: DeleteJob

        /// <summary>
        /// Deletes a job used in a Scenario test.
        /// </summary>
        public static void DeleteJob(BatchController controller, BatchAccountContext context, string jobId)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            client.DeleteJob(context, jobId, behaviors);
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:11,代码来源:ScenarioTestHelpers.cs


示例6: GetPoolCount

        /// <summary>
        /// Gets the number of pools under the specified account
        /// </summary>
        public static int GetPoolCount(BatchController controller, BatchAccountContext context)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListPoolOptions options = new ListPoolOptions(context, behaviors);

            return client.ListPools(options).Count();
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:13,代码来源:ScenarioTestHelpers.cs


示例7: CreateTestJob

        /// <summary>
        /// Creates a test job for use in Scenario tests.
        /// </summary>
        public static void CreateTestJob(BatchController controller, BatchAccountContext context, string jobId)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSPoolInformation poolInfo = new PSPoolInformation();
            poolInfo.PoolId = SharedPool;

            NewJobParameters parameters = new NewJobParameters(context, jobId, behaviors)
            {
                PoolInformation = poolInfo
            };

            client.CreateJob(parameters);
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:19,代码来源:ScenarioTestHelpers.cs


示例8: WaitForRecentJob

        /// <summary>
        /// Waits for a recent job on a workitem and returns its name. If a previous job is specified, this method waits until a new job is created.
        /// </summary>
        public static string WaitForRecentJob(BatchController controller, BatchAccountContext context, string workItemName, string previousJob = null)
        {
            DateTime timeout = DateTime.Now.AddMinutes(2);

            YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListWorkItemOptions options = new ListWorkItemOptions(context, behaviors)
            {
                WorkItemName = workItemName,
                Filter = null,
                MaxCount = Constants.DefaultMaxCount
            };
            PSCloudWorkItem workItem = client.ListWorkItems(options).First();

            while (workItem.ExecutionInformation.RecentJob == null || string.Equals(workItem.ExecutionInformation.RecentJob.Name, previousJob, StringComparison.OrdinalIgnoreCase))
            {
                if (DateTime.Now > timeout)
                {
                    throw new TimeoutException("Timed out waiting for recent job");
                }
                Sleep(5000);
                workItem = client.ListWorkItems(options).First();
            }
            return workItem.ExecutionInformation.RecentJob.Name;
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:30,代码来源:ScenarioTestHelpers.cs


示例9: WaitForTaskCompletion

        /// <summary>
        /// Waits for the specified task to complete
        /// </summary>
        public static void WaitForTaskCompletion(BatchController controller, BatchAccountContext context, string workItemName, string jobName, string taskName)
        {
            YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListTaskOptions options = new ListTaskOptions(context, workItemName, jobName, null, behaviors)
            {
                TaskName = taskName
            };
            IEnumerable<PSCloudTask> tasks = client.ListTasks(options);

            ITaskStateMonitor monitor = context.BatchOMClient.OpenToolbox().CreateTaskStateMonitor();
            monitor.WaitAll(tasks.Select(t => t.omObject), TaskState.Completed, TimeSpan.FromMinutes(2), null, behaviors);
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:18,代码来源:ScenarioTestHelpers.cs


示例10: AddTestCertificate

        /// <summary>
        /// Adds a test certificate for use in Scenario tests. Returns the thumbprint of the cert.
        /// </summary>
        public static string AddTestCertificate(BatchController controller, BatchAccountContext context, string filePath)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            X509Certificate2 cert = new X509Certificate2(filePath);
            ListCertificateOptions getParameters = new ListCertificateOptions(context) 
            { 
                ThumbprintAlgorithm = BatchTestHelpers.TestCertificateAlgorithm, 
                Thumbprint = cert.Thumbprint,
                Select = "thumbprint,state"
            };

            try
            {
                PSCertificate existingCert = client.ListCertificates(getParameters).FirstOrDefault();
                DateTime start = DateTime.Now;
                DateTime end = start.AddMinutes(5);

                // Cert might still be deleting from other tests, so we wait for the delete to finish.
                while (existingCert != null && existingCert.State == CertificateState.Deleting)
                {
                    if (DateTime.Now > end)
                    {
                        throw new TimeoutException("Timed out waiting for existing cert to be deleted.");
                    }
                    Sleep(5000);
                    existingCert = client.ListCertificates(getParameters).FirstOrDefault();
                }
            }
            catch (AggregateException ex)
            {
                foreach (Exception inner in ex.InnerExceptions)
                {
                    BatchException batchEx = inner as BatchException;
                    // When the cert doesn't exist, we get a 404 error. For all other errors, throw.
                    if (batchEx == null || !batchEx.Message.Contains("CertificateNotFound"))
                    {
                        throw;
                    }
                }
            }

            NewCertificateParameters parameters = new NewCertificateParameters(context, null, cert.RawData);

            client.AddCertificate(parameters);

            return cert.Thumbprint;
        }
开发者ID:kjohn-msft,项目名称:azure-powershell,代码行数:51,代码来源:ScenarioTestHelpers.cs


示例11: CreateTestWorkItem

        /// <summary>
        /// Creates a test workitem for use in Scenario tests.
        /// </summary>
        public static void CreateTestWorkItem(BatchController controller, BatchAccountContext context, string workItemName, TimeSpan? recurrenceInterval)
        {
            YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSJobExecutionEnvironment jobExecutionEnvironment = new PSJobExecutionEnvironment();
            jobExecutionEnvironment.PoolName = DefaultPoolName;
            PSWorkItemSchedule schedule = null;
            if (recurrenceInterval != null)
            {
                schedule = new PSWorkItemSchedule();
                schedule.RecurrenceInterval = recurrenceInterval;
            }

            NewWorkItemParameters parameters = new NewWorkItemParameters(context, workItemName, behaviors)
            {
                JobExecutionEnvironment = jobExecutionEnvironment,
                Schedule = schedule
            };

            client.CreateWorkItem(parameters);
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:26,代码来源:ScenarioTestHelpers.cs


示例12: DeleteComputeNodeUser

        /// <summary>
        /// Deletes a compute node user for use in Scenario tests.
        /// </summary>
        public static void DeleteComputeNodeUser(BatchController controller, BatchAccountContext context, string poolId, string computeNodeId, string computeNodeUserName)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ComputeNodeUserOperationParameters parameters = new ComputeNodeUserOperationParameters(context, poolId, computeNodeId, computeNodeUserName);

            client.DeleteComputeNodeUser(parameters);
        }
开发者ID:kjohn-msft,项目名称:azure-powershell,代码行数:11,代码来源:ScenarioTestHelpers.cs


示例13: CreateComputeNodeUser

        /// <summary>
        /// Creates a compute node user for use in Scenario tests.
        /// </summary>
        public static void CreateComputeNodeUser(BatchController controller, BatchAccountContext context, string poolId, string computeNodeId, string computeNodeUserName)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            NewComputeNodeUserParameters parameters = new NewComputeNodeUserParameters(context, poolId, computeNodeId, null)
            {
                ComputeNodeUserName = computeNodeUserName,
                Password = "Password1234!",
            };

            client.CreateComputeNodeUser(parameters);
        }
开发者ID:kjohn-msft,项目名称:azure-powershell,代码行数:15,代码来源:ScenarioTestHelpers.cs


示例14: GetComputeNodeId

        /// <summary>
        /// Gets the id of a compute node in the specified pool
        /// </summary>
        public static string GetComputeNodeId(BatchController controller, BatchAccountContext context, string poolId)
        {
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListComputeNodeOptions options = new ListComputeNodeOptions(context, poolId, null);

            return client.ListComputeNodes(options).First().Id;
        }
开发者ID:kjohn-msft,项目名称:azure-powershell,代码行数:11,代码来源:ScenarioTestHelpers.cs


示例15: WaitForSteadyPoolAllocation

        public static void WaitForSteadyPoolAllocation(BatchController controller, BatchAccountContext context, string poolId)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListPoolOptions options = new ListPoolOptions(context, behaviors)
            {
                PoolId = poolId
            };

            DateTime timeout = DateTime.Now.AddMinutes(2);
            PSCloudPool pool = client.ListPools(options).First();
            while (pool.AllocationState != AllocationState.Steady)
            {
                if (DateTime.Now > timeout)
                {
                    throw new TimeoutException("Timed out waiting for steady allocation state");
                }
                Sleep(5000);
                pool = client.ListPools(options).First();
            }
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:23,代码来源:ScenarioTestHelpers.cs


示例16: DeleteWorkItem

        /// <summary>
        /// Deletes a workitem used in a Scenario test.
        /// </summary>
        public static void DeleteWorkItem(BatchController controller, BatchAccountContext context, string workItemName)
        {
            YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            client.DeleteWorkItem(context, workItemName, behaviors);
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:11,代码来源:ScenarioTestHelpers.cs


示例17: GetPoolCurrentDedicated

        /// <summary>
        /// Gets the CurrentDedicated count from a pool
        /// </summary>
        public static int GetPoolCurrentDedicated(BatchController controller, BatchAccountContext context, string poolId)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            ListPoolOptions options = new ListPoolOptions(context, behaviors)
            {
                PoolId = poolId
            };

            PSCloudPool pool = client.ListPools(options).First();
            return pool.CurrentDedicated.Value;
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:17,代码来源:ScenarioTestHelpers.cs


示例18: CreateTestUser

        /// <summary>
        /// Creates a test user for use in Scenario tests.
        /// </summary>
        public static void CreateTestUser(BatchController controller, BatchAccountContext context, string poolName, string vmName, string vmUserName)
        {
            YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            NewVMUserParameters parameters = new NewVMUserParameters(context, poolName, vmName, null, behaviors)
            {
                VMUserName = vmUserName,
                Password = "Password1234!",
            };

            client.CreateVMUser(parameters);
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:17,代码来源:ScenarioTestHelpers.cs


示例19: CreateTestJobSchedule

        /// <summary>
        /// Creates a test job schedule for use in Scenario tests.
        /// </summary>
        public static void CreateTestJobSchedule(BatchController controller, BatchAccountContext context, string jobScheduleId, TimeSpan? recurrenceInterval)
        {
            RequestInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            PSJobSpecification jobSpecification = new PSJobSpecification();
            jobSpecification.PoolInformation = new PSPoolInformation();
            jobSpecification.PoolInformation.PoolId = SharedPool;
            PSSchedule schedule = new PSSchedule();
            if (recurrenceInterval != null)
            {
                schedule = new PSSchedule();
                schedule.RecurrenceInterval = recurrenceInterval;
            }

            NewJobScheduleParameters parameters = new NewJobScheduleParameters(context, jobScheduleId, behaviors)
            {
                JobSpecification = jobSpecification,
                Schedule = schedule
            };

            client.CreateJobSchedule(parameters);
        }
开发者ID:OliverMichalski,项目名称:azure-powershell,代码行数:27,代码来源:ScenarioTestHelpers.cs


示例20: DeleteUser

        /// <summary>
        /// Deletes a user used in a Scenario test.
        /// </summary>
        public static void DeleteUser(BatchController controller, BatchAccountContext context, string poolName, string vmName, string vmUserName)
        {
            YieldInjectionInterceptor interceptor = CreateHttpRecordingInterceptor();
            BatchClientBehavior[] behaviors = new BatchClientBehavior[] { interceptor };
            BatchClient client = new BatchClient(controller.BatchManagementClient, controller.ResourceManagementClient);

            VMUserOperationParameters parameters = new VMUserOperationParameters(context, poolName, vmName, vmUserName, behaviors);
            client.DeleteVMUser(parameters);
        }
开发者ID:shuainie,项目名称:azure-powershell,代码行数:12,代码来源:ScenarioTestHelpers.cs



注:本文中的Microsoft.Azure.Commands.Batch.Models.BatchClient类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ScenarioTests.BatchController类代码示例发布时间:2022-05-26
下一篇:
C# Transport.TransportAsyncCallbackArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap