Worker setup
A worker is a microservice that can contain one or more commands. Commands are triggered by tasks.
Command names (case insensitive) should be unique in your Taskurai setup.
Workers are pushed as containers to a container registry of choice (Azure Container Registry, Docker Hub, ...).
Please note that some container registry offerings (see Docker Hub) have rate limits in place.
This is not recommended for Taskurai production environments. Consider paid subscriptions or use an Azure Container Registry.
Create a worker application
- Create an application directory
- macOS
- Windows
- Linux
mkdir taskurai-workers
cd taskurai-workers
md taskurai-workers
cd taskurai-workers
mkdir taskurai-workers
cd taskurai-workers
- C#
.NET 8.0 SDK is required for this example.
- Install Taskurai dotnet templates
To quickly create a Taskurai worker, first install the Taskurai dotnet templates:
dotnet new install Taskurai.Templates
- Create a new Taskurai worker project
The following options are required:
- --name: Name of the project
- --workerName: Name of the worker (only 1-20 alphanumeric characters and hyphens are allowed.)
dotnet new taskuraiworker --name TestWorker --workerName TestWorker
- Go to the newly created project directory:
cd TestWorker
Add the personal access token as a user secret:
dotnet user-secrets init
dotnet user-secrets set "Taskurai:Pat" "e8gFaA8ZaetAHiS257opAr..."
Access tokens used in local workers should at least have the following access permissions:
Data/Buildby.Taskurai/tasks/*Data/Buildby.Taskurai/steps/*Data/Buildby.Taskurai/state/*
When using global locks, the following scopes are required:
Data/Buildby.Taskurai/locks/*
When using sensitive data or secrets in tasks and the worker is required to read the information, add the following scope:
Data/Buildby.Taskurai/sensitive/read
When global secrets are referenced in the task arguments and the worker must have permission to read the secrets, add the following scope:
Data/Buildby.Taskurai/secrets/read
A less granular permission like Data/Buildby.Taskurai/* may also be used.
Adding a personal access token (PAT) is only required during development.
Important: The same isolation key must be used by both:
- the application creating tasks
- the local worker
This is required to enable isolation mode.
A PAT includes a default isolation key. You can either:
- Use the same PAT in both the worker and the task-creating application, or
- Override the isolation key by configuring the same unique GUID in both applications:
- via the
Taskurai:IsolationKeyapplication setting, or - via TaskuraiClientOptions
- via the
Once the worker is deployed to Taskurai, the PAT is no longer required.
Next steps
Before a local worker can be started for the first time, it must be deployed to Taskurai.
Once the worker is registered in Taskurai for the first time, the local worker can be started and tested locally without having to redeploy.
Learn more: