Skip to content

Engine Jobs

If a job is inserted onto the ProvEn 1 compatibility queue, it is converted into a ProvEn 2.0 format job and added to the back of the main jobs queue.

Jobs are received from the ProvEn 2.0 format queue, and an instance of the JobHandler orchestrator is triggered. This is the main function that carries the job from start to end, calling out to all other functions in the process.

A Request item is created in the SharePoint Requests List within the tenant’s ProvEnBase site.

If ForceRefreshTemplate is set to true on the request, a new template is always generated.

If not, a check is performed to see if a template of the same name already exists. If a template already exists, generation is skipped and the cached version is used.

If template generation is required, a new template is generated and persisted. This applies any patched, and includes any content types to install from the hub and any extracted files. This process usually takes up to a few minuts, depending on the template size.

If template generation is skipped, metadata is retrieved from the template cache.

If a URL is not provided in the request, the target URL is generated from the site name.

A check is performed to see if a site with the same URL already exists.

If a new site is required, a site is created.

The engine will poll the site until it is regarded as ‘provisioned’ by SharePoint; this refers to the OOTB site provisioning process, and not our template provisioning.

Usually this takes less than a minute, but in some cases it can take considerably longer. The engine will wait around 5 minutes before “giving up”, and assuming the provisioning has completed. In this case it continues with a warning.

As a final check, the site status is checked to ensure it is ‘Active’. If not, it can be assumed that provisioning has failed.

Once ready, if there is an M365 group ID associated with the site, this is returned.

If no new site is required, and it is a teams site, the group ID is fetched and returned.

Content types that originate from the Content Type Hub are not included in the template as PnP Provisioning will create duplicate content types that are detached from the hub. Instead, these are tracked separately, and Graph is used to ‘syndicate’ these types to install them onto the site in the correct manner.

This is one of the most complex parts of the engine, as the API is inconsistent:

  • Sometimes content types are added synchronously, in which case no further action is required.
  • Sometimes content types are added asynchronously, in which case the URL to a long-running job in Graph is returned.
    • In this case, the engine polls the Graph API until the job is complete.
    • A job can occasionally gets ‘stuck’ take an exceptionally long time to complete. If this is detected, the engine will cancel the job and retry.
    • If a retry limit is hit, an error is raised.

The template is loaded from cache, and invoked onto the target site. This is the longest part of the process and can take several minutes depending on the size of the template.

If this is a M365 group site, and a team has been requested, a check is performed to see if the team already exists.

If a team is required and does not exist, a new team is created and attached to the M365 group.

Any channels, tabs, and tags specified in the request are created in the team.

If a new site was created, and the Site Information List was requested, this is created.

If a new site was created, an item is added to the SharePoint Install List.

If a queue message was included in the request, this is sent to the target Service Bus queue.