API deployment within skybow Solution Studio is a feature that allows you to deliver your custom solution to the customer environment.
To set some additional properties or settings on the target site that can't be included in a package you can use callback to run post-deployment script that will be executed after the solution API deployment process is finished.
In this article, we examine the example on how to run a custom post-deployment script on the target site using the azure HTTP trigger function. The following script updates predefined Data Lookup column on a site where solution was deployed. The following instruction you can apply to run any post-deployment script.
So, to run post-deployment script it is required to do the following steps:
1). Register publish service for API deployment
In the solution studio you can register the publish service for API deployment. The instruction describes how to do it you can find here: https://my.skybow.com/hc/en-us/articles/360013511159-skybow-API-deployment
2). Granting access using SharePoint App-Only
The simplest way is to register new app principal in SharePoint tenant and grant tenant Full Control permissions to this principal:
3). Create HTTP trigger azure function
There has been attached azure http trigger function code, that updates some predefined Data lookup column on the target site (A site, where the solution will be deployed via API deployment).
In most cases, skybow Data Lookup source list is automatically resolved. When you deploy to another tenant, which has another site collection/sites structure and server-relative URL of the source site for data lookup is different, then skybow Data Lookup will not work. This azure function will update data connection of skybow Data Lookup to the source list with correct references.
This function reads siteurl query string parameter, then load source list by predefined constants and updates DataConnection property of skybow Data Lookup. It requires to edit the index.js and set correct values for settings and other variables of top of function code:
The full function code you can download here. Also you can extend this function and update all Data Lookup in the target SP site.
4). Sent API deployment request
For testing purpose, we will use Postman in order to send request to publishing service:
Authorization: Basic Auth (user name and password should be used from publish service created in step 2)
Headers: Content-Type application/json
In callbackUrl, we set the URL to this azure function and add an additional query string parameter: siteurl – it should be the same URL as in webUrl property of serviceData.