{"id":25190168,"url":"https://github.com/keyfactor/keyfactor-sample-jobcompletionhandler","last_synced_at":"2025-07-06T17:07:38.580Z","repository":{"id":160464374,"uuid":"579168050","full_name":"Keyfactor/keyfactor-sample-jobcompletionhandler","owner":"Keyfactor","description":"The Keyfactor Command platform has an extension point that allows custom code to be executed after the completion of orchestrator jobs. This is a sample implementation of a job completion handler.","archived":false,"fork":false,"pushed_at":"2025-04-23T18:55:43.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-05-25T12:02:26.639Z","etag":null,"topics":["keyfactor-completionhandler"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Keyfactor.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-16T20:49:06.000Z","updated_at":"2025-04-23T18:54:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"800881ec-c667-479e-b769-e07f5e98812f","html_url":"https://github.com/Keyfactor/keyfactor-sample-jobcompletionhandler","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Keyfactor/keyfactor-sample-jobcompletionhandler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Keyfactor%2Fkeyfactor-sample-jobcompletionhandler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Keyfactor%2Fkeyfactor-sample-jobcompletionhandler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Keyfactor%2Fkeyfactor-sample-jobcompletionhandler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Keyfactor%2Fkeyfactor-sample-jobcompletionhandler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Keyfactor","download_url":"https://codeload.github.com/Keyfactor/keyfactor-sample-jobcompletionhandler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Keyfactor%2Fkeyfactor-sample-jobcompletionhandler/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263940313,"owners_count":23533012,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["keyfactor-completionhandler"],"created_at":"2025-02-09T21:19:06.065Z","updated_at":"2025-07-06T17:07:38.570Z","avatar_url":"https://github.com/Keyfactor.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Keyfactor Command Sample Job Completion Handler\n\n## Overview\n\nThe Keyfactor Command platform has an extension point that allows custom code to be executed after the completion\nof orchestrator jobs.\nThis code is in the form of a .NET assembly that is installed on the Command server. \nThe extension receives basic information about the job (orchestrator that executed the job, job type, job identification,\nsuccess or failure, etc.) and can perform whatever server-side job post-processing is desired.\n\nTypical use cases would be triggering external business workflow systems on success or failure of orchestrator jobs.\n\nThis repository contains a sample job completion handler that traces out the job context information provided and\ndemonstrates making an API call back into the Command platform.\n\nJob Completion Handlers were introduced in Command version 9.0. This sample has been tested with Command Version 11.2.\nThe way Completion Handlers and other extensions are loaded in Command changed in version 11.\nPlease review the comments and examples in this repository in order to configure and load the Completion Handler correctly.\n\n\n## Getting Started\n\nTo use this sample you will need:\n- An understanding of the Keyfactor Command platform, orchestrators, orchestrator extensions, certificate stores, and certificate store related jobs\n- An understanding of C# and .NET development\n- A working Keyfactor Command instance and administrative access to the server it is running on\n- An installed, configured, and approved Universal Orchestrator Framework instance\n- The \"Windows Certificate\" Universal Orchestrator Extension, installed into the Orchestrator Framework\n- The corresponding \"WinCert\" certificate store type configured on the Command instance\n- An instance of a \"WinCert\" certificate store with a scheduled inventory job\n- Visual Studio (or other development environment that can build a .NET C# assembly)\n\n#### 1 - Get a Command environment up and running with an inventory job running on a certificate store\n\nJob completion handlers execute after an orchestrator job completes, so to play with completion handlers, you will need a\njob running on some orchestrator. Completion handlers are typically written to be specific to a job type and in the case\nof certificate store jobs, also specific to a certificate store type.\nThis sample is specific to the \"WinCert\" certificate store type, which is used to manage certificates found in Local\nMachine certificate stores on Windows Servers. If you don't already have the WinCert extension installed in your orchestrator, it\ncan be found at https://github.com/Keyfactor/iis-orchestrator. Any certificate store type may be used, but adjustments\nto the sample will be necessary if it isn't \"WinCert\"\n\nThe details of getting your Command environment with a certificate store set up are beyond the scope of this documentation. \n\n#### 2 - Determine the Certificate Store Type Job IDs in your Command environment\n\nEvery job that can be sent to an Orchestrator has a \"Job Type\" that is identified by a GUID.\nWhen a certificate store type is configured in Command, the corresponding job types related to that certificate store type\nare dynamically created.\nThese job type GUIDs are unique to each Command instance.\n\nWhen a completion handler is registered in the Command system, the registration includes a list of the job type GUIDs \nthat the handler will handle.\nWhenever a job completes, the Command platform checks to see if there are any job completion handlers registered to handle\nthat job type, and if so the handler is called.\n\nSince this sample is specific to the WinCert store type, the specific WinCert related job GUIDs must be determined for \nyour environment.\n\nTo retrieve the GUIDs, the `GET /CertificateStoreTypes/Name/` API endpoint may be used.\n\nUsing the Keyfactor API Reference and Utility, scroll down to the *CertificateStoreType* API, and select the\nGET /CertificateStoreTypes/Name/{name} end point.\nEnter \"WinCert\" the name parameter and click the `Try it out!` button to execute the API.\n\nAlternatively, you could use a curl command similar to the following (after substituting your credentials and specifying \nthe proper URL for your Command Server API endpoint:\n\n`curl -u {domain}\\\\{account}:{password}  'https://{commandserver}/KeyfactorAPI/CertificateStoreTypes/Name/WinCert'`\n\nOnce the response is returned, scroll down to the end of the JSON result.\nYou will see a list of Job Types and their associated GUIDs which will look something like:\n\n```\n    \"InventoryJobType\": \"49b3a17d-cada-4ec8-84c6-7719bf5beef3\",\n    \"ManagementJobType\": \"4be14534-55b0-4cd7-9871-536b55b5e973\",\n    \"EnrollmentJobType\": \"e868b3f8-9b6a-48b1-91c8-683d71d94f61\"\n```\n\nNote that if you pick a different cert store type, you may see different job types as not all cert store types implement \nall of the possible job types. The WinCert store implements the above three job types. Your GUIDs will be different.\n\n#### 3 - Build the sample extension\n\nAdd Keyfactor's GitHub NuGet package repository to your list of Visual Studio NuGet package sources.\nThe URL for the package source is `https://nuget.pkg.github.com/Keyfactor/index.json`.\nYou will need to create a GitHub personal access token and use it to authenticate to the GitHub package source.\nThe package repository is public read but does require a GitHub login. \n\nUse Visual Studio to build the solution file in this repository.\n\nNote that this extension will need to be compiled with the same version of the .NET Framework as is the Command \ninstance it will be plugged into. This project targets both .NET 6.0 and .NET 8.0. The appropriate output can be selected for the Command version in use.\nFuture versions of Command are planed to be targeted for current versions of .NET. \nIf this sample or production Completion Handlers are built against future versions, the target framework may need to be updated.\n\n#### 4 - Copy the assembly to the Command Server\n\nCopy the compiled assembly (`SampleJobCompletionHandler.dll`), `manifest.json` and required dependencies to the correct location\nfor Extensions for the Orchestrator API endpoint on the Command Server. You may organize these under a single sub-directory.\nThis is typically `C:\\Program Files\\Keyfactor\\Keyfactor Platform\\WebAgentServices\\Extensions\\JobCompleteHandlers`\n\nIn cases where your custom code may need additional dependent assemblies, make sure to only copy assemblies that are specific to your handler. \nAs long as Extensions are copied into an isolated folder, there is no concern of overwriting libraries. Different versions of a library can be \nused as long as they are included correctly in the Extensions folder in use.\n\n#### 5 - Register the handler on the Command Server\n\nJob completion handlers are loaded by the extension loader system using the `manifest.json` file.\n\nA sample `manifest.json` file for this extension is included in this repository. It should be edited with the correct Options values.\nThe correct job type GUIDs retrieved above should be entered in a comma-seperated list in the JobTypes property.\n\nMultiple completion handlers may be registered. If they are located in the same sub-directory for Extension loading,\nthe `manifest.json` file needs to specify __all__ extensions in a directory to load. If you do not wish to merge `manifest.json`\nfiles, organize extensions into seperate sub-directories entirely.\n\nNote that an incorrect `manifest.json` file or a `manifest.json` that points to an assembly that cannot be loaded can prevent\nthe Orchestrator API from operating and prevent all Orchestrators from contacting the platform. Be sure the check the\nlogs (see below) for proper operation any time the `manifest.json` or the corresponding Assemblies are changed.\n\n#### 6 - Enable trace logging for the handler\n\nTo be able to see the trace log messages in the sample without having to enable trace level logging for the whole \nOrchestrator API endpoint, find the NLog configuration file for the Orchestrator API endpoint, usually located at:\n\n`C:\\Program Files\\Keyfactor\\Keyfactor Platform\\WebAgentServices\\NLog_Orchestrators.config`\n\nand add the following rule inside the `\u003cRules\u003e` section:\n\n`\u003clogger name=\"*.SampleJobCompletionHandler\" minlevel=\"Trace\" writeTo=\"logfile\" final=\"true\"/\u003e`\n\njust before the default logging rule:\n\n `\u003clogger name=\"*\" minlevel=\"Info\" writeTo=\"logfile\" /\u003e`\n\n#### 7 - Restart IIS\n\nChanges to extensions and a `manifest.json` will require that the web server is restarted, which can be done by running the iisreset command.\n\nAt this point trace messages should appear in the Orchestrator API endpoint logs whenever a WinCert store type job\nis completed by an orchestrator. By default the logs will be at `C:\\Keyfactor\\logs\\Command_OrchestratorsAPI_Log.txt`\n\n# Understanding the Sample\n\nExamine the sample code for a detailed understanding of how the handler works, but a higher level overview is described here.\n\n#### Orchestrator Job Flow\n\nFor background information, orchestrator jobs are processed by Command as follows:\n\n- A job is scheduled on the Command platform (and targeted at a specific Orchestrator).\n- Orchestrators periodically check in with the Command platform to see if there is any work requested. When they check in they receive a list of jobs and requested times to run those jobs.\n- When the orchestrator thinks it's time to do a job that it was asked to do, it asks the Command platform for the job details.\n- The Command platform provides the job details and the Orchestrator executes the job.\n- The Orchestrator returns the results of the job and the completion status to the Command platform.\n- The Command platform stores any job related data (such as inventory results) and then records the completion status of the job.\n- The Command platform looks for any registered job completion handlers that match the job type and executes them.\n- (We are here)\n\nWhile this sample discusses jobs that are related to certificate store management, there are other kinds of jobs that\nship with the platform and it is possible to create custom jobs. The same job flow works for all job types,\nincluding the completion handler step.\n\n#### RunHandler method\n\nThe Completion Handler is a .NET class that implements the `IOrchestratorJobCompleteHandler` interface.\nThe interface contains a single method with a signature of `bool RunHandler(OrchestratorJobCompleteHandlerContext context)`.\nThe handler's responsibility is to look at the context object (see below),\ndo whatever processing is necessary, and return a true or false success status.\nSince a single completion handler will typically manage multiple job types, the RunHandler method will usually have some\nsort of dispatch logic to figure out what kind of job has completed and call the appropriate logic for the job.\n\nLooking at the sample code, you will see an implementation of the RunHandler method, which relays control to an async\nversion of the method, which in turn determines the job type and calls a job specific method.\n\nThe method that handles inventory jobs demonstrates using data from the context object to make an API call back to the \nCommand platform to retrieve more information about the inventory job (in this case the history of previous job runs).\nSince the API call is an asynchronous call, the code shows how to transition from the synchronous RunHander interface.\n\nThe method that handles management jobs demonstrates having a different code path based on the various operation types\ncan occur with management jobs.\n\nFinally, the method that handles reenrollment jobs doesn't have any logic but shows handling the third kind of job that\nis possible with the WinCert store type.\n\nAll of the methods trace out control of flow and it should be clear as to where you could put your own logic.\nSee below for sample trace output.\n\nThe interface assemblies needed by the code are shipped with the Command platform and for developers are made publicly \navailable as NuGet packages on GitHub's package server (in the Keyfactor Organization). The sample uses the following\nKeyfactor specific packages: \n- `Keyfactor.Logging`\n- `Keyfactor.Orchestrators.Common`\n- `Keyfactor.Platform.IOrchestratorJobCompleteHandler`\n\n#### Context Object\n\nWhen the completion handler is executed, it is passed a context object that contains information about the job that just completed.\nDepending on the job type, various fields in the context object may or may not be present. The sample code traces out the\ncontents of the context object.\n\n\u003cdetails\u003e\u003csummary\u003eSample Inventory Context\u003c/summary\u003e\n\n```\n[\nAgentId : fa406103-d84a-43ea-8bfd-99bc1f064281,\nUsername : KFTRAIN\\SVC_Orchestrator,\nClientMachine : orchestrator.kftrain.lab,\nJobResult : Success,\nJobId : 0b4b411a-4b26-4492-a575-a10adb43a08a,\nJobType : WinCertInventory,\nJobTypeId : 49b3a17d-cada-4ec8-84c6-7719bf5beef3,\nOperationType : Unknown,\nCertificateId : null,\nRequestTimestamp : 5/3/2023 11:18:48 PM,\nCurrentRetryCount : 0,\nClient : https://command.kftrain.lab/KeyfactorAPI/\n]\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eSample Management Context\u003c/summary\u003e\n\n```\n[\nAgentId : fa406103-d84a-43ea-8bfd-99bc1f064281,\nUsername : KFTRAIN\\SVC_Orchestrator,\nClientMachine : orchestrator.kftrain.lab,\nJobResult : Success,\nJobId : 426ec1ab-9f02-4011-8df9-72c4a603ca90,\nJobType : WinCertManagement,\nJobTypeId : 4be14534-55b0-4cd7-9871-536b55b5e973,\nOperationType : Add,\nCertificateId : 14,\nRequestTimestamp : 5/6/2023 12:29:32 AM,\nCurrentRetryCount : 0,\nClient : https://command.kftrain.lab/KeyfactorAPI/\n]\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eSample ReEnrollment Context\u003c/summary\u003e\n\n```\n[\nAgentId : fa406103-d84a-43ea-8bfd-99bc1f064281,\nUsername : KFTRAIN\\SVC_Orchestrator,\nClientMachine : orchestrator.kftrain.lab,\nJobResult : Success,\nJobId : 32354394-955e-4142-a968-479daa294128,\nJobType : WinCertReenrollment,\nJobTypeId : e868b3f8-9b6a-48b1-91c8-683d71d94f61,\nOperationType : Unknown,\nCertificateId : 15,\nRequestTimestamp : 5/6/2023 12:32:46 AM,\nCurrentRetryCount : 0,\nClient : https://command.kftrain.lab/KeyfactorAPI/\n]\n```\n\u003c/details\u003e\n\nThe context fields provided are:\n\n| Field | Description |\n|-------|-------------|\n|AgentId | The GUID that identifies the Orchestrator that ran the job.|\n|Username | The account that the Orchestrator used to authorize itself to the Command platform. Displayed as \"Identity\" on the Orchestrator management screen|\n|ClientMachine | The name of the Orchestrator. This is typically a fully qualified domain name, but can be any string that the Orchestrator declared when it registered with the Command Platform|\n|JobResult | Result reported by Orchestrator. (Success, Warning, Failure, Unknown) |\n|JobId | These will be fixed for reoccurring jobs, such as inventory, and change for one time jobs |\n|JobType | String based Job type |\n|JobTypeId | GUID for job type. These will be unique per Command instance. These are the values that were configured in the JobTypes Options |\n|OperationType | Some job types have multiple operations. While inventory jobs report \"Unknown\", management jobs can report \"Add\" and \"Remove\" |\n|CertificateID | The internal Command Id for the certificate related to the job. Useful for knowing which certificate was added, remove, or enrolled |\n|RequestTimestamp | When the job was originally scheduled |\n|CurrentRetryCount | Failed jobs are automatically retried (rescheduled) by the Command platform. This will be zero on the first execution of the job and increment for each retry. |\n|Client | The context contains an initialized HTTPClient which is appropriate for making calls to the Command API|\n\n#### Sample Trace Outputs\n\n\n\u003cdetails\u003e\u003csummary\u003eSample Inventory Handler Trace\u003c/summary\u003e\n\n```\n2023-05-05 17:30:00.3527 E014A91C-90BA-46C8-B185-9F9290993C69 KFSample.SampleJobCompletionHandler [Trace] - This handler's favorite animal is: Tiger\n2023-05-05 17:30:00.3527 E014A91C-90BA-46C8-B185-9F9290993C69 KFSample.SampleJobCompletionHandler [Trace] - The context passed is: \n[\nAgentId : fa406103-d84a-43ea-8bfd-99bc1f064281,\nUsername : KFTRAIN\\SVC_Orchestrator,\nClientMachine : orchestrator.kftrain.lab,\nJobResult : Success,\nJobId : 0b4b411a-4b26-4492-a575-a10adb43a08a,\nJobType : WinCertInventory,\nJobTypeId : 49b3a17d-cada-4ec8-84c6-7719bf5beef3,\nOperationType : Unknown,\nCertificateId : null,\nRequestTimestamp : 5/3/2023 11:18:48 PM,\nCurrentRetryCount : 0,\nClient : https://command.kftrain.lab/KeyfactorAPI/\n]\n2023-05-05 17:30:00.3527 E014A91C-90BA-46C8-B185-9F9290993C69 KFSample.SampleJobCompletionHandler [Trace] - Dispatching job completion handler for an Inventory job 0b4b411a-4b26-4492-a575-a10adb43a08a\n2023-05-05 17:30:00.3527 E014A91C-90BA-46C8-B185-9F9290993C69 KFSample.SampleJobCompletionHandler [Trace] - Executing the Inventory handler\n2023-05-05 17:30:00.3527 E014A91C-90BA-46C8-B185-9F9290993C69 KFSample.SampleJobCompletionHandler [Trace] - Custom logic for Inventory completion handler here\n2023-05-05 17:30:00.3527 E014A91C-90BA-46C8-B185-9F9290993C69 KFSample.SampleJobCompletionHandler [Trace] - Querying Command API with: OrchestratorJobs/JobHistory?pq.queryString=JobID%20-eq%20%220b4b411a-4b26-4492-a575-a10adb43a08a%22\n2023-05-05 17:30:00.3683 E014A91C-90BA-46C8-B185-9F9290993C69 KFSample.SampleJobCompletionHandler [Trace] - Results of JobHistory API: [{\"JobHistoryId\":2168,\"AgentMachine\":\"orchestrator.kftrain.lab\",\"JobId\":\"0b4b411a-4b26-4492-a575-a10adb43a08a\",\"Schedule\":{\"Interval\":{\"Minutes\":1}},\"JobType\":\"WinCertInventory\",\"OperationStart\":\"2023-05-06T00:27:00\",\"OperationEnd\":\"2023-05-06T00:27:00\",\"Message\":\"\",\"Result\":\"Success\",\"Status\":\"Completed\",\"StorePath\":\"My\",\"ClientMachine\":\"iistarget.kftrain.lab\"},{\"JobHistoryId\":2169,\"AgentMachine\":\"orchestrator.kftrain.lab\",\"JobId\":\"0b4b411a-4b26-4492-a575-a10adb43a08a\",\"Schedule\":{\"Interval\":{\"Minutes\":1}},\"JobType\":\"WinCertInventory\",\"OperationStart\":\"2023-05-06T00:28:00\",\"OperationEnd\":\"2023-05-06T00:28:00\",\"Message\":\"\",\"Result\":\"Success\",\"Status\":\"Completed\",\"StorePath\":\"My\",\"ClientMachine\":\"iistarget.kftrain.lab\"},{\"JobHistoryId\":2170,\"AgentMachine\":\"orchestrator.kftrain.lab\",\"JobId\":\"0b4b411a-4b26-4492-a575-a10adb43a08a\",\"Schedule\":{\"Interval\":{\"Minutes\":1}},\"JobType\":\"WinCertInventory\",\"OperationStart\":\"2023-05-06T00:29:00\",\"OperationEnd\":\"2023-05-06T00:29:00\",\"Message\":\"\",\"Result\":\"Success\",\"Status\":\"Completed\",\"StorePath\":\"My\",\"ClientMachine\":\"iistarget.kftrain.lab\"},{\"JobHistoryId\":2171,\"AgentMachine\":\"orchestrator.kftrain.lab\",\"JobId\":\"0b4b411a-4b26-4492-a575-a10adb43a08a\",\"Schedule\":{\"Interval\":{\"Minutes\":1}},\"JobType\":\"WinCertInventory\",\"OperationStart\":\"2023-05-06T00:30:00\",\"OperationEnd\":null,\"Message\":\"\",\"Result\":\"Unknown\",\"Status\":\"InProcess\",\"StorePath\":\"My\",\"ClientMachine\":\"iistarget.kftrain.lab\"}]\n2023-05-05 17:30:00.3844 E014A91C-90BA-46C8-B185-9F9290993C69 KFSample.SampleJobCompletionHandler [Trace] - Exiting Job Completion Handler for orchestrator [fa406103-d84a-43ea-8bfd-99bc1f064281/orchestrator.kftrain.lab] and JobType 'WinCertInventory' with status: True\n\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eSample Management Handler Trace\u003c/summary\u003e\n\n```\n2023-05-05 17:30:30.0244 F1CF5BD5-3148-47B5-A24D-5A81F21C86CA KFSample.SampleJobCompletionHandler [Trace] - Entering Job Completion Handler for orchestrator [fa406103-d84a-43ea-8bfd-99bc1f064281/orchestrator.kftrain.lab] and JobType 'WinCertManagement'\n2023-05-05 17:30:30.0244 F1CF5BD5-3148-47B5-A24D-5A81F21C86CA KFSample.SampleJobCompletionHandler [Trace] - This handler's favorite animal is: Tiger\n2023-05-05 17:30:30.0244 F1CF5BD5-3148-47B5-A24D-5A81F21C86CA KFSample.SampleJobCompletionHandler [Trace] - The context passed is: \n[\nAgentId : fa406103-d84a-43ea-8bfd-99bc1f064281,\nUsername : KFTRAIN\\SVC_Orchestrator,\nClientMachine : orchestrator.kftrain.lab,\nJobResult : Success,\nJobId : 426ec1ab-9f02-4011-8df9-72c4a603ca90,\nJobType : WinCertManagement,\nJobTypeId : 4be14534-55b0-4cd7-9871-536b55b5e973,\nOperationType : Add,\nCertificateId : 14,\nRequestTimestamp : 5/6/2023 12:29:32 AM,\nCurrentRetryCount : 0,\nClient : https://command.kftrain.lab/KeyfactorAPI/\n]\n2023-05-05 17:30:30.0244 F1CF5BD5-3148-47B5-A24D-5A81F21C86CA KFSample.SampleJobCompletionHandler [Trace] - Dispatching job completion handler for a Management job 426ec1ab-9f02-4011-8df9-72c4a603ca90\n2023-05-05 17:30:30.0244 F1CF5BD5-3148-47B5-A24D-5A81F21C86CA KFSample.SampleJobCompletionHandler [Trace] - Executing the Management handler\n2023-05-05 17:30:30.0244 F1CF5BD5-3148-47B5-A24D-5A81F21C86CA KFSample.SampleJobCompletionHandler [Trace] - Custom logic for Inventory completion handler here\n2023-05-05 17:30:30.0244 F1CF5BD5-3148-47B5-A24D-5A81F21C86CA KFSample.SampleJobCompletionHandler [Trace] - Management job process for an Add operation\n2023-05-05 17:30:30.0244 F1CF5BD5-3148-47B5-A24D-5A81F21C86CA KFSample.SampleJobCompletionHandler [Trace] - Exiting Job Completion Handler for orchestrator [fa406103-d84a-43ea-8bfd-99bc1f064281/orchestrator.kftrain.lab] and JobType 'WinCertManagement' with status: True\n\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eSample ReEnrollment Handler Trace\u003c/summary\u003e\n\n```\n2023-05-05 17:33:31.7903 F81ECB91-496C-4C66-8B66-C2BA4C6CE9F5 KFSample.SampleJobCompletionHandler [Trace] - Entering Job Completion Handler for orchestrator [fa406103-d84a-43ea-8bfd-99bc1f064281/orchestrator.kftrain.lab] and JobType 'WinCertReenrollment'\n2023-05-05 17:33:31.7903 F81ECB91-496C-4C66-8B66-C2BA4C6CE9F5 KFSample.SampleJobCompletionHandler [Trace] - This handler's favorite animal is: Tiger\n2023-05-05 17:33:31.7903 F81ECB91-496C-4C66-8B66-C2BA4C6CE9F5 KFSample.SampleJobCompletionHandler [Trace] - The context passed is: \n[\nAgentId : fa406103-d84a-43ea-8bfd-99bc1f064281,\nUsername : KFTRAIN\\SVC_Orchestrator,\nClientMachine : orchestrator.kftrain.lab,\nJobResult : Success,\nJobId : 32354394-955e-4142-a968-479daa294128,\nJobType : WinCertReenrollment,\nJobTypeId : e868b3f8-9b6a-48b1-91c8-683d71d94f61,\nOperationType : Unknown,\nCertificateId : 15,\nRequestTimestamp : 5/6/2023 12:32:46 AM,\nCurrentRetryCount : 0,\nClient : https://command.kftrain.lab/KeyfactorAPI/\n]\n2023-05-05 17:33:31.7903 F81ECB91-496C-4C66-8B66-C2BA4C6CE9F5 KFSample.SampleJobCompletionHandler [Trace] - Dispatching job completion handler for the re-enrollment job 32354394-955e-4142-a968-479daa294128\n2023-05-05 17:33:31.7903 F81ECB91-496C-4C66-8B66-C2BA4C6CE9F5 KFSample.SampleJobCompletionHandler [Trace] - Executing the Reenrollment handler\n2023-05-05 17:33:31.7903 F81ECB91-496C-4C66-8B66-C2BA4C6CE9F5 KFSample.SampleJobCompletionHandler [Trace] - Custom logic for Reenrollment completion handler here\n2023-05-05 17:33:31.7903 F81ECB91-496C-4C66-8B66-C2BA4C6CE9F5 KFSample.SampleJobCompletionHandler [Trace] - Exiting Job Completion Handler for orchestrator [fa406103-d84a-43ea-8bfd-99bc1f064281/orchestrator.kftrain.lab] and JobType 'WinCertReenrollment' with status: True\n\n```\n\u003c/details\u003e\n\n# Summary\nThis document has provided an example Job Completion Handler for a specific job type and can be extended to handle other job types.\nInformation was provided for using the Keyfactor APIs to find the correct GUIDs to process specific job types.\nThe sample also provides examples for handling Inventory, Management and Reenrollment jobs, along with how to access the context properties and a working HTTP Client.\nOnce the handler has been developed, instructions were provided describing how to load the handler with a `manifest.json` file so Keyfactor Command can call the appropriate handler.\nFor additional information, please refer to the comments in the example source code.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeyfactor%2Fkeyfactor-sample-jobcompletionhandler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeyfactor%2Fkeyfactor-sample-jobcompletionhandler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeyfactor%2Fkeyfactor-sample-jobcompletionhandler/lists"}