Running OpenBao Agent as a Windows service

A practical guide to registering OpenBao Agent with the Windows Service Control Manager so Windows servers and .NET applications receive rendered secrets at boot.

On this page

Why run OpenBao Agent as a Windows service

Running OpenBao Agent as a Windows service makes sense when a Windows operations team runs .NET services that need secrets before they start, and nobody is logged on to launch anything. Without a service, someone has to sign in after every reboot, start a console process and keep it open, or hand a long-lived token to each application. Registering OpenBao Agent with the Windows Service Control Manager turns that sidecar into a managed process that starts at boot under a service account, runs in the background, and restarts after failures. The Service Control Manager is the piece that removes the interactive login step from the delivery path.

Once running, OpenBao Agent does three jobs. Auto-auth logs the machine in to OpenBao using a method suited to servers, such as AppRole, and writes the resulting token to a sink that only the agent and its service account can read. Template rendering pulls secrets from OpenBao and writes them to files such as application configuration, and it re-renders them as leases and values change. Token handling renews the token before it expires so rendered secrets stay current. Because the agent owns authentication and renewal, the .NET applications never see OpenBao credentials and do not need code changes to receive their configuration.

This pattern fits when the workload runs on Windows Server, the applications read configuration from files or environment variables, and the team wants secret delivery to work across reboots without manual steps. It is less suitable when the applications can call the OpenBao API directly and handle their own authentication, where OpenBao Proxy or a client library may be simpler, or when the platform is Kubernetes, where a different delivery model applies. Before committing, confirm with your own environment which auto-auth method your security team will approve for servers, which service account the agent will run under, and how the file system permissions on rendered output will be locked down.

How Agent delivers secrets at boot

The flow starts when Windows boots and the Service Control Manager starts the OpenBao Agent service. The Agent authenticates to the OpenBao server using its auto-auth method, then renders each template into a protected directory on the host. The .NET application reads those files, so it never calls OpenBao itself. Check that the trust boundary is where you expect it, and that the rendered directory is readable only by the service account and the application.

Boot-time secret delivery from the Windows host to the .NET application, across the trust boundary.

Which registration and auth options fit which Windows estate

This table compares the registration and authentication choices for OpenBao Agent on Windows, with the situations each one suits and its main trade-off. Read each row as a starting point: confirm the exact behavior of every option against the OpenBao Agent documentation for the version you plan to run before you commit.

OptionWhen it fitsMain trade-offWhat to confirm
Dedicated service accountServers where Agent must read secrets from file paths or network shares that only a named account can accessRequires password or managed account handling and explicit file and key permissions for each secret pathWhich account type your estate supports and how its permissions apply to the rendered output directory
Local system accountStandalone servers with no network share access needs and a short list of secretsBroad local privileges make a compromised Agent more damaging, and it has limited identity for auditingWhether the default service identity can reach your secret and template paths on your Windows version
AppRole auto-authServers and .NET hosts that need a non-human machine identity, which the project recommends for serversSecret-zero: the role ID and secret ID must be delivered and rotated securely to the hostHow secret ID delivery and rotation are configured, and whether wrapping is available in your release
Token file sinkHosts where another process or the Agent needs a token written to a restricted file for reuseA token file on disk is a credential, so NTFS permissions and lifetime must be tightly controlledExact sink options, file permission behavior and how renewal updates the file
sc.exe registrationTeams that want a native service entry with a fixed binary path and standard start type settingsService arguments and recovery behavior must be maintained by hand and are easy to mistypeQuoting rules for the binary path and arguments, and the recovery actions your standards require
Wrapper serviceEnvironments that need a service wrapper to handle logging, restarts or a process that does not run as a native serviceAdds another component to patch, monitor and auditWhether the wrapper is supported by your security team and how it passes exit codes and signals

Registering OpenBao Agent with the Service Control Manager

This sequence takes a Windows server from no secrets access to an OpenBao Agent service that starts at boot, authenticates with AppRole, and writes rendered secrets to protected paths that applications can read. Each step ends with a check so the server can be verified before applications depend on it.

  1. Prepare the server and OpenBao policies

    The OpenBao administrator creates a dedicated policy that grants read access only to the secret paths this server needs, and an AppRole role bound to that policy. The Windows administrator creates a local service account or group-managed identity for the Agent, confirms that the server reaches the OpenBao API address over the expected TLS endpoint, and records which secret paths map to which files. The step is complete when a test login with the AppRole credentials succeeds from this server and a read of a permitted path works while a read of an unpermitted path is denied. Confirm the exact AppRole and policy syntax against the OpenBao auth methods documentation for your release.

  2. Place the Agent binary and configuration

    Install the OpenBao Agent binary in a directory under Program Files that only administrators can write to, and store the configuration file and the AppRole role ID and secret ID files in a separate directory with restricted permissions. Remove inherited permissions on the configuration directory, grant read access only to the Agent service identity and administrators, and create a dedicated output directory for rendered files. The step is done when an icacls review shows that standard users cannot read the secret ID file or modify the binary, and the Agent runs in the foreground from an administrator shell without errors.

  3. Configure AppRole credential delivery

    Configure the Agent's auto-auth block to use the AppRole method, pointing the role ID and secret ID file paths at the protected directory, and set a file sink for the token so other processes can use it only if they have permission. Decide how the secret ID is delivered and rotated, since the file is the only credential that starts the Agent, and document who can replace it. The step is complete when the Agent authenticates in foreground mode, writes the token file, and renders at least one test secret into the output directory. Confirm the auto-auth and sink settings against the Agent documentation for the release you deploy.

  4. Register the service with a network dependency

    Register the Agent with the Service Control Manager using sc.exe or a service wrapper your team already supports, setting the binary path to include the configuration file argument and the service to start automatically. Set the service to depend on the network stack so it does not start before the network is available, and run it under the dedicated service identity rather than LocalSystem where your policy allows. The step is done when sc.exe qconfig shows the expected start type, binary path, and service account, and the service reaches the Running state after a manual start with the output files updated.

  5. Set recovery actions for failures

    Configure the service recovery options so Windows restarts the Agent after a failure, using sc.exe failure settings with a reset period and restart actions that match your operations runbook. Record the restart behavior in your change records, and make sure the alerting team knows which event log entries indicate a repeated failure, such as authentication errors from an expired secret ID. The step is complete when sc.qfailure shows the recovery actions you set, and a deliberate stop of the process triggers the expected restart in a test window.

  6. Verify startup with a reboot test

    Reboot the server without any manual action, then check that the Agent service is running, that the token file and rendered secrets are present and recent, and that the Windows event log contains no authentication or template errors from the Agent. Confirm that a dependent application can read the rendered file under its own identity and that a second user account cannot. The step is done when the post-reboot checks pass on the first attempt, and the results are saved with the change record so the configuration can be repeated on other servers.

Protecting secret-zero and rendered files on Windows

The secret that lets OpenBao Agent log in is the first secret on the server, and every file or token the Agent writes inherits the protection of the directory it lands in. The cards below cover the controls that connect those two surfaces, plus the service account, logs and restart behavior that can leak values after the initial setup is done.

AppRole secret ID on disk

The secret ID is the credential that lets the Agent authenticate with AppRole, so whoever reads it can request tokens for that role. Decide where it is delivered, who can read that location, and whether it is single-use or bound to specific CIDRs in the AppRole configuration. Verify that the file holding it is readable only by the service account and administrators, and that the secret ID is rotated after provisioning rather than reused indefinitely.

AppRole auth docs

NTFS permissions on rendered files

Templates write secrets into files such as configuration files on disk, and those files often inherit permissions from a broad parent folder such as a shared application directory. Set explicit ACLs on each rendered output so that only the application's service account and required administrators have read access. Verify with an effective-access check from a standard user account, not only by inspecting the ACL in the console.

Token sink permissions

When auto-auth writes a token to a sink file, that token can read whatever policies allow, so the sink needs the same protection as a rendered secret. Confirm the sink path is in a directory the Agent's service account owns, that inheritance from parent folders is reviewed, and that no backup job or antivirus exclusion copies the file to a wider location. Check that the sink file is removed or replaced when the Agent stops if your design requires it.

Service account privileges

The Windows service runs under an identity, and that identity decides what the Agent can read and what an attacker gains by compromising the process. Use a dedicated local or managed service account with only the log-on right needed for the service, not an administrator or a shared domain account. Verify group memberships, the 'log on as a service' assignment, and that the account cannot modify the Agent binary or its configuration directory.

Logs that echo values

Agent logs record authentication events, template renders and errors, and a misconfigured template or debug level can write secret contents into the Windows Event Log or a log file. Set the log level deliberately, confirm that the log destination has restrictive permissions, and check that forwarding to a central log system does not copy rendered content. Test by triggering a render error and reviewing what was written.

Restart and re-render behavior

When the service restarts after a crash or reboot, it re-authenticates and re-renders every template, so stale files can persist between failure and recovery. Decide whether old rendered files should be cleared on stop, how the Windows service recovery actions are configured, and whether dependent application services wait for the Agent before starting. Verify the boot sequence on a test server by reading the rendered files and sink contents after a forced restart.

Questions teams ask before running Agent on Windows

How much effort does running OpenBao Agent as a Windows service take?

The effort depends mostly on how many servers and applications receive secrets, how many auth paths you need, and how much of the setup is already standardized. The core work is registering the Agent with the Service Control Manager, writing the Agent configuration, setting up auto-auth, defining templates for each application, and testing reboot behavior. Each additional application adds its own template, restart command and permission review. Ask any partner to split its quote into a one-time build for the service pattern and a per-application cost, so you can see which part grows as you add servers.

Can our internal team set this up without outside help?

Yes, if you have engineers who already run OpenBao or Vault, understand Windows services and can test reboots on a non-production server. The harder parts are rarely the service registration itself. They are choosing an auth method that suits servers, designing least-privilege policies, handling file permissions on rendered secrets and documenting recovery. Teams with no prior OpenBao experience usually need training or a short build with a partner first. A partner can also build the pattern and hand it over so your team runs it afterward.

What do we need to provide for the work to start?

Plan to provide the following before work begins:

  • Active Directory details: the service account or group that will run the Agent, and who approves changes to it
  • OpenBao access: a running cluster you control, the auth method to use, and the policies and paths each application may read
  • Test servers: at least one Windows Server host that matches production, with a way to reboot it and check services
  • Application details: which services or .NET applications read the rendered files, their restart commands and the file paths they expect
  • Change windows and an owner for sign-off on the pilot
How long does a pilot take?

A pilot length depends on how many applications you want to cover, how many auth paths you need and how quickly your change process approves access and test servers. Pilots that use one application and one auth method usually finish faster than ones covering several platforms. Your schedule will also depend on how long it takes to get the OpenBao policies, service account and test host approved. Ask for the timeline in the written scope, with milestones for the boot test, the restart test and the handover. No duration is given here because the time depends on your environment.

Does OpenBao Agent work with IIS application pools?

Whether Agent suits an IIS application pool depends on how the application reads its configuration and how the pool identity can access the rendered files. Agent runs as a Windows service, so the rendered files must be readable by the worker process identity, and restarting the pool after a secret change must be planned. Confirm the exact behavior with your application team and test it on a server that matches production. Also confirm with the OpenBao documentation which Agent features apply on Windows for your version before you commit to this pattern.

What are the main risks when Agent renders secrets on Windows?

The main risks are rendered files readable by users who should not see them, tokens stored in places with weak access control, and services that start before the Agent has written current secrets. Mitigate these with restrictive NTFS permissions on the output directory and token sink, a service account with only the policies it needs, and boot-order tests. Also document how to revoke access if a server is compromised. Ask any partner to show how the security review, permissions and recovery steps are written into the handover.

Who maintains the Agent after the pilot?

Your team maintains the Agent after handover unless you buy a retainer. Ongoing work includes applying OpenBao and Agent updates, reviewing policies as applications change, rotating the credentials used for auto-auth and testing reboots after patches. Check the OpenBao release notes before each upgrade, and confirm which versions you plan to run. Ask whether support is included in a fixed-scope engagement or sold separately as a retainer.

Running and monitoring the Agent after go-live

Day-two work on a Windows Agent comes down to four routine checks: the service state in the Service Control Manager, the Agent's own logs, the health of the token it uses to reach OpenBao, and the age of the AppRole secret ID it was given at install. Set up a check for the service state and the log output before go-live, because a service that reports as running can still be failing to authenticate or to render files. Confirm with your monitoring team which Windows event or log source they will watch, and confirm the log destination and verbosity you configured on the Agent, since both determine what an alert can see. Treat the Agent's logs as the primary record of renewal and render failures, not the service status alone.

Token renewal failures are the most likely source of a silent outage. When the Agent cannot renew its token, the rendered files stop updating while the application keeps reading the last good copy until its own lease or the file's age becomes a problem. Decide in advance who receives an alert when renewal fails and what the response is, including whether the Agent restarts automatically under the Windows recovery settings for the service. For rotation, plan a change window for AppRole secret IDs: generate the new secret ID, deliver it through your existing secret-zero process, update the Agent's configuration or credential file, restart the service, and then revoke the old secret ID once the new one is confirmed working. Ask your OpenBao administrator which secret ID lifetime and use limits the AppRole role enforces, because those settings decide how often this rotation must happen.

Plan Agent upgrades in a defined maintenance window, one server or pool at a time, and keep the previous Agent binary available for rollback. Run the upgrade on a non-production server first, then confirm that the service starts, that auto-auth succeeds and that a rendered file changes when a test secret is updated. Test reboots the same way: restart each server, confirm that the service starts in the expected order relative to the applications that depend on it, and confirm that the files exist with correct permissions before those applications read them. Record the results. For alerting design, monitoring of the OpenBao server itself and the wider secrets platform is covered in the related area OpenBao operations and monitoring, which you should review before you choose metrics for this Agent.

Rolling the pattern out across a Windows fleet

The sequence moves the service account, template and service registration from one non-production server to production in controlled waves, so each stage proves the pattern before it reaches more hosts. Every stage ends with a recorded check that decides whether the next stage starts.

  1. Pilot the pattern on one non-production server

    Your platform engineer installs OpenBao Agent, registers the service and runs the full configuration on a single non-production Windows server that matches the production build as closely as possible. Confirm the service account, auto-auth method, template paths and service recovery settings all match the written design. The step is done when the pilot server starts the service, renders its files and logs a clean authentication with no manual intervention.

  2. Validate template output and file permissions

    Your security engineer checks that every rendered file contains the expected secret fields, that no unrelated secrets appear in the output, and that the NTFS access control list grants read access only to the application's service account and administrators. Confirm that the token sink and any cache files sit in locations with equivalent restrictions. The step closes when the permission report and a sample rendered file are attached to the change record.

  3. Test reboot and recovery behavior

    Your operations team reboots the pilot server and confirms the Windows service starts automatically, authenticates to OpenBao and re-renders files before the dependent application starts. Then they stop the service, simulate a lost token or a temporarily unreachable OpenBao endpoint, and check that the failure appears in the event log and that the service recovers when connectivity returns. The step is done when both tests produce the expected results and the start order with the application is documented.

  4. Test failover against the OpenBao endpoint

    Your platform team points the pilot configuration at the high availability address of the OpenBao cluster and then takes one cluster node out of service, observing whether the agent keeps working through the remaining nodes. Confirm the agent's address configuration uses the load balancer or DNS name your design specifies, not a single node. The step closes when the failover result is recorded and any configuration change it required is reflected in the template for all hosts.

  5. Promote the approved build into staged production waves

    Your release owner deploys the validated installation package, configuration and service registration to production in small waves, starting with a limited group of hosts that run low-impact applications. Each wave runs the same checks as the pilot, and the next wave starts only after the previous one shows clean authentication, correct file permissions and a successful reboot test. The step is done when every host in the wave is recorded in the inventory with its service status and configuration version.

  6. Prepare and rehearse rollback for each wave

    Before each production wave, your operations team writes down how to stop and disable the service, remove the rendered files, restore the previous application configuration and revert the registration. They rehearse the procedure on the pilot server so the steps and their order are known to the on-call staff. The step closes when the rollback runbook is approved and each host's previous configuration is retained for restoration.

  7. Confirm the fleet state and hand over operations

    Once every wave passes, your team compares the inventory against the design, checks that each host renders its files and that the service is set to start automatically, and confirms that alerting covers authentication failures and stopped services. The owner of the Windows fleet then accepts the service into standard operations with the runbook, the configuration version and the list of exceptions. The step is done when the handover record is signed and the rollout is closed in the change system.

When a partner scopes this work

A fixed-scope engagement for this topic starts with discovery: an inventory of the Windows servers, Windows services and .NET applications that need OpenBao secrets, the secrets each one reads, how often those values change, and which service accounts currently hold them. The partner then writes a registration design covering the service account the Agent runs under, the Service Control Manager recovery and startup settings, the auto-auth method for each host class, the template output paths and the restart behavior of each dependent application. Configuration, testing and documentation follow from that design, and the written scope should name each of these as a deliverable with its acceptance check.

The client has to provide the inputs that the design depends on. That means access to the Windows hosts and a test environment that matches them, the OpenBao endpoint and namespace layout, the approved authentication method and policy owners, the list of applications with their current secret locations, and a named contact who can approve ACL changes on the secret output directories. Ask the partner to confirm in writing which of these they expect you to supply and which they will request during discovery, because a missing inventory or an unavailable test host is the most common reason a fixed scope moves.

DeployOpen works inside your own infrastructure, in your Windows domain, your OpenBao cluster and your change process, so the engagement never requires your secrets to leave your environment. The quote follows from the written scope: the number of hosts, services and applications, the authentication methods in use and the testing depth you require. Ask the partner which parts of the quote are one-time (design, build, first test cycle) and which recur (upgrades of the Agent binary, changes to templates, support), and whether the documentation handover includes runbooks your operations team can use without the partner present.

How DeployOpen scopes, delivers and supports this

DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside the client's own infrastructure, including the Windows servers and .NET hosts where OpenBao Agent runs. For a Windows service deployment, the work starts with a written scope that names the hosts, the auth method, the templates and the applications that will receive secrets.

How we scope

  • Inventory the Windows servers, service accounts and .NET applications that will receive rendered secrets
  • Agree the auth method for each host and the OpenBao policies each service identity may read
  • Confirm the secret paths, template targets and file permissions before any build work starts
  • Record scope, deliverables and timelines in writing, since most engagements are fixed-scope

How we build

  • Install and register OpenBao Agent as a Windows service with the Service Control Manager in your environment
  • Configure auto-auth, token sinks and templates so secrets are written only to approved locations
  • Test boot ordering, service recovery and secret rotation on representative hosts before production
  • Run security checks on file permissions, service account rights and credential handling

How we hand over

  • Deliver the configuration, service definitions and runbooks for each Windows host in the scope
  • Document the restart, rotation and troubleshooting steps your Windows administrators will use
  • Walk your platform, security and application teams through the setup and the evidence it produces
  • Provide the test results and fixes needed for your compliance or security reviewers to assess the setup

How we support

  • Offer ongoing support, upgrades and continuous testing as a retainer after the handover
  • Plan OpenBao Agent version upgrades with your change process and test them on non-production hosts first
  • Review new hosts and applications added to the Agent configuration against the agreed scope
  • Confirm support terms, response expectations and retainer scope in the written quote

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.