Provisioning a VDB via the API and adding a post script to it

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered
Is it possible to provision a DB via the API
and also set up the new VDB to have a post script automatically?

What I'm trying to do is get all developer created VDBs to be done via the API and each one automatically has a post script that runs against their newly created DB.  I don't want this to be optional to the devs, all the VDBs must run this script on creation/refresh.
We have created a powershell module which provisions the VDBs via the API and I'm not sure if we can add post script at provision time.

Our code is something like this 

private dynamic ProvisionDatabase()        {
            var targetEnvironment = new Environment(this.Session).GetEnvironment(this.TargetServerName);
            var targetRepository = new Repository(this.Session).GetRepository(targetEnvironment.reference.Value);
            var snapshot = new Snapshot(this.Session);


            dynamic json = new ExpandoObject();
            json.type = "MSSqlProvisionParameters";

            json.container = new ExpandoObject();
            json.container.type = "MSSqlDatabaseContainer";
   = this.TargetVirtualSourceName;
   = this.TargetGroup;

            json.source = new ExpandoObject();
            json.source.type = "MSSqlVirtualSource";

            json.sourceConfig = new ExpandoObject();
            json.sourceConfig.type = "MSSqlSIConfig";
            json.sourceConfig.repository = targetRepository.reference.Value;
            json.sourceConfig.databaseName = this.TargetPhysicalDatabaseName;
            json.sourceConfig.instance = new ExpandoObject();
            json.sourceConfig.instance.type = "MSSqlInstanceConfig";

            json.timeflowPointParameters = new ExpandoObject();
            json.timeflowPointParameters.type = "TimeflowPointSemantic";
            json.timeflowPointParameters.container = this.DatabaseResult.reference.Value;
            json.timeflowPointParameters.location = "LATEST_SNAPSHOT";

            var result = this.DoPost(json, "/resources/json/delphix/database/provision");
            return result;
Photo of Mark Hayter

Mark Hayter

  • 766 Points 500 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of Scott MacDonald

Scott MacDonald, Staff Engineer

  • 2,722 Points 2k badge 2x thumb
Official Response
Hi Mark,

Yep, the hooks are defined in the MSSqlVirtualSource object (as type String), such as:


described in the API docs under <SERVER>/api/#MSSqlVirtualSource

Hope that helps,


Photo of Mark Hayter

Mark Hayter

  • 766 Points 500 badge 2x thumb
ah thanks Scott...much appreciated