private void SetStandardProperties(ClientJobRequest request, JobCreateParameters details)
 {
     foreach (var jobRequestParameter in request.Resources)
     {
         details.Files.Add(jobRequestParameter.Value.ToString());
     }
 }
 private JobCreationResults CreateJobSuccessResult(JobCreateParameters details, string jobName)
 {
     return(this.CreateJobSuccessResult(new JobDetails()
     {
         StatusDirectory = details.StatusFolder
     }, jobName));
 }
示例#3
0
 /// <summary>
 /// Creates a new Job, allowing the service to generate a job id. Use
 /// CreateOrUpdate if a user-chosen job id is required.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.WindowsAzure.Scheduler.IJobOperations.
 /// </param>
 /// <param name='parameters'>
 /// Required. Parameters specifying the job definition for a Create Job
 /// operation.
 /// </param>
 /// <returns>
 /// The Create Job operation response.
 /// </returns>
 public static JobCreateResponse Create(this IJobOperations operations, JobCreateParameters parameters)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IJobOperations)s).CreateAsync(parameters);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
示例#4
0
        public JobInformationBasicEx BuildJob(JobCreateParameters parameters)
        {
            FixupCreateJobParameters(parameters);

            var cj            = new CreateJobProperties(parameters.ScriptText, null);
            var bj_parameters = new BuildJobParameters(JobType.USql, cj, parameters.JobName);
            var job_info      = this.RestClients.JobsClient.Job.Build(this.Account.Name, bj_parameters);
            var j             = new JobInformationBasicEx(job_info, this.Account);

            return(j);
        }
示例#5
0
        public JobInformationBasicEx CreateJob(JobCreateParameters parameters)
        {
            FixupCreateJobParameters(parameters);

            var usql_prop_parameters = new CreateUSqlJobProperties(parameters.ScriptText);
            var cj       = new CreateJobParameters(JobType.USql, usql_prop_parameters, parameters.JobName);
            var job_info = this.RestClients.JobsClient.Job.Create(this.Account.Name, parameters.JobId, cj);

            var j = new JobInformationBasicEx(job_info, this.Account);

            return(j);
        }
示例#6
0
        private static void FixupCreateJobParameters(JobCreateParameters parameters)
        {
            // If caller doesn't provide a guid, then create a new one
            if (parameters.JobId == default(System.Guid))
            {
                parameters.JobId = System.Guid.NewGuid();
            }

            // if caller doesn't provide a name, then create one automativally
            if (parameters.JobName == null)
            {
                // TODO: Handle the date part of the name nicely
                parameters.JobName = "USQL " + System.DateTimeOffset.Now.ToString();
            }
        }
        public void Create_Job_with_Syntax_Error()
        {
            this.Initialize();
            var create_job__parameters = new JobCreateParameters();

            create_job__parameters.ScriptText = "FOOBAR";
            create_job__parameters.JobName    = "Test Job";
            var ji = this.AnalyticsClient.Jobs.CreateJob(create_job__parameters);

            System.Console.WriteLine("{0} {1} {2}", ji.Name, ji.JobId, ji.SubmitTime);

            var ji2 = this.AnalyticsClient.Jobs.GetJobDetails(ji.JobId, false);

            Assert.AreEqual(ji.Name, ji2.Name);
        }
        public void Create_500_Jobs()
        {
            this.Initialize();

            int  num_jobs = 500;
            bool doit     = false;

            if (doit)
            {
                for (int i = 0; i < num_jobs; i++)
                {
                    var create_job_parameters = new JobCreateParameters();
                    create_job_parameters.ScriptText = "FOOBAR";
                    create_job_parameters.JobName    = "Test Job " + i.ToString();
                    var ji = this.AnalyticsClient.Jobs.CreateJob(create_job_parameters);
                }
            }
        }
 /// <summary>
 /// If the user wants the server to create the job id then he can use a
 /// POST request to the jobs resource.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.WindowsAzure.Scheduler.IJobOperations.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Create Job operation.
 /// </param>
 /// <returns>
 /// The Create Job operation response.
 /// </returns>
 public static JobCreateResponse Create(this IJobOperations operations, JobCreateParameters parameters)
 {
     try
     {
         return(operations.CreateAsync(parameters).Result);
     }
     catch (AggregateException ex)
     {
         if (ex.InnerExceptions.Count > 1)
         {
             throw;
         }
         else
         {
             throw ex.InnerException;
         }
     }
 }
        public static async Task <JobCreateResponse> startSouceControlJob(AutomationManagementClient automationClient, String resourceGroup, String automationAccount)
        {
            var jobParams = new JobCreateParameters
            {
                Properties = new JobCreateProperties
                {
                    Runbook = new RunbookAssociationProperty
                    {
                        Name = Constants.sourceControlRunbook
                    },
                    Parameters = null
                }
            };

            var jobResponse = await automationClient.Jobs.CreateAsync(resourceGroup,
                                                                      automationAccount, jobParams, new CancellationToken());

            return(jobResponse);
        }
        private string SerializeQueryRequest(string userName, JobCreateParameters details, string jobName, string file, string query, string queryFieldName, ICollection <string> arguments, IDictionary <string, string> defines)
        {
            queryFieldName.ArgumentNotNullOrEmpty("queryFieldName");
            details.ArgumentNotNull("details");

            var values = new List <KeyValuePair <string, string> >();

            values.AddRange(this.SerializeJobRequest(userName, details, jobName, arguments, defines));
            if (query.IsNullOrEmpty())
            {
                file.ArgumentNotNullOrEmpty("file");
                values.Add(new KeyValuePair <string, string>(WebHCatConstants.File, file));
            }
            else
            {
                values.Add(new KeyValuePair <string, string>(queryFieldName, query));
            }

            return(this.ConvertItems(values.Where(kvp => kvp.Value != null)));
        }
示例#12
0
        /// <summary>
        /// Create a new runbook job with specified jobname
        /// </summary>
        /// <param name="resourceGroup"></param>
        /// <param name="automationAccount"></param>
        /// <param name="runbookName"></param>
        /// <param name="jobName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task <Job> CreateJob(string resourceGroup, string automationAccount, string runbookName, string jobName, Dictionary <string, string> parameters)
        {
            try
            {
                //Create parameters for job
                JobCreateParameters jobCreateParameters = new JobCreateParameters(new RunbookAssociationProperty
                {
                    Name = runbookName
                }, parameters);

                //Create job
                return(await Client.Job.CreateAsync(resourceGroup, automationAccount, jobName, jobCreateParameters));
            }
            catch (Exception ex)
            {
                await StaticRepo.SendErrorMessage(ex.Message);

                return(null);
            }
        }
示例#13
0
        /// <summary>
        /// Create a new runbook job with specified jobname
        /// </summary>
        /// <param name="resourceGroup"></param>
        /// <param name="automationAccount"></param>
        /// <param name="runbookName"></param>
        /// <param name="jobName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public async Task <Job> CreateJob(string resourceGroupName, string automationAccountName, string runbookName, string jobName, string hybridWorkergroup, Dictionary <string, string> parameters)
        {
            try
            {
                //TODO: Check if hybridworkergroup exists



                //Create parameters for job
                JobCreateParameters jobCreateParameters = new JobCreateParameters(new RunbookAssociationProperty
                {
                    Name = runbookName
                }, parameters, hybridWorkergroup);

                //Create job
                return(await Client.Job.CreateAsync(resourceGroupName, automationAccountName, jobName, jobCreateParameters));
            }
            catch (Exception ex)
            {
                throw new Exception($"Runbook job could not be created. Error: {ex}");
            }
        }
        /// <summary>
        /// Invokes the specified runbook.
        /// </summary>
        /// <param name="resourceGroupName">Name of the resource group.</param>
        /// <param name="automationAccount">The automation account.</param>
        /// <param name="runbookName">Name of the runbook.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// automationAccount
        /// or
        /// resourceGroupName
        /// or
        /// runbookName
        /// </exception>
        public async Task InvokeRunbookAsync(string resourceGroupName, string automationAccount, string runbookName)
        {
            JobCreateParameters        jcp;
            RunbookAssociationProperty rap;

            if (string.IsNullOrEmpty(automationAccount))
            {
                throw new ArgumentNullException(nameof(automationAccount));
            }
            if (string.IsNullOrEmpty(runbookName))
            {
                throw new ArgumentNullException(nameof(runbookName));
            }
            if (string.IsNullOrEmpty(resourceGroupName))
            {
                throw new ArgumentNullException(nameof(resourceGroupName));
            }

            try
            {
                rap = new RunbookAssociationProperty()
                {
                    Name = runbookName
                };

                jcp = new JobCreateParameters(new JobCreateProperties(rap)
                {
                    Parameters = null
                });

                await Client.Jobs.CreateAsync(resourceGroupName, automationAccount, jcp).ConfigureAwait(false);
            }
            finally
            {
                rap = null;
                jcp = null;
            }
        }
示例#15
0
        public async Task <RunbookJob> StartRunbookAsync(
            string accessToken,
            string subscriptionId,
            string resourceGroupName,
            string automationAccountName,
            string runbookName,
            IDictionary <string, string> runbookParameters = null)
        {
            var credentials = new TokenCloudCredentials(subscriptionId, accessToken);

            using (var client = new AutomationManagementClient(credentials))
            {
                var parameters = new JobCreateParameters(
                    new JobCreateProperties(
                        new RunbookAssociationProperty
                {
                    Name = runbookName
                })
                {
                    Parameters = runbookParameters
                });

                var jobCreateResult = await client.Jobs.CreateAsync(resourceGroupName, automationAccountName, parameters).ConfigureAwait(false);

                return(new RunbookJob
                {
                    JobId = jobCreateResult.Job.Properties.JobId.ToString(),
                    StartDateTime = jobCreateResult.Job.Properties.StartTime,
                    EndDateTime = jobCreateResult.Job.Properties.EndTime,
                    Status = jobCreateResult.Job.Properties.Status,
                    ResourceGroupName = resourceGroupName,
                    AutomationAccountName = automationAccountName,
                    RunbookName = runbookName
                });
            }
        }
        private string SerializeQueryRequest(string userName, JobCreateParameters details, string jobName, string file, string query, string queryFieldName, ICollection<string> arguments, IDictionary<string, string> defines)
        {
            queryFieldName.ArgumentNotNullOrEmpty("queryFieldName");
            details.ArgumentNotNull("details");

            var values = new List<KeyValuePair<string, string>>();
            values.AddRange(this.SerializeJobRequest(userName, details, jobName, arguments, defines));
            if (query.IsNullOrEmpty())
            {
                file.ArgumentNotNullOrEmpty("file");
                values.Add(new KeyValuePair<string, string>(WebHCatConstants.File, file));
            }
            else
            {
                values.Add(new KeyValuePair<string, string>(queryFieldName, query));
            }

            return this.ConvertItems(values.Where(kvp => kvp.Value != null));
        }
示例#17
0
 /// <summary>
 /// Create a job of the runbook.  (see
 /// http://aka.ms/azureautomationsdk/joboperations for more
 /// information)
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.Automation.IJobOperations.
 /// </param>
 /// <param name='automationAccount'>
 /// Required. The automation account name.
 /// </param>
 /// <param name='parameters'>
 /// Required. The parameters supplied to the create job operation.
 /// </param>
 /// <returns>
 /// The response model for the create job operation.
 /// </returns>
 public static Task <JobCreateResponse> CreateAsync(this IJobOperations operations, string automationAccount, JobCreateParameters parameters)
 {
     return(operations.CreateAsync(automationAccount, parameters, CancellationToken.None));
 }
示例#18
0
        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 Job in the given Experiment.
 /// </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='experimentName'>
 /// The name of the experiment. Experiment 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='jobName'>
 /// The name of the job within the specified resource group. Job 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'>
 /// The parameters to provide for job creation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <JobInner> CreateAsync(this IJobsOperations operations, string resourceGroupName, string workspaceName, string experimentName, string jobName, JobCreateParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, workspaceName, experimentName, jobName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
示例#20
0
        public string SerializeJobCreationDetails(JobCreateParameters job)
        {
            if (job.IsNull())
            {
                throw new ArgumentNullException("job");
            }

            if (job.StatusFolder.IsNullOrEmpty())
            {
                job.StatusFolder = "(ignore)";
            }
            var asHiveJob      = job as HiveJobCreateParameters;
            var asMapReduceJob = job as MapReduceJobCreateParameters;
            var jobType        = asHiveJob.IsNotNull() ? "Hive" : "MapReduce";

            if (asHiveJob.IsNull() && asMapReduceJob.IsNull())
            {
                throw new NotSupportedException(string.Format(CultureInfo.InvariantCulture, "Unsupported job type :{0}", job.GetType().FullName));
            }

            var jobName = asHiveJob == null ? asMapReduceJob.JobName : asHiveJob.JobName;

            if (jobName.IsNullOrEmpty())
            {
                throw new ArgumentException("A jobDetails name is required when submitting a jobDetails.", "job");
            }

            dynamic dynaXml = DynaXmlBuilder.Create();

            dynaXml.b
            .xmlns("http://schemas.datacontract.org/2004/07/Microsoft.ClusterServices.RDFEProvider.ResourceExtensions.JobSubmission.Models")
            .xmlns.i("http://www.w3.org/2001/XMLSchema-instance")
            .xmlns.a("http://schemas.microsoft.com/2003/10/Serialization/Arrays")
            .xmlns.s("http://www.w3.org/2001/XMLSchema")
            .ClientJobRequest
            .b
            .End();

            if (asMapReduceJob.IsNotNull() && asMapReduceJob.ClassName.IsNotNullOrEmpty())
            {
                dynaXml.ApplicationName(asMapReduceJob.ClassName);
            }
            else
            {
                dynaXml.ApplicationName.End();
            }

            dynaXml.Arguments
            .b
            .sp("arguments")
            .d
            .End();

            if (asMapReduceJob.IsNotNull() && asMapReduceJob.JarFile.IsNotNullOrEmpty())
            {
                dynaXml.JarFile(asMapReduceJob.JarFile);
            }
            else
            {
                dynaXml.JarFile.End();
            }

            dynaXml.JobName(jobName)
            .JobType(jobType.ToString())
            .OutputStorageLocation(job.StatusFolder)
            .Parameters
            .b
            .sp("parameters")
            .d
            .Query
            .b
            .sp("query")
            .d
            .Resources
            .b
            .sp("resources")
            .d
            .End();

            dynaXml.d.d.End();

            if (asHiveJob.IsNotNull() && asHiveJob.Query.IsNotNull())
            {
                dynaXml.rp("query")
                .text(asHiveJob.Query);

                if (asHiveJob.Defines.IsNotNull())
                {
                    foreach (var parameter in asHiveJob.Defines)
                    {
                        dynaXml.rp("parameters")
                        .JobRequestParameter
                        .b
                        .Key(parameter.Key)
                        .Value
                        .b
                        .at.xmlns.i.type("s:string")
                        .text(parameter.Value)
                        .d
                        .d
                        .End();
                    }
                }
            }
            if (asMapReduceJob.IsNotNull() && asMapReduceJob.Arguments.IsNotNull())
            {
                foreach (var argument in asMapReduceJob.Arguments)
                {
                    dynaXml.rp("arguments").xmlns.a.@string(argument);
                }

                if (asMapReduceJob.Defines.IsNotNull())
                {
                    foreach (var parameter in asMapReduceJob.Defines)
                    {
                        dynaXml.rp("parameters")
                        .JobRequestParameter
                        .b
                        .Key(parameter.Key)
                        .Value
                        .b
                        .at.xmlns.i.type("s:string")
                        .text(parameter.Value)
                        .d
                        .d
                        .End();
                    }
                }
            }

            if (job.Files.IsNotNull())
            {
                foreach (var resource in job.Files)
                {
                    dynaXml.rp("resources")
                    .JobRequestParameter
                    .b
                    .Key(resource)
                    .Value
                    .b
                    .at.xmlns.i.type("s:string")
                    .text(resource)
                    .d
                    .d
                    .End();
                }
            }
            return(dynaXml.ToString());
        }
 /// <summary>
 /// Creates a Job in the given Experiment.
 /// </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='experimentName'>
 /// The name of the experiment. Experiment 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='jobName'>
 /// The name of the job within the specified resource group. Job 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'>
 /// The parameters to provide for job creation.
 /// </param>
 public static Job BeginCreate(this IJobsOperations operations, string resourceGroupName, string workspaceName, string experimentName, string jobName, JobCreateParameters parameters)
 {
     return(operations.BeginCreateAsync(resourceGroupName, workspaceName, experimentName, jobName, parameters).GetAwaiter().GetResult());
 }
        private IEnumerable <KeyValuePair <string, string> > SerializeJobRequest(string userName, JobCreateParameters details, string jobName, ICollection <string> arguments, IDictionary <string, string> defines)
        {
            var values = new List <KeyValuePair <string, string> >();

            if (defines.IsNotNull())
            {
                if (jobName.IsNotNullOrEmpty() && !defines.ContainsKey(WebHCatConstants.DefineJobName))
                {
                    defines.Add(WebHCatConstants.DefineJobName, jobName);
                }

                values.AddRange(this.BuildNameValueList(WebHCatConstants.Define, defines));
            }

            if (arguments.IsNotNull())
            {
                if (jobName.IsNotNullOrEmpty() && defines.IsNull())
                {
                    arguments.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}", WebHCatConstants.DefineJobName, jobName));
                }

                values.AddRange(this.BuildList(WebHCatConstants.Arg, arguments));
            }

            values.Add(new KeyValuePair <string, string>(WebHCatConstants.StatusDirectory, details.StatusFolder));
            values.Add(new KeyValuePair <string, string>(WebHCatConstants.Files, this.BuildCommaSeparatedList(details.Files)));
            values.Add(new KeyValuePair <string, string>(WebHCatConstants.UserName, userName));
            values.Add(new KeyValuePair <string, string>(WebHCatConstants.Callback, details.Callback));
            values.Add(new KeyValuePair <string, string>(HadoopRemoteRestConstants.EnableLogging, details.EnableTaskLogs.ToString().ToLowerInvariant()));

            return(values);
        }
 /// <summary>
 /// Create a job of the runbook.
 /// <see href="http://aka.ms/azureautomationsdk/joboperations" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure Resource group.
 /// </param>
 /// <param name='automationAccountName'>
 /// The name of the automation account.
 /// </param>
 /// <param name='jobName'>
 /// The job name.
 /// </param>
 /// <param name='parameters'>
 /// The parameters supplied to the create job operation.
 /// </param>
 /// <param name='clientRequestId'>
 /// Identifies this specific client request.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Job> CreateAsync(this IJobOperations operations, string resourceGroupName, string automationAccountName, string jobName, JobCreateParameters parameters, string clientRequestId = default(string), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateWithHttpMessagesAsync(resourceGroupName, automationAccountName, jobName, parameters, clientRequestId, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create a job of the runbook.
 /// <see href="http://aka.ms/azureautomationsdk/joboperations" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure Resource group.
 /// </param>
 /// <param name='automationAccountName'>
 /// The name of the automation account.
 /// </param>
 /// <param name='jobName'>
 /// The job name.
 /// </param>
 /// <param name='parameters'>
 /// The parameters supplied to the create job operation.
 /// </param>
 /// <param name='clientRequestId'>
 /// Identifies this specific client request.
 /// </param>
 public static Job Create(this IJobOperations operations, string resourceGroupName, string automationAccountName, string jobName, JobCreateParameters parameters, string clientRequestId = default(string))
 {
     return(operations.CreateAsync(resourceGroupName, automationAccountName, jobName, parameters, clientRequestId).GetAwaiter().GetResult());
 }
        private IEnumerable<KeyValuePair<string, string>> SerializeJobRequest(string userName, JobCreateParameters details, string jobName, ICollection<string> arguments, IDictionary<string, string> defines)
        {
            var values = new List<KeyValuePair<string, string>>();

            if (defines.IsNotNull())
            {
                if (jobName.IsNotNullOrEmpty() && !defines.ContainsKey(WebHCatConstants.DefineJobName))
                {
                    defines.Add(WebHCatConstants.DefineJobName, jobName);
                }

                values.AddRange(this.BuildNameValueList(WebHCatConstants.Define, defines));
            }

            if (arguments.IsNotNull())
            {
                if (jobName.IsNotNullOrEmpty() && defines.IsNull())
                {
                    arguments.Add(string.Format(CultureInfo.InvariantCulture, "{0}={1}", WebHCatConstants.DefineJobName, jobName));
                }

                values.AddRange(this.BuildList(WebHCatConstants.Arg, arguments));
            }

            values.Add(new KeyValuePair<string, string>(WebHCatConstants.StatusDirectory, details.StatusFolder));
            values.Add(new KeyValuePair<string, string>(WebHCatConstants.Files, this.BuildCommaSeparatedList(details.Files)));
            values.Add(new KeyValuePair<string, string>(WebHCatConstants.UserName, userName));
            values.Add(new KeyValuePair<string, string>(WebHCatConstants.Callback, details.Callback));
            values.Add(new KeyValuePair<string, string>(HadoopRemoteRestConstants.EnableLogging, details.EnableTaskLogs.ToString().ToLowerInvariant()));

            return values;
        }
 /// <summary>
 /// If the user wants the server to create the job id then he can use a
 /// POST request to the jobs resource.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the Microsoft.WindowsAzure.Scheduler.IJobOperations.
 /// </param>
 /// <param name='parameters'>
 /// Parameters supplied to the Create Job operation.
 /// </param>
 /// <returns>
 /// The Create Job operation response.
 /// </returns>
 public static Task <JobCreateResponse> CreateAsync(this IJobOperations operations, JobCreateParameters parameters)
 {
     return(operations.CreateAsync(parameters, CancellationToken.None));
 }
 private JobCreationResults CreateJobSuccessResult(JobCreateParameters details, string jobName)
 {
     return this.CreateJobSuccessResult(new JobDetails { StatusDirectory = details.StatusFolder }, jobName);
 }