Creating the content deployment job

In this recipe, we will create the second portion of the content deployment connection, the content deployment job. We will use the content deployment path created in the Creating the content deployment path recipe.

How to do it…

Follow these steps to create the content deployment job:

  1. Navigate to Central Administration in your preferred web browser.
  2. Click on General Application Settings.
  3. Click on Configure content deployment paths and jobs from the Content Deployment section.
  4. Select Create Job from the drop-down menu for the content deployment path created in the Creating the content deployment path recipe:
    How to do it…
  5. Provide a name and description for the content deployment job in the Name and Description fields as shown in the following screenshot:
    How to do it…
  6. Select the content deployment path we created in the Creating the content deployment path recipe if it is not already selected.
    How to do it…
  7. Select Run this job on the following schedule for Frequency. The default schedule is once per day. You can configure the schedule to suit your needs.
    How to do it…
  8. Click on OK.

How it works…

The content deployment job defines when and how the content defined in a content deployment path should be deployed. For content deployment jobs with a repeating schedule, a SharePoint timer job will execute the job at the specific interval.

There's more…

A content deployment job may also be created with PowerShell or code using the server-side object model.

Creating the content deployment job using PowerShell

Follow these steps to create the content deployment job using PowerShell:

  1. Get the content deployment path with the Get-SPContentDeploymentPath Cmdlet as follows:
    $path = Get-SPContentDeploymentPath "Staging Deployment Path"
    
  2. Create a new SPDailySchedule object as follows:
    $schedule = New-Object Microsoft.SharePoint.SPDailySchedule
    $schedule.BeginHour = 3
    

    Note

    Any SPSchedule object may be used for the job schedule. This includes SPDailySchedule, SPHourlySchedule, and SPMinuteSchedule.

  3. Create the content deployment job using the New-SPContentDeploymentJob Cmdlet as follows:
    New-SPContentDeploymentJob –Name "Staging Deployment Job" –SPContentDeploymentPath $path –Schedule $schedule –ScheduleEnabled $true
    

Creating the content deployment job with code using the server-side object model

Follow these steps to create the content deployment job with code using the server-side object model:

  1. Get the content deployment path as follows:
    var path = Microsoft.SharePoint.Publishing.Administration.ContentDeploymentPath.GetInstance("Staging Deployment Path");
  2. Create a new content deployment job as follows:
    var job = Microsoft.SharePoint.Publishing.Administration.ContentDeploymentJob.GetAllJobs().Add();
  3. Set the properties of the content deployment job as follows:
    job.Name = "Staging Deployment Job";
    job.IsEnabled = true;
    job.Path = path;
  4. Update the content deployment job using the following line of code:
    job.Update();
  5. Create an SPDailySchedule object as follows:
    var schedule = new SPDailySchedule();
    schedule.BeginHour = 3;
  6. Assign the schedule to the TimerJobDefintion object of the content deployment job as follows:
    job.TimerJobDefinition.Schedule = schedule;
  7. Update the content deployment job using the following line of code:
    job.Update();
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.163.238