The Problem
SharePoint workflows, which are based on Microsoft WF, are a great way to automate processes that require human interaction and can be easily managed through SharePoint designer, without any custom development. But when it comes to automating IT processes, Microsoft provides us with another workflows engine called Orchestrator (part of System center). The Orchestrator has a variety of activities and integration packs that make him a powerful tool for implementing IT runbooks.
I needed a solution for users who design SharePoint’s workflows, using the SharePoint designer, to easily create workflows that will include execution of Orchestrator’s runbook. Using the SharePoint OIP (Orchestrator Integration Packs) you can monitor a SharePoint list for a change and execute a runbook as a result (as described here). However, this monitoring approach is based on pooling, so for example, if I’m using the default 30 seconds for pooling interval with the above approach for a task that is usually required once a week, it will generate more than 20,000 unnecessary queries against the SharePoint. Then, when the user will update the list’s item it will take up to 30 seconds before the workflow will start.
And so, it would seem that triggering the runbook from SharePoint will be a much better solution.
The Solution
The SharePoint native way for integration with external resources is using the Business Data Catalog (BDC). Using Visual Studio 2010, I created the “Orchestrator BDC Connector”, which can be deployed as a WSP solution file through the SharePoint Central admin. With that connector installed, you can create a SharePoint external list that will contain all or a filter list of the Orchestrator’s runbooks. To execute a runbook all you need to do is to update the specific runbook item on that external list. The list contains a column called “InitValue” where the updated value on this field will be sent as a parameter to the runbook. In SharePoint designer’s workflows this activity translates to adding the “Update List Item” action to a workflow, picking the desired runbook from the list and setting the parameter’s value. To provide more than one runbook’s parameter you can setup the SharePoint integration pack for Orchestrator. Then, the current “List item Id” can be set as the parameter and using the “Read Item” activity you can access all the rest of the list item’s fields from the runbook.
Required Ingredients:
- Orchestrator Server with runbooks that accepts zero or one parameter
- SharePoint 2010 with the BCD service and the Security storage service enabled and attached to your web application
- SharePoint Designer
- The “Orchestrator BDC connector” (download link at the bottom of this post)
Deployment:
- Deploy the provided WSP File. The connector implements a custom feature receiver that enables it to be automatically deployed also on farms that do not have a root site on port 80 (If you have more than one web application you will still need to deploy it manually).
- Create a new “Secure Storage target application” with the following configurations
- Name: “OrchestratorBdcConnector”
- Type: “Group Restricted”
- Fields:
- Members – group that will have permission to execute the runbooks. I used “All Authenticated Users”
- Set the credential for the new store application:
- Username/Password for a user that has access to execute the Orchestrator’s runbooks. The username should include the domain (Domainusername).
- Url of the Orchestrator web services. The format: http{s}://{OrchestratorServer}:81/Orchestrator2012/Orchestrator.svc/
- Optional – to filter the runbooks list for only a specific folder, type in the “Runbook Prefix Filter” field the required folder path.
- Create an External List based on the “OrchestratorBdcModelInstance” External content type
- Make sure that you can see the runbook list (if not, go back and check the previous steps)
- In SharePoint Designer build a workflow that contains an “Update item” action and update the InitValue field with the required runbook’s parameter value. In the “Find the List Item” section search the required runbook by “FullPath” (you can copy the name from the list you defined in the previous step).
- Execute the workflow and watch the runbook executing