Skip to main content

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, ...).

info

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

  1. Create an application directory
mkdir taskurai-workers
cd taskurai-workers
info

.NET 8.0 SDK is required for this example.

  1. Install Taskurai dotnet templates

To quickly create a Taskurai worker, first install the Taskurai dotnet templates:

dotnet new install Taskurai.Templates
  1. 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
  1. 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..."
note

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.

info

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:

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: