Building Temporal applications with the .NET SDK

Temporal workflows in C# only stay reliable if the workflow code follows deterministic rules, the workers run where your operations team can manage them, and the change process catches problems before deployment. This page covers how to plan and build that work inside your existing .NET estate.

On this page

How the Temporal .NET SDK fits C# workflows into your services

A .NET team builds a Temporal application by writing the business process as a workflow in C#, with each external call (a payment, an email, a database write) written as an activity. The SDK gives you the workflow and activity types, a client that starts and signals workflows and queries their state, and a worker that polls a task queue and runs the code. Your application code stays in ordinary C# classes and methods, while Temporal records each step so a workflow can resume after a crash, a deploy or a long wait without you writing that recovery logic yourself. The SDK does not store anything on its own. Every workflow history is kept by a Temporal Service, which is either a server you run in your infrastructure or Temporal Cloud, and the decision between those two is an operations and compliance decision that the SDK itself does not make.

Temporal is worth considering when a process spans several services or days, needs retries with state carried across them, or must wait for a human approval or an external event. Ordinary background jobs, such as a queued message consumer or a scheduled task in a hosted service, work well for single, short, idempotent operations. They become hard to reason about when a failed step must be retried with its context intact, when a process waits for hours, or when you need to know exactly which step a customer's order reached. Before committing, list the processes you would move and mark which of them have those properties. Confirm with your platform team whether the processes can tolerate running on a service you operate, since that choice drives most of the rest of the design.

Which worker hosting option fits each .NET team

This table compares the three ways to host Temporal workers and clients in .NET: inside an ASP.NET Core service, as a separate worker process or container, and as a client-only API layer. Read each row against your team's deployment model and who will be paged when a worker stops polling. The main takeaway is that hosting choice sets ownership and scaling boundaries more than it changes workflow code.

Hosting optionBest suited toOperational ownership, deployment and scalingWhat to confirm in the .NET SDK documentation
Hosted service inside an ASP.NET Core appTeams with one service that owns both the HTTP API and the workflows it needs, and a small number of task queuesThe web team owns worker health, shutdown and rollout. Scaling the API also scales workers, so a web traffic spike can add polling load you did not plan for.How the worker is registered as a hosted service, how graceful shutdown drains in-flight tasks, and how dependency injection scopes apply to activities
Separate worker process or containerTeams that want workers scaled on queue backlog, with different release cadence from the web app or different resource needsA platform or service team owns a second deployable. Rollouts can be staged per task queue, but each extra image adds build, monitoring and secret-handling work.Container host requirements, how the worker connects to the Temporal Service endpoint and TLS settings, and documented guidance on running multiple workers per queue
Client-only API layer that starts workflowsTeams whose web or API tier should submit and query workflows while a different group runs the workersThe API team owns request handling and client connection settings. Workflow execution depends on workers owned elsewhere, so ownership boundaries must be written down.Client connection and namespace configuration, how workflow IDs and start options are set, and how queries and signals are sent without a local worker
Workers that share a process with other background jobsSmall teams with existing background job infrastructure they want to keep in one deployableMixed workloads share CPU and memory limits. Long-running CPU work in one job can slow workflow task processing, which makes capacity harder to predict.Worker concurrency settings, how thread pools interact with activity execution, and any documented limits on activity types per worker
Deciding who is paged for worker outagesOrganizations with a clear on-call model for either application teams or a platform groupWhichever option you choose, the on-call owner needs alerts on worker polling and task failures. Splitting roles across teams requires shared runbooks.Which SDK metrics exist for worker health and polling, and how to export them to your monitoring stack

How the .NET client, workers and Temporal Service connect

The flow starts in your application or API, which uses a Temporal client to start a workflow. The Temporal Service records each event in workflow history and places tasks on a task queue. .NET workers in your network poll those queues, run workflow and activity code, and call your databases and external systems. Check where the trust boundary sits: the Temporal Service should run on hosts not reachable from the public internet, and any Temporal Cloud connection crosses your network edge, so confirm how it is secured before you go live.

Client, worker and Temporal Service flow with trust boundaries marked.

Which C# patterns break workflow determinism

Temporal rebuilds workflow state by replaying recorded event history against your workflow code, so every run must make the same decisions in the same order. The patterns below are the ones .NET teams most often write into workflow methods without noticing. Each has a documented alternative, and the exact API names should be confirmed against the .NET SDK's current determinism guidance before code is written.

Reading wall-clock time

Calling DateTime.UtcNow or DateTimeOffset.Now inside a workflow returns a different value on replay than it did on the original run. A branch such as "expire after one hour" can then take another path and throw a non-determinism error. Use the SDK's workflow clock for the current time, and use durable timers for delays. Check every workflow class for DateTime and Stopwatch calls before review.

Generating random values and identifiers

Guid.NewGuid(), Random and RandomNumberGenerator produce new output each time the workflow code runs, so a replayed run gets different identifiers than the recorded one. Any value that drives a branch or gets stored in state changes the path. Generate identifiers in the client before starting the workflow and pass them in as input, or move generation into an activity whose result is recorded in history.

Calling external systems directly

HTTP clients, database calls, message bus publishes and file reads made straight from workflow code run again on replay, which can duplicate side effects and return different data. Move each of these into an activity with explicit timeouts and retry policy, and have the workflow call the activity by its defined interface. Confirm which .NET SDK helpers are permitted in workflow code, since the rules differ from activity code.

Using threads, tasks and locks

Starting Task.Run, Thread objects, timers from System.Threading, or lock-based coordination inside a workflow bypasses the scheduler that Temporal uses to replay execution order. Parallel work should be expressed with the SDK's workflow-safe task and wait primitives, so the order of completion is recorded. Review any async code in workflow classes for calls that resume on thread pool threads.

Iterating unordered collections

Looping over a Dictionary or HashSet and acting on each item in enumeration order can produce a different sequence after a process restart or a runtime change, because the order is not part of the contract. When the sequence of commands matters, sort keys explicitly, or keep the collection as an ordered list in workflow state. Confirm that the iteration order used in your workflows is stable across worker processes.

Reading environment and configuration at runtime

Reading environment variables, feature flags or configuration files inside workflow code means a replay can see a different value than the original run did. A worker that is redeployed with a changed setting can then fail replay for workflows already in flight. Pass configuration as workflow input, or read it in an activity and return the result. Use the SDK's versioning API when a code path must change for running workflows.

Fitting the Temporal .NET SDK into existing services

When the service is designed around Temporal from the start, workflow code, activities and workers form the core of the service rather than an add-on. Register the Temporal client and workers in the host's dependency injection container during startup so that activities receive their dependencies through constructors. Keep connection settings (server address, namespace, task queue names and TLS options) in the standard configuration system so each environment can change them without code changes.

  • Container registration: Register the client once as a singleton and create workers in hosted services so they share the host's lifetime.
  • Activity boundaries: Put every call to a database, HTTP API, email system or message queue in an activity with typed inputs, so workflow code stays free of I/O.
  • Worker placement: Run workers in the API process only for small deployments. Separate worker deployments scale independently and are easier to upgrade.
  • Shutdown: Tie worker start and stop to the host lifetime so the stop signal lets in-flight activity tasks finish. Confirm the drain timeout in the SDK version you pin.
  • Environment separation: Keep namespace and task queue names in configuration so test and production environments use separate namespaces.

Check that a second worker deployment can attach to the same task queue without code changes before the first production release.

Setup sequence for the Temporal .NET SDK project

This sequence takes a team from an undecided Temporal deployment to a working .NET worker and client that run one workflow end to end. Each step ends with a check you can repeat, so problems surface before application code grows around them.

  1. Choose the Temporal Service and namespace

    Decide whether the team will run self-hosted Temporal in infrastructure it controls or use Temporal Cloud, and confirm this with the people who own networking, identity and data residency. Create a dedicated namespace for the project's development environment and record its name, region or host address, and retention setting. Done means the namespace is listed in the chosen service's management interface and the team can reach its endpoint from a developer workstation. For self-hosted deployments, confirm that the Authorizer is configured before anyone connects, because the default noopAuthorizer allows every API request.

  2. Install and pin the .NET SDK packages

    A .NET developer adds the Temporal SDK NuGet packages to a new solution and pins exact versions in the project file rather than floating ranges. Before pinning, read the SDK release notes and confirm that the chosen SDK version supports the Temporal Server version in use, including any server minimum listed there. Done means dotnet restore completes on a clean machine and the lock or version pins are committed to source control with the release notes link recorded in the repository readme.

  3. Configure the client connection and TLS

    Create a single shared client configuration that reads the target address, namespace and certificate or API key settings from environment variables or a secrets store, not from source code. For self-hosted mTLS, load the client certificate and key and the CA bundle that the frontend expects. For Temporal Cloud, configure the API key or mTLS credentials the account issues. Done means a small console program connects to the namespace and prints the server's namespace description, and a deliberately wrong certificate or address fails with a clear connection error.

  4. Define the first workflow and activity

    Write one workflow class with a single method that calls one activity, and keep workflow code free of I/O, random values, current-time calls and direct reads of environment variables. Put the activity in a separate class that performs the external work, and set explicit start-to-close timeouts and a retry policy on the activity options. Done means the solution builds with no analyzer warnings on the workflow project and the team can read the workflow method and confirm that every external effect sits inside an activity.

  5. Register the worker on a task queue

    Create a worker that listens on a named task queue and registers the workflow and activity types. In an ASP.NET Core or Generic Host application, run the worker as a hosted service so it starts and stops with the process, and use the same task queue name in both the worker and the client that starts workflows. Done means the worker starts without errors, logs that it is polling the task queue, and the Web UI or CLI shows the queue with at least one active poller.

  6. Start a workflow and confirm it in the Web UI

    Start the workflow from a client with a unique workflow ID, then open the namespace in the Temporal Web UI or query it with the CLI. Confirm that the execution appears, that the activity event is recorded in the history, and that the workflow reaches Completed with the expected result. Done means the team can point to the workflow ID, its history events and the final result, and the same result is returned by the client.

  7. Run the workflow on a local development server

    Start a local Temporal development server with the Temporal CLI, point the client configuration at it through a separate profile, and run the same workflow test. Use the test server or time-skipping environment provided by the SDK for unit-level checks that need no running service. Done means a repeatable local run completes the workflow and an automated test in the test project passes in CI, which gives the team a baseline before any determinism or replay checks are added.

  8. Record pinned versions and the setup checklist

    Write a short setup record in the repository that lists the Temporal Server version, the .NET SDK package versions, the .NET target framework, the namespace and the check each earlier step produced. Note the SDK release notes you used to confirm compatibility, and tell the team to repeat the checks whenever either side is upgraded. Done means a new engineer can follow the record from a clean machine and reach the same completed workflow without asking the original author.

How versioning and replay affect C# code changes

Temporal rebuilds workflow state by replaying recorded event history, so every change to workflow code can affect executions that are already running. When a worker picks up a workflow task, the .NET SDK re-executes the workflow method from the start and checks that each command it produces matches the events already in history. If a renamed method, a reordered call to an activity, or a changed timer no longer matches what was recorded, the worker reports a non-determinism error and the workflow task fails. Deleting a workflow or changing its signature in the same deploy as a worker restart can therefore break executions that were started days or months earlier, long before the new code path is ever reached.

The team has three options for each change. Compatible changes, such as editing activity implementations, altering logic that runs only inside activities, or adding code after the last recorded command, can usually ship as a normal deploy. Incompatible changes to workflow logic need the SDK's patching or versioning mechanism, which lets old histories keep the old branch while new executions take the new one, and the team must later remove the old branch once no open executions depend on it. The third option is to keep old workers running until existing executions complete, then switch code, which suits short-lived workflows but is hard to plan for long-running ones. Confirm the current .NET SDK versioning API, its exact method names, and its documented limits in the SDK documentation before writing the change, since these mechanisms have changed across releases.

Replay testing in CI is the control that catches these problems before production. Teams collect real event histories from the Temporal service, store them as fixtures, and run them against the candidate build as part of the pipeline, so a non-deterministic change fails the build instead of a live workflow task. Histories from long-running and recently changed workflows give the most useful coverage, and the fixture set should be refreshed as the code evolves. Replay tests do not prove that a change is safe for workflows that have not yet been recorded, so the release checklist should still require a review of every workflow definition touched by the change, and the team should confirm with its own SDK version how replay test tooling is invoked.

Security controls the .NET team configures on self-hosted Temporal

Temporal's self-hosted security controls sit mostly in the server configuration, but several change how .NET code connects, authenticates and handles payloads. Each card below names the control, the part the application team touches and the part the platform team owns, so both sides agree on the boundary before the first worker connects.

Default authorizer allows all requests

If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Platform teams own the decision to configure an Authorizer before any shared environment is used. The .NET team should confirm that its client code fails visibly when calls are denied, so authorization errors are not mistaken for network faults during testing. Check this setting in every environment, including staging, because workers built against a permissive server can hide missing credentials.

Security docs

Internode and frontend mTLS

Self-hosted Temporal supports mTLS with separate settings for internode traffic between Temporal services and frontend traffic from clients. The platform team issues and rotates the certificates for both paths. The .NET team configures its client with the client certificate and CA trust for the frontend endpoint, usually through the connection options in the SDK. Confirm that certificate expiry and rotation are handled without redeploying every worker, and test a worker with an expired or untrusted certificate so the failure mode is known.

ClaimMapper and namespace roles

A ClaimMapper maps JWT or certificate claims to namespace roles, which decides what a caller can do in each namespace. The platform team defines the claim mapping and role model. The application team should request the narrowest role its workers need, usually the ability to poll a task queue and complete tasks in its own namespace, and avoid running workers with administrative roles. Review the mapping whenever a service is split, renamed or moved to a new namespace, since stale claims are a common source of unexpected access.

OIDC single sign-on for the Web UI

OIDC single sign-on applies to the Temporal Web UI, which operators use to inspect and act on workflow executions. The platform team configures the identity provider and the Web UI settings. The .NET team should know which groups or roles can view histories, terminate executions or reset workflows, because those actions can change production state. Confirm that the UI access model matches the namespace roles, so a user who cannot call the API through their service identity cannot act through the browser.

Payload encryption with codecs

Payload encryption uses custom codecs and a codec server, so workflow inputs, results and event history can be encrypted before they are stored. The application team writes and tests the codec in .NET, and the platform team hosts the codec server and manages keys. Confirm that the codec is applied on the client and the worker in the same way, and that the codec server is reachable only from the trusted network the Web UI uses. Losing or rotating a key without a plan can make old histories unreadable, so agree on key ownership before workflows go to production.

Keep services off the public internet

The Temporal deployment documentation says Temporal services should run on hosts not reachable from the public internet, with network access restricted to trusted internal networks. The platform team owns network exposure, load balancers and firewall rules. The .NET team should place its workers and services on the same trusted network segment and confirm that workers in other networks, including developer laptops, reach the frontend only through approved paths. Verify the exposure from outside the network as part of the deployment check.

Deployment docs

What a Temporal .NET SDK project costs and what it needs from your team

What drives the cost of a Temporal .NET SDK project?

The main drivers are the number of workflows and activities, how many external systems they call, how much existing .NET code must be wrapped or refactored, and how much of the hosting and security work is included. Cost has two parts: one-time build work (workflow design, worker code, tests, deployment) and recurring work (server operations, upgrades, on-call and worker maintenance). A written scope should list each workflow, each activity integration, the target hosting, the identity model and the test coverage expected, so that two quotes can be compared line by line.

How long does a first Temporal workflow take to reach production?

No duration is fixed by the SDK or the server, so the honest answer depends on the work around the first workflow. The timeline is driven by the hosting decision (self-hosted or Temporal Cloud), the identity and network setup, whether the team has already agreed on versioning and replay testing rules, and how many activities need real integrations rather than stubs. Ask for a timeline that separates environment setup, the first workflow build, test and replay checks, and the production cutover, with a named owner for each step.

Can our .NET team build Temporal workflows without outside help?

Often yes, if the team already runs .NET services in production and has someone who can own the hosting side. The learning curve is mostly about deterministic workflow code: which .NET APIs are safe inside workflow code, how changes are versioned, and how workflows are tested against recorded histories. Teams that lack an engineer who has operated a stateful service, or that need a self-hosted cluster on Kubernetes with mTLS and SSO, usually ask for help on those parts first. A short internal assessment of these skills is a fair input to the decision.

What does the work need from our developers and platform engineers?

Developers need to own workflow and activity code, unit and integration tests, and the versioning rules for changes to running workflows. Platform engineers need to provide a database for persistence, a visibility store, network paths between workers and the Temporal frontend, container or VM capacity for workers, secrets handling and monitoring. The written scope should name these responsibilities and the sign-off points, including who approves a change to a live workflow type.

What does the self-hosted server need to run securely?

The Temporal deployment documentation says services should run on hosts not reachable from the public internet, with network access limited to trusted internal networks. The security documentation also notes that if no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Plan mTLS between services, a ClaimMapper and Authorizer, and OIDC single sign-on for the Web UI before any workflow handles real data. Confirm each of these in the scope rather than assuming they are on by default.

How does Temporal Cloud pricing differ from running the server yourself?

Temporal Cloud is a managed service, so the recurring cost is a usage and support subscription instead of compute, database and operations staff time for the server. Temporal's pricing page lists pay-as-you-go pricing starting at 50 US dollars per million actions, with active storage at 0.042 dollars per GB-hour and retained storage at 0.00105 dollars per GB-hour, a 99.9% SLA or 99.99% with high availability, and SAML SSO. Support add-ons on the same page start with Business at 500 US dollars per month with a 2-hour P0 response in business hours, while Enterprise and Mission Critical are quoted by sales. Self-hosting removes the per-action fee but adds database, upgrade and on-call costs, so compare both against your actual action volume and staffing.

What should we request in a written scope before signing?

Ask for a list of workflows and activities with their external dependencies, the target hosting option and its reasoning, the environments to be delivered, the security controls to be configured, the test and replay checks, the handover material and the support model after go-live. Also ask what is excluded, how changes to scope are priced and approved, and who owns the Temporal Cloud or server account. Keeping those items explicit makes the quote comparable and reduces surprises during the build.

Limits and items to confirm before building

A .NET Temporal build depends on four moving parts: the SDK, the Temporal Server it talks to, the stores behind that server, and the hosting platform your workers run on. Confirm each one in your own environment before you write workflow code, because a mismatch found late usually means rework in worker hosting or persistence.

SDK version and support status

Pin the .NET SDK version your team will build against and confirm its support status with Temporal's SDK release notes and the SDK repository. Check which Temporal Server versions that SDK release is tested against, and whether it is the line your organization will still be supporting in two years. Ask your engineering lead to record the chosen version in the project's dependency file so that every worker and client uses the same version.

Temporal releases

Server version and upgrade path

Decide which Temporal Server minor line you will run and confirm it is compatible with the SDK version above. Temporal documents that upgrades should move one minor version at a time, so your platform team should own a written upgrade path before go-live. Confirm the exact server release with the platform owner and check its release notes for schema steps that must run first.

Upgrade step size
One minor
Upgrade docs

Persistence and visibility stores

Confirm that the database engine and version you plan to use for persistence and for visibility appear in Temporal's supported lists. SQLite is documented for development and testing only. For visibility, confirm whether your team needs Elasticsearch or OpenSearch, since Temporal recommends them beyond a small number of workflow executions. Ask your database team to confirm version support and sizing before the .NET services are designed around them.

Persistence docs

Payload size and history limits

Workflow histories grow with every activity, timer and signal, and payloads carry each input and result. Read the current payload size and event history limits in Temporal's documentation for your server version, then design workflows around them, for example by passing references to large data instead of the data itself. Have the .NET lead run a test workflow with realistic payloads to confirm that the design fits inside those limits.

.NET runtime and hosting platform

Confirm with the SDK documentation which .NET runtime versions the SDK supports, and whether your target hosting model (ASP.NET Core host, Windows service, container on Kubernetes) is an approved pattern. Workers run as long-lived processes that poll task queues, so check how your platform handles graceful shutdown and restarts. Your .NET platform team should confirm these details with the SDK maintainers before services are containerized.

Cloud or self-hosted feature needs

List the features your workflows depend on, such as namespace isolation, SSO for the Web UI, mTLS, or a custom payload codec, and confirm which deployment supports each one. Self-hosted Temporal has no authorization by default, so the security team must confirm the authorizer and claim mapping before production. If you are considering Temporal Cloud, confirm identity, SLA and support tier against Temporal's pricing page and sales quote.

Security docs

How DeployOpen works on this

DeployOpen is a Chainscore Labs company that plans, implements, customizes, hardens, documents and supports self-hosted open-source platforms inside your own infrastructure. For Temporal .NET work, we start from a written scope covering the workflows, activities, workers and service integration you need, then build and test that code in your environment.

How we scope

  • Inventory the workflows, activities and external calls that will run as Temporal code in your .NET services.
  • Agree in writing which services, task queues and Temporal namespaces are in and out of scope.
  • Define how workflow code will be tested, replayed and versioned before any change reaches production.

How we build

  • Write deterministic workflow code and idempotent activities in C#, with worker hosts run as hosted services.
  • Build replay tests from real event histories so non-determinism is caught in CI before deployment.
  • Wire the workers into your existing .NET services, configuration, secrets handling and logging.

How we hand over

  • Deliver source code, test suites and a deployment guide for your build pipeline and worker hosts.
  • Document workflow versioning rules, task queue ownership and the runbook for stuck or failed executions.
  • Walk your engineers through the code and the operational checks they will run after handover.

How we support

  • Offer ongoing support, SDK and server upgrade work and continuous testing as a retainer after handover.
  • Review planned changes to workflow code against replay tests before they are merged.
  • Confirm with your team which Temporal Server version, SDK version and deployment model the support covers.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.