Now that you’ve created the host application and the job, you can now run and debug your job locally.

Get a Config

To run a job locally during development or testing, you can run the app directly from the command line. To do this you first need a config file. Each job defines its config and default values. The Job CLI enables you to get a default config for the jobs in an app.

Use the get command to write the config for the HelloWorld job to the current working directory:

dotnet run -- get HelloWorld .

This will output a HelloWorld.json file to the current working directory with the contents:

{
  "names": [
    "Rick",
    "Morty"
  ],
  "job": "MyProject.HelloWorld"
}

Edit the Config

Once you have the config, open it in your favorite JSON or text editor and make any changes before you run the job:

{
  "names": [
    "Rick",
    "Morty",
    "Not Jerry"
  ],
  "job": "MyProject.HelloWorld"
}

Run the Job

With the changes to the config saved, we simply need to pass the config’s path to the job with the run command:

dotnet run -- run HelloWorld.json

When complete, you should see the following output to your console:

Running HelloWorld: 0 items of 3 processed
info: docs_example.HelloWorld[0]
      Hello, Rick
info: docs_example.HelloWorld[0]
      Hello, Morty
info: docs_example.HelloWorld[0]
      Hello, Not Jerry
                                                                                
============================================================
JOB SUCCESSFUL
============================================================

3 items of 3 processed

InitializeAsync     Successful          
GetItemsAsync       Successful          
GetEnumerator       Successful          
FinalizeAsync       Successful          

3 items             Successful          Successful          

============================================================
RESULTS
============================================================

------------------------------------------------------------
Successful
------------------------------------------------------------
Morty
Not Jerry
Rick

============================================================
OUTPUT
============================================================

-- No Output --

Notice the rich results we get back from the job. If there were failures processing any of our items or failures setting up the job, it would all be reported here.

Debug the Job

Since the application is just a plain console application, you can debug it in your IDE just like you are used to. Simply set the CLI arguments for the debugger to run HelloWorld.json and then step through your job.

If you don’t have your IDE open and still would like to debug, you can also make use of the launchDebugger flag. Edit your HelloWorld.json:

{
  "names": [
    "Rick",
    "Morty"
  ],
  "job": "MyProject.HelloWorld",
  "execution": {
    "launchDebugger": true
  }
}

Now, run the app from the command line:

dotnet run -- run HelloWorld.json

If you have Visual Studio installed, it will prompt you to open your project in Visual Studio and start the debugger.

Congratulations! You now have created a job and learned how to run it locally. If you’d like to go more in depth, we recommend: