Service Management Automation (SMA) Child runbook not found when starting parent runbook if runbooks published out of order

Imagine a scenario where you have two runbooks; one that is the “parent” and one that is the “child” because the parent runbook calls the child runbook synchronously during execution. If these two runbooks are imported and published in the wrong order, associations between the two runbooks are not made correctly and the parent runbook cannot run.

This is the bug we posted for Service Management Automation.  This is a known limitation with SMA and the product team is working on determining if they can change this behavior.

In the meantime, I have developed a runbook that you can run to republish all runbooks in SMA after you make changes.  This runbook loops through every runbook in SMA, exports it, imports it and then publishes it.  It does this 3 times by default, which should cover the situation where you have 3 generations of runbooks.  (Runbook A calls Runbook B calls Runbook C).  You can run this with more iterations if you like; it doesn’t hurt to run it more.


workflow Republish-AllRunbooks
	Param([System.String]$WebServiceEndpoint = "https://localhost", [System.Int32]$iterations = 3)

		$runbooks = Get-SMARunbook -WebServiceEndpoint $Using:WebServiceEndpoint 

		foreach ($runbook in $runbooks)
			Write-Output ("Saving Runbook " + $runbook.RunbookName + "...")
			$definition = Get-SmaRunbookDefinition -WebServiceEndpoint $Using:WebServiceEndpoint -Id $runbook.RunbookID -Type Published
			$path = Join-Path -Path $env:temp -ChildPath ($runbook.RunbookName + ".ps1")       
			$stream = [System.IO.StreamWriter] $path

		foreach ($count in 1..$Using:iterations)
			Write-Output "========== Publish Iteration number $count"
			foreach ($runbook in $runbooks)
				Write-Output ("Publishing Runbook " + $runbook.RunbookName + "...")
				$path = Join-Path -Path $env:temp -ChildPath ($runbook.RunbookName + ".ps1")       
				Edit-SmaRunbook -WebServiceEndpoint $Using:WebServiceEndpoint -Path $path -Id $runbook.RunbookID -Overwrite
				$PublishId = Publish-SmaRunbook -WebServiceEndpoint $Using:WebServiceEndpoint -Id $runbook.RunbookID    

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: