Jaa


How to Automate a Runbook from Service Provider Foundation

 

Updated: May 13, 2016

Applies To: System Center 2012 SP1 - Orchestrator, System Center 2012 R2 Orchestrator

Starting with Service Provider FoundationSystem Center 2012 R2 you can configure Service Management Automation to use Service Provider Foundation. For more information see the "Connect to the SMA web service" section of Manage Web Services and Connections in Service Provider Foundation. You can also invoke runbooks with the older invoke runbook scenario.

You can automate runbooks using Service Management Automation provided that you have configured the Service Management Automation to use Service Provider Foundation by using the Set-SCSPFEventRegisration and Get-SCSPFEventRegistation cmdlets, as shown in the following example.

PS C:\> # This command sets a runbook to be invoked when the Create event for a new virtual machine is raised.  
PS C:\> Set-SCSPFEventRegistration –ResourceName "VMM.VirtualMachine" – ActionName "Create" –RunbookName "Invoke-SampleCmdlet"  
PS C:\>   
PS C:\> # This command gets an event with the Action parameter and stores it in the $event_backup variable.  
PS C:\> $event_backup = Get-SCSPFEventRegistration –Action "Backup"  
  

The remainder of this topic describes the older scenario.

Invoking runbooks (not automation)

You can set a runbook in System Center 2012 - Orchestrator to be run whenever a new virtual machine or new service is created by remote calls to Service Provider Foundation with the Virtual Machine Manager Service. You can set the runbook to be invoked by using the Windows PowerShell Set-SCSPFExtensibleEventHandler cmdlet. Service Provider Foundation raises internal events to invoke the runbook and the runbook will continue to be invoked continuously as long as the extensible event handler is enabled.

Service Provider Foundation will not invoke the runbook if the virtual machine or service was created by other means such as by using Windows PowerShell cmdlets or by using the console in System Center 2012 – Virtual Machine Manager (VMM).

To support the infrastructure for invoking a runbook, Service Provider Foundation calls the Start-SCOrchestratorRunbook cmdlet internally and it does to need to be explicitly called by the user.

Make sure you have the following information and settings applied before you call the Set-SCSPFExtensibleEventHandler cmdlet:

  • The URI to the Orchestrator web service.

  • The identity settings for the Service Provider Foundation Application Pools in Internet Information Services (IIS) Manager must be included in the Orchestrator Users Group. For information about determining the credentials that were applied for Service Provider Foundation, see the "Verify Local user credentials for portal access" section in Verify local user credentials for portal access. For information about adding credentials the Orchestrator Users Group, see How to Change the Orchestrator Users Group.

See Parameters for Runbooks Invoked from Service Provider Foundation for a list of parameters that are automatically provided to the runbook.

To invoke a runbook from Service Provider Foundation

  • Call the Set-SCSPFExtensibleEventHandler with following parameters:

    Parameter Value
    EventName Specify either "VirtualMachineCreated" or "ServiceCreated".
    OrchestratorUri The URI to the Orchestrator web service.
    RunbookPath The local path to the runbook.
    Enable Specify to enable the runbook.

    To disable the runbook from being invoked, omit this parameter.

    Example:

    PS C:\> Set-SCSPFExtensibleEventHandler -EventName "VirtualMachineCreated" -OrchestratorUri "http://east.contoso.com:82/Orchestrator2012/Orchestrator.svc" -RunbookPath "\SPF Runbooks\Extensibility\VM Created" -Enable  
    

To determine what the extensible event handler is set to, call the Get-SCSPFExtensibleEventHandler cmdlet.

To disable a runbook from being invoked

  • Repeat the Get-SCSPFExtensibleEventHandler command but without the Enable parameter. You can also specify empty strings for the OrchestratorUri and Runbookpath parameters as shown in the following example:

    PS C:\> Set-SCSPFExtensibleEventHandler -EventName "VirtualMachineCreated" -OrchestratorUri "" -RunbookPath ""  
    

See Also

Manage Web Services and Connections in Service Provider Foundation
Parameters for Runbooks Invoked from Service Provider Foundation
Extensibility in Service Provider Foundation
Administering Service Provider Foundation
Cmdlets in System Center 2012 - Service Provider Foundation
How to Configure the Orchestrator Web Service to use HTTPS