Clone modifications
Published 01 May 2018
SQL Clone can modify your clones while they are being created by applying a clone template to them via PowerShell (as of version 2.6.0) and via the GUI (as of version 2.6.1).
SQL Clone templates contain a collection of T-SQL scripts that will be run on a clone, in sequence, just after it is created. As with T-SQL image modifications, the scripts will be run as a limited user.
Each template belongs to an image. Each image can have multiple templates available from it, but each clone can only have one template applied to it.
Usage scenario
Suppose you have an image in which you want to clone, but each clone may have different requirements. Creating multiple images could be time consuming and so it may be quicker and easier to have create modified clones based upon your image.
Using the clone modifications feature, a template will update the clone. This all happens as a part of the clone creation workflow - no additional manual work needed, except to specify what work to do.
Using the web UI
Creating templates
You can upload modifications up to a total of 1MB in size using the web UI. For larger modifications, use PowerShell.
Find the image you want to create a template for in the dashboard.
Click on its name to go to the image page.
Select "Create Template".
Specify the name of the template and upload T-SQL script files to run when that template is specified during image creation. Certain variables are automatically injected by SQL Clone and can be used in your scripts to customize them for particular machines and users.
Specifying templates
During the clone creation workflow, SQL Clone will give you the option of choosing a template that will be used to modify your clone. If you don't choose a template, your clone will be created as normal.
Using PowerShell
See the documentation for the New-SqlCloneTemplate and New-SqlClone cmdlets for examples of how to use clone templates with PowerShell.