Now that you have connected your first node, it’s time to upload your first job. Jobs are compiled and packaged into NuGet packages to be uploaded to your organization.

Setup

Download the Runly Examples project. If you are using git, you can clone the repo:

git clone https://github.com/runlyio/core-dotnet.git
cd core-dotnet/examples/getting-started

Explore the Code

Take a minute to explore the code in the getting-started folder. You’ll notice that it is a plain console application that references the Runly nuget package.

Bootstrapping

The application is bootstrapped using a HostBuilder in Program.cs:

static async Task Main(string[] args)
{
	await JobHost.CreateDefaultBuilder(args)
		.Build()
		.RunJobAsync();
}

This allows you to encapsulate and configure the app’s resources such as:

Jobs

You can also take a look at the example job we will be using for the rest of this guide: the PlaceImporter. The PlaceImporter takes a few dependencies (including a fake database) and “imports” data from the US Census.

The lifecycle of the job goes something like this:

  1. Job is instatiated via the constructor
  2. InitializeAsync is called once before the job starts running
  3. GetItemsAsync is called once to get the list of items for processing
  4. For each item to be processed, ProcessAsync is called possibly in parallel depending on the job settings
  5. Once the job is finished, FinalizeAsync is called with the disposition of the job (success, failure, cancelled, etc)

Learn more about jobs.

Pack as Tool

In order for Runly to be able to run your job application, you will need to package the application as a dotnet tool. This means flipping the bit in the csproj file:

<PackAsTool>true</PackAsTool>

The Examples project already has this configured.

Run Locally

You can run & debug the job application locally without ever involving your Runly infrastructure. Learn more about running & debugging locally.

Package the Application

Run the following from the getting-started folder to package the application as a nupkg file:

dotnet pack -c Release

This will output a nupkg file in the bin/Release folder.

Upload the Package

Login to your Runly Dashboard and upload the generated nupkg file by adding a package in the package list.

upload package

Congratulations! Your first package is now uploaded and you can now queue jobs on your Runly infrastructure!

Continue to Step 3: Run a Runly job >>