Overview

When Matrix42 Enterprise runs in the cloud (or another environment, which can't access a specific “local” network), the application server cannot reach systems in your own network, such as Active Directory, file shares or internal databases. A Remote Worker closes this gap. It is a Functional Worker that runs outside of the application and executes the tasks that need access to these resources.

Remote is meant from the point of view of the application. For cloud customers, the Remote Worker is the worker that you install in your own, local network.

Starting with version 26.1, the worker component is called Functional Worker. A Functional Worker that runs outside of the application is called Remote Worker. In earlier versions it was the Matrix42 Worker, and before version 11.0 the Data Gateway. For older versions, see Matrix42 Worker Engine.

 

Choose the Right Approach

The Remote Worker technology is designed primarily for data providers. Use the following approaches in this order of preference:

Approach Use it for Available from
Data provider Importing data from systems in your network. Use a delivered data provider, for example Active Directory. For other sources, create a custom data provider with your own data collector workflow (generic data provider framework). For computer inventory data, use the prepared Generic Inventory data provider. 12.1
PowerShell Execution Engine Running PowerShell scripts on a Remote Worker, for example to call a web API of a system in your network. 26.2
Client workflow Small, clearly delimited steps that the first two approaches do not cover, for example to collect data and return it to the calling workflow. 12.1

Client workflows are not persistent. A client workflow does not create a workflow instance that you can open in the system, and after it has finished, nothing of it remains except entries in the worker logs. Use a client workflow only for clearly delimited tasks, for example to collect data and pass it on. Do not build long or complex processes in client workflows.

 

How it works

The Remote Worker never accepts incoming connections. It asks the Matrix42 server regularly for tasks, runs them and returns the results.

Every task has a target: a Worker Capability. A Remote Worker runs only the tasks whose capability it holds. Capabilities replace the former Data Gateway assignment. Some screens call the same object Data Provider Pool. You select the capability when you configure a data provider, a PowerShell script or the activity Run Client Workflow.

Prerequisites

  • A Matrix42 Enterprise tenant, version 26.1 or later. The PowerShell Execution Engine requires version 26.2 or later.
  • A user with permissions in the Administration application.
  • A computer in your network with access to the resources that the Remote Worker has to reach.
  • Network access from this computer to your tenant. See Functional Worker in Matrix42 ESM for the operating system, runtime and service account requirements.

Install and Connect the Remote Worker

Generate an API Token

In the Administration application, open Integration → Web Service Tokens and run the action Generate New Token. Details are described in Web Services tokens: Generate API Token.

The token is displayed only once, directly after it was generated. Copy it and store it securely. Starting with version 26.1, the action also returns an encrypted API token. Use the encrypted value as ApiToken in the worker configuration file.

 

Download and Install the Remote Worker

  1. Open Services & Processes → Workers and select Download Worker.
  2. Copy the package to the computer in your network and run the installation.
  3. Enter the URL of your tenant and the API token. The configuration file appsettings.json contains, among other settings, ServerBaseUrl, ApiToken and FriendlyName. All settings are described in Functional Worker in Matrix42 ESM.

Install only one Functional Worker on a computer. If several workers are installed on the same computer, keep one and uninstall the others.

 

Check the Connection

In Services & Processes → Workers, the Remote Worker appears in the list. Check that its status is Active and that Last Update changes regularly. The column Token expires shows when you have to renew the API token.

Create a Capability and Assign It to the Remote Worker

Create a Capability

  1. Open Services & Processes → Workers → Worker Capabilities and select Add Worker Capability.
  2. Enter a unique Name, for example CustomerNetwork, and a Description.
  3. Leave the check box Maintained automatically cleared. The system maintains automatically detected capabilities, such as Windows or Server, by itself.
  4. Select Save & Close.

Assign the Capability to the Remote Worker

  1. Open Services & Processes → Workers and open the Remote Worker in your network.
  2. In Assigned Capabilities, select the new capability.
  3. Select Save & Close.

The list Worker Capabilities now shows the Remote Worker in the column Workers.

Use the Remote Worker with Data Providers

Configure a Data Provider

Data providers, such as Active Directory, run on the Remote Worker that holds the capability selected in the provider configuration.

  1. Open Integration → Data Providers and open the provider.
  2. In Configurations, open the configuration.
  3. On the tab General, select your capability in Data Provider Pool. The grid shows the same value in the column Runs on.
  4. Save the configuration and set the schedule of the engine activation as usual.

The tab Workflows of a configuration shows only the run history of the provider workflows. The Remote Worker is selected only in Data Provider Pool.

 

The provider workflows read the Data Provider Pool of the configuration themselves. You do not have to change the workflows.

 

Create a Custom Data Provider for Other Sources

If no delivered data provider exists for your source, create a custom data provider. This is the generic data provider framework: it works for any data that you can map to Matrix42 objects. You build two workflows, and the framework runs them together:

  • The data collector workflow is a client workflow. It runs on the Remote Worker in your network, connects to the source, retrieves the data and saves it as a package. It collects and passes the data on, nothing else.
  • The import workflow runs in the cloud. It starts the data collector workflow with the activity Run Client Workflow, receives the data and runs an import definition that maps the data to Matrix42 objects.

To create the data provider:

  1. Create the data collector workflow in Workflow Studio from the template Connector Data Collector - WF Template. Use integration activities such as Get Ldap Entries, HTTP Send, SendAndReceiveReply, Execute SQL Query or Invoke PowerShell to request the data, and the Connector Package activities to save it. Add a value for your object type to the data definition Package Item Type.
  2. Create the import workflow from the template Connector Import - WF Template. In the activity Run Client Workflow (under Collect Data → Wait Client), select your data collector workflow as Workflow.
  3. Create an import definition in Integration → Import → Import Definitions and reference it in the import workflow with the activity Execute GDI Sequence.
  4. Open Integration → Data Providers and add a data provider. Under Implementation, select the import workflow.
  5. Add a configuration to the data provider. In Data Provider Pool, select the capability of your Remote Worker. Select Enable Import, save, select Enable and then Activate to run the import.
  6. Check the results on the tabs Last Result and Import Logs of the configuration.

The complete tutorial with an example (importing exchange rates) is described in Creating a New Data Provider.

Use Generic Inventory for Computer Inventory Data

For computer inventory data, the Generic Inventory extension provides a prepared server workflow, a data collector workflow template and a configuration. You only develop the data collector workflow that connects with your source.

  1. Install the Generic Inventory extension from the Extension Gallery. See Getting started with Generic Inventory.
  2. Create the data collector workflow from the provided template. See Introduction to creating a Generic Inventory data collector workflow.
  3. Create a data provider based on the extension and select your capability in Data Provider Pool. See Create custom data provider based on Generic Inventory extension.

For a complete example, see Sample data collector workflow for Generic Inventory extension.

Run PowerShell Scripts on the Remote Worker

Starting with version 26.2, the PowerShell Execution Engine runs PowerShell scripts on a Functional Worker. You define the script and its execution settings in a PowerShell Script Definition. In the field Capabilities, you select the capabilities that a worker has to provide. The script is dispatched only to a worker that provides all selected capabilities. With the capability of your Remote Worker, the script runs in your network. For details, see PowerShell Execution Engine.

Create the Script

  1. Open Services & Processes → Scripts and select Add PowerShell Script Definition.
  2. On the tab General, enter a unique Name and select the Purpose.
  3. In Capabilities, select the capability of your Remote Worker.
  4. If needed, select further options: Run Isolated for long-running or resource-intensive scripts, Require Data Layer only if the script uses Data Layer operations, and Long-Running. For long-running scripts, enter the Timeout (min). The default is 1 minute, the maximum is 120 minutes.
  5. On the tab Script, enter the script. Define input parameters with the PowerShell param() statement and output values with the [Output] attribute.
  6. Save the script. Then select Run Script in the toolbar of the script. The wizard Run Script has three steps: Script Parameters (enter a value for each input parameter), Script Execution Progress (terminal output of the run) and Result (the output parameters with their values).
  7. After the first run, the script detects its parameters. The sections Input Parameters (with Type and Required) and Output Parameters (with Type) of the script are filled. Before the first run, the page shows the note that you should run the script to validate execution and evaluate its output contract.

param([string]$Url)

# Example: call a web API of a system in your network
[Output]$StatusCode = (Invoke-WebRequest -Uri $Url -UseBasicParsing).StatusCode

The script runs with PowerShell 7 in a .NET process. In cloud container deployments, the default process is the Linux .NET Realtime Worker. If your script depends on Windows, select a capability that only a Windows worker provides, for example Windows, in addition to your own capability.

 

Run the Script from a Workflow

Add the activity Execute PowerShell to the workflow in Workflow Studio or Workflow Designer and select the script. Run the script once before, so that the system knows its parameters.

Property Description
Script Required. The PowerShell Script configuration item.
Parameters The input parameters of the script. They are filled automatically when you select the script.
Results The output parameters of the script. Assign them to workflow variables.
Completed Output. Shows whether the script completed successfully.
Errors Output. The errors of the script. Available only when Completed is false.
Ignore on Error Select this option if the workflow instance continues when the script fails.

Use Execute PowerShell for new workflows. The legacy activity Invoke PowerShell runs in the workflow process with PowerShell 2.0 and cannot be dispatched to another worker. Starting with version 27.1, the option Run on Server of Invoke PowerShell no longer runs the script in the Web Application process. The script runs on the Windows worker that runs the workflow.

 

In version 26.1, the PowerShell Execution Engine is not available. Run scripts in a client workflow instead. See Run Scripts in a Client Workflow (Before 26.2).

 

Run Client Workflows on the Remote Worker

Use a client workflow only when neither a data provider nor the PowerShell Execution Engine fits, and only for small, clearly delimited steps. A client workflow is not persistent: you do not see an instance of it in the system, and nothing remains after it has finished.

Principle

A normal workflow runs in the cloud. The part that needs access to your network runs in a client workflow on the Remote Worker. You start the client workflow from the normal workflow with the activity Run Client Workflow.

Workflow A (cloud)                      Client workflow (Remote Worker in your network)
  Get data                                 Get Single Record Data
  Run Client Workflow  ───────────────►    Collect data in your network
     Data Provider Pool = CustomerNetwork   Assign result to an Out argument
     Arguments: In / Out        ◄───────────
  Decision on the result
  Update data

Create the Client Workflow

  1. In Workflow Studio, create a workflow and set Integration Context to Client Custom Workflow in the workflow properties.
  2. Define the arguments of the workflow, as described in Pass Parameters Between the Workflows.
  3. Add the activities that run in your network.

A Remote Worker in your network has no direct SQL connection to the Matrix42 database. Read Matrix42 data with Get Single Record Data, not with Execute SQL.

 

The toolbox shows only the activities that can run in the workflow. In a client workflow, activities that run only on the server are hidden, for example Run Client Workflow, Get Package and Encrypt Data. A client workflow cannot start another client workflow.

 

Start the Client Workflow

In the workflow that runs in the cloud, add the activity Run Client Workflow from the category Integration. The activity is available only in workflows with a server-side Integration Context.

Property Description
Data Provider Pool The capability of the Remote Worker that runs the client workflow. At least one active Remote Worker has to hold it.
Workflow The client workflow that is started.
Arguments The values that are passed to the client workflow (In) and returned from it (Out).
Related Objects Objects that are referenced as related objects of the workflow instance. They appear on the page Affected Objects of the instance.
Do not wait Select this option if the calling workflow must not wait until the client workflow has finished.
Ignore Failure Select this option if the calling workflow continues when the client workflow fails.
Is Failed Output. Shows whether the client workflow has failed.
Error Message Output. The error message of the client workflow.

Select the capability for Data Provider Pool in one of two ways:

  • Static: Select the capability from the list. The list contains all capabilities of the system, including the automatic ones such as Windows or Server. Select your own capability.
  • Variable or Expression: Use a variable that contains the ID of the capability. The workflows of the data providers use this way: they read the Data Provider Pool of the provider configuration into a variable.

Run Scripts in a Client Workflow (Before 26.2)

In version 26.1, add the activity Invoke PowerShell to the client workflow. Make sure that the check box Run on Application Server is cleared. From version 26.2, use the PowerShell Execution Engine instead.

If Run on Application Server is selected, the script runs on the application server in the cloud and cannot reach your network.

 

Pass Parameters Between the Workflows

The workflows exchange values through arguments. The delivered Active Directory workflows Change Password \ Unlock Account (in the cloud) and Change Password \ Unlock Account on Agent (client workflow) show the complete pattern.

  1. Declare the arguments in the client workflow. Each argument has a name, a direction (In or Out) and a type.
  2. Map the arguments in the calling workflow. In the property Arguments of Run Client Workflow, add one entry for each argument. The key is the argument name of the client workflow. For an In argument, enter an expression or variable of the calling workflow. For an Out argument, enter the variable that receives the result.
  3. Work with the arguments in the client workflow. Read further data from the passed ID, run the local action and assign the result to an Out argument.
  4. Continue in the calling workflow. After the client workflow has finished, the Out variables are available, for example for a Decision.
Argument Direction Type Purpose
ObjectId In Guid ID of the account that is processed
UnlockRequested In Boolean Whether the account has to be unlocked
NewPassword In SecureData The new password
UnlockCompleted Out Boolean Whether the account was unlocked
ChangePasswordCompleted Out Boolean Whether the password was changed

Pass IDs and flags, not complete objects. The client workflow reads the data it needs from the ID.

 

Pass passwords and other secrets only as type SecureData, never as plain text.

 

Return results through Out arguments. Use Is Failed and Error Message to react to errors.

 

Migrate Workflows from On-Premises to the Cloud

When you move an on-premises installation to the cloud, the application server is no longer in your network. Workflow parts that access local resources have to move to the Remote Worker.

Find the Affected Workflows

Look for workflows with activities that access your network:

  • Invoke PowerShell with file paths, local programs, Active Directory commands or internal hosts.
  • Execute SQL on internal databases.
  • Activities for LDAP, files and packages on internal systems.
  • Custom activities that rely on files on the application server.

Decide What to Change

Finding Action
The workflow uses only Matrix42 data No change.
The workflow collects data from systems in your network Use a data provider: a delivered one, or a custom data provider with a data collector workflow. See Use the Remote Worker with Data Providers.
The workflow runs a PowerShell script against systems in your network Version 26.2 and later: Create a PowerShell Script with the capability of your Remote Worker and use Execute PowerShell. Version 26.1: Move the script into a client workflow.
The workflow needs another small step in your network Move the step into a client workflow and start it with Run Client Workflow.
The workflow needs a resource on the application server Redesign the workflow. The application server is in the cloud and does not reach your network.

Move a Workflow Part into a Client Workflow

  1. Create the client workflow and move the local activities into it.
  2. Turn the variables that the moved activities read into In arguments. Turn the values that later steps need into Out arguments.
  3. Replace the moved part in the original workflow with Run Client Workflow and map the arguments.
  4. Decide how to handle errors: use Is Failed, Ignore Failure and a TryCatch in the client workflow.
  5. Release both workflows and test them with a capability that only the Remote Worker in your network holds.

After the migration, the data provider configurations can still point to the former default pool, which is named after the old server. Select the capability of your Remote Worker in Data Provider Pool for each provider.

 

Troubleshooting

Question Where to look
Is the Remote Worker connected? Services & Processes → Workers: status and last update. Check also the expiry date of the token.
Does the Remote Worker hold the capability? Services & Processes → Workers → Worker Capabilities: the column Workers lists the workers.
Was the client workflow executed? Services & Processes → Workers → Worker Logs: a client workflow appears as a process of the type Data Gateway. The ErrorMessage shows errors. Client workflows are not persistent, so there is no workflow instance to open.
The Remote Worker does not start or reports authentication errors See the knowledge base article about workers that do not work with the error Authentication failed.

Related articles