Running HAPI FHIR on SQL Server and Azure SQL: when your team needs it
This page covers how to run a self-hosted HAPI FHIR JPA server on Microsoft SQL Server or Azure SQL, and the SQL Server settings that decide whether the server performs well and upgrades cleanly. It is written for organizations with an existing Microsoft data estate that must keep FHIR data inside infrastructure they control. The HAPI FHIR JPA server starter supports Microsoft SQL Server for production, alongside PostgreSQL, and it defaults to an embedded H2 database for development only. The JPA layer is designed to work with any supported relational database, so the choice of SQL Server does not change the FHIR API your applications see. What changes is the database behavior underneath it.
That behavior is where most SQL Server projects run into trouble. Connection settings, collation, the database compatibility level and the way IDs are stored all affect whether indexes are used, how searches on large ID sets perform, and whether a version upgrade changes existing data in ways you did not plan for. Decide early whether you will run SQL Server on premises, on a virtual machine, or as Azure SQL, because managed service features, backup tooling and patching responsibilities differ. Ask your DBA team to confirm the edition, licensing and high availability design before the schema is created, since moving a populated FHIR database later is far more work than choosing the right settings at the start.
Treat every SQL Server-specific setting in this topic as version-dependent. Check the HAPI FHIR documentation for the release you intend to deploy, including its Java requirement, the supported SQL Server versions and any schema migration notes, before you write configuration. HAPI FHIR 8.2.0 requires JDK 17, and the current release line is documented in the project's releases page. Build a test environment that mirrors your production SQL Server version and collation, load representative data, and run your search and upgrade checks there before any production change.
Which SQL Server settings fit which deployment
This table compares the SQL Server decisions a team makes before the HAPI FHIR JPA server goes live: where the database runs, the JDBC Unicode setting, collation and compatibility level. Read each row as a question to settle with your DBA and the HAPI release you run. The main takeaway is that collation and the Unicode setting are hard to change after data is loaded, so settle them before the first load.
| Setting | When it fits | What it affects | What to confirm |
|---|---|---|---|
| SQL Server on-premises | Data must stay on servers your organization runs and patches | You own instance sizing, high availability, backups and collation set at install | Supported SQL Server versions and editions for your HAPI FHIR release |
| Azure SQL | You want the provider to handle host patching and backups within your Azure tenant | Some server settings are fixed by the service tier; collation is set when the database is created | Which settings you can change on your tier, in Microsoft's Azure SQL documentation |
| JDBC Unicode setting (sendStringParametersAsUnicode) | Every deployment; the value must suit the column types in the HAPI schema | Unicode-typed parameters compared with varchar columns can prevent index use and slow searches | The value HAPI documents for your release, checked with query plans in staging |
| Case-sensitive collation | Existing IDs differ only by letter case and must stay distinct | String comparison and ID uniqueness follow case for new data and for searches | The 8.8 upgrade notes on case-sensitive IDs and how your existing data is stored |
| Case-insensitive collation | Clients treat IDs as the same regardless of case, or data was loaded that way | Searches and uniqueness ignore case, which can merge IDs that differed only by case | Whether existing data contains IDs that differ only by case before you choose |
| Compatibility level 130 | Large ID searches run slowly and load tests show the optimizer gains from this level | Changes query plan choice for the whole database, so every workload on it is affected | Whether HAPI documents this level for your release, and Microsoft's compatibility notes for it |
| Other compatibility levels | HAPI guidance or your own load tests call for a different level | Plan behavior changes; rerun the full FHIR search test suite after each change | The level HAPI documents for your release and Microsoft's compatibility level notes |
How the JDBC Unicode setting can defeat indexes
The Unicode parameter binding choice in the JDBC driver can stop SQL Server from seeking on an index, even when the index exists and covers the search. The Microsoft JDBC driver sends string parameters as nvarchar by default. HAPI FHIR's search columns for IDs and string values are typically varchar in a database created with a non-Unicode collation. When the parameter type is higher in data type precedence than the column, SQL Server converts the column side of the comparison to match the parameter. That conversion is applied to every row the index holds, so the optimizer cannot use the index seek it would otherwise choose and falls back to a scan.
The effect is easy to miss because queries return correct results, only more slowly as tables grow. To confirm it, capture the actual execution plan for a representative search, such as a token or string search on a large resource table, and look for an index scan where you expect a seek. Then check the predicate: a CONVERT_IMPLICIT on the indexed column confirms the mismatch. Run the same query with explicit parameter types in SQL Server Management Studio to compare the plans. Confirm the exact connection property that controls Unicode string binding in the current Microsoft JDBC driver documentation and in the HAPI FHIR JPA server configuration for your version, since property names and defaults change between releases. Test the change in a non-production copy of the database before applying it, and record the plans before and after.
Collation and case-sensitive IDs: what goes wrong
Collation is set when the database and its tables are created, and it governs how SQL Server compares ID strings, sorts them and matches them in indexes. Each card names a decision or check that connects to HAPI FHIR on Microsoft SQL Server and Azure SQL, so the choice is made before the first resource is stored.
Case-sensitive ID matching
A case-insensitive collation treats two IDs that differ only in letter case as equal, so a create, read or update can act on the wrong record. Decide whether source systems can produce such pairs, and whether your clients rely on exact case. Confirm in the HAPI FHIR release notes for your target version how IDs of differing case are handled, then write the decision into your data standards before the first load.
Database and application collation
Collation exists at server, database and column level, and a mismatch between them can change comparison results without raising an error. Read the collation of the database and the HFJ tables after creation, not the value in your deployment template, and compare it with what reporting tools and external systems assume. The JPA server is designed to run on several databases, so the SQL Server collation is an operator decision that the application will not make for you.
JPA server docsUnicode parameters hide indexes
The JDBC Unicode setting sends string parameters as national character types, and comparing them with non-Unicode columns can force SQL Server to convert each value during the query. The result is that the index is not used, and searches slow as the table grows. Check the JDBC connection string used by the starter, run the search queries your clients send against a populated test database, and review the execution plans for scans on ID columns.
Changing collation after data exists
Changing the collation of a database that already holds resources is a data project, not a settings change. Each affected column must be altered, its indexes rebuilt and any unique constraints validated against the new comparison rules. Ask for the upgrade or migration plan to state how collation changes are handled, rehearse the change on a restored copy, and confirm that the schema migration in the target release does not assume a different collation.
Testing with mixed-case IDs
Standard test data often uses lowercase IDs, so case collisions go unnoticed until production. Build a test set that includes IDs differing only by case and run it through create, read, update, delete, conditional update and search operations against the same collation as production. Include identifiers exported from each source system, because the risky values usually come from those systems and seldom from hand-written fixtures.
Release 8.8 ID migration
Release 8.8 affects how case-sensitive IDs are handled during migration, so upgrading from an earlier line can change stored IDs. Read the release notes for your exact target version, including the 8.8 line and any later patch you plan to deploy, and identify which of your IDs differ only by case. Run the migration on a restored copy, then compare resource counts and sample reads before scheduling the production change.
Release notesSetting up HAPI FHIR on SQL Server or Azure SQL
This sequence takes a HAPI FHIR JPA server from an empty Microsoft SQL Server or Azure SQL database to a running server with the collation, compatibility level and JDBC settings it needs. Each step ends with a check so that problems surface before data is loaded.
Provision the database and collation
The team provisions a SQL Server instance or Azure SQL database in infrastructure the organization controls, then creates a dedicated database and login for the FHIR server. The database collation must be case-sensitive, because HAPI FHIR stores resource IDs and some search values in a way that a case-insensitive collation can make ambiguous. Confirm the collation with the database owner before any schema is created, since changing it later usually means rebuilding the database. The check is a query of the database collation that returns a case-sensitive value, recorded in the deployment notes.
Set the database compatibility level
The DBA sets the database compatibility level to 130 for the FHIR database, which HAPI FHIR's guidance on large ID searches relies on. Confirm the value against the current HAPI FHIR documentation for your release, because the supported levels can change between versions. Keep the server edition and version in mind, since Azure SQL and on-premises SQL Server expose this setting in slightly different ways. The check is a query of the compatibility level for the FHIR database that returns 130, with the result saved alongside the collation record.
Configure the datasource and JDBC settings
The platform engineer deploys the hapi-fhir-jpaserver-starter with the Microsoft SQL Server driver and sets the datasource URL, username, password and dialect in the starter configuration. Take exact configuration keys from the current starter documentation rather than from older examples, and store the password in the organization's secrets manager, not in the image or the repository. Pay particular attention to the JDBC Unicode setting: the driver option that sends strings as Unicode must be set so that indexed string comparisons are not defeated. The check is a successful connection from the server pod or host, and a test query showing the expected database name and collation.
Run the schema migration
The server is started with the schema initialization or migration mode the starter documentation describes for the release being deployed, so that the HFJ tables and indexes are created in the empty database. Run the migration once, from a single instance, and capture the log output so that any failure is traceable. Do not point several replicas at an unmigrated database at the same time. The check is a clean migration log with no errors, followed by a query confirming that the expected HFJ tables and their indexes exist.
Verify indexes and collation behavior
The DBA reviews the index definitions created by the migration and confirms that the string indexes on the search tables are present and used. Run the server's capability statement request and a simple search on a test resource, then examine the execution plan for that search to confirm that an index seek is used rather than a full scan. If the plan shows a scan on a string column, check the JDBC Unicode setting from the previous step before continuing. The check is a saved execution plan for at least one representative search with its index seek recorded.
Confirm search behavior with test data
The team loads a small, known set of test resources with IDs in mixed case and runs reads, searches and updates to confirm that case-sensitive IDs are stored and returned exactly as sent. Include a search on a string parameter to confirm that the collation behaves as expected for the organization's data. Record the results, because they become the baseline for later upgrades and performance tuning. The check is a documented test run where every resource is returned with the ID and search results expected from the test plan.
Record the configuration and the baseline
The platform team writes down the final collation, compatibility level, JDBC settings, starter version, Java version and migration output in the deployment record, and stores the configuration under version control with secrets excluded. The baseline includes the execution plans and test results from the earlier checks. This record is what the upgrade and monitoring work will compare against, so it should be reviewed by the DBA and the application owner before production data is loaded. The check is a signed-off deployment record that another engineer could use to rebuild the environment.
Why compatibility level 130 matters for large ID searches
Compatibility level 130 is a database setting that asks SQL Server to use the query processing behavior of SQL Server 2016, and it matters for HAPI FHIR when a search passes a long list of IDs, such as a _id parameter or a chained search that expands into many resource IDs. Under older compatibility levels, the optimizer can choose a plan for these lists that performs poorly as the list grows. Raising the level can change that plan, but it can also change plans for queries that were already fast, so treat it as a decision to test on your own data rather than a default to apply everywhere.
Start by reproducing the workload. Build a test database from a representative export, not a small fixture, and run the searches your clients actually send at realistic ID volumes, including the largest lists you expect in production. Record execution time, logical reads and the plan shape for each run at the current compatibility level, then repeat at level 130 on the same data and the same HAPI FHIR version. Compare plans with the query store if it is enabled, and check for regressions in simple searches as well as the large ones. Confirm the exact behavior for your build with Microsoft's documentation on database compatibility levels, and confirm which SQL Server versions and compatibility levels your HAPI FHIR release supports in its own documentation before you change anything in production.
Security and operations on a SQL Server backed FHIR server
A HAPI FHIR JPA server stores clinical data in whatever database it is pointed at, so the database account, connection encryption, backups and data access logs are part of the server's security design. HAPI FHIR provides building blocks rather than a single security layer, so the controls below need to be designed around the SQL Server or Azure SQL database from the start.
Least-privilege database accounts
Give the starter its own SQL login with rights limited to the schema it needs, and keep schema migration rights separate from the account the running server uses. Migration runs usually need elevated permissions for initial setup and upgrades, so decide who holds those credentials and when they are used. Confirm with your DBA which permissions the migrator and the running application each require for the HAPI FHIR version you deploy, and rotate both credentials through your secrets store rather than a configuration file.
Encrypted database connections
Require TLS on every JDBC connection from the HAPI FHIR server to SQL Server, and validate the server certificate instead of trusting any certificate. Check the encryption options in your JDBC driver version, since defaults for certificate trust have changed between driver releases. Verify with a packet or driver log test that the connection is actually encrypted in each environment, including the migrator job.
Backups and tested restores
Set full and transaction log backups for the FHIR database to match the recovery point your organization has agreed to, and store copies outside the server's failure domain. A backup that has never been restored is not evidence of recovery, so run restore tests into a separate environment and time them against your recovery target. Include the search index tables and the schema version in the restore check, since a restored database must match the HAPI FHIR version that runs against it.
Azure SQL firewall and private networking
For Azure SQL, decide between public endpoints restricted by firewall rules and private endpoints reached through your virtual network. Private endpoints keep the database off the public internet, but they add DNS and routing work for the application and the migrator. Confirm the current networking options and their limits in Microsoft's documentation for your tier before you choose, and test name resolution from every node that connects.
Authorization and audit of data access
HAPI FHIR does not decide who may read which resource on its own, so the authorization interceptors and consent rules must be designed alongside the database. Database-level auditing can record which logins read or changed tables, but it sees SQL statements, not FHIR users or patients. Map FHIR user identity to the audit trail with the server's audit logging, and agree which events you retain and for how long before go-live.
HAPI FHIR security docsQuestions teams ask before running HAPI FHIR on SQL Server
What drives the cost of running HAPI FHIR on SQL Server?
Cost comes from four places: the implementation work, the SQL Server licenses or Azure SQL subscription, the hosting and backup storage underneath, and the support or upgrade work after go-live. The implementation fee is one-time and covers design, installation, configuration and validation, with scope and deliverables agreed in writing before work starts. Licensing and hosting recur, and their size depends on the SQL Server edition, core or vCore count, data volume and the number of environments you run. Effort rises with high availability requirements, the number of FHIR interfaces that must be tested, and how much SQL Server capacity your organization already has. Ask any quote to separate one-time work from recurring costs and to state which licenses it assumes you already hold.
How long does setup and validation usually take?
No duration is meaningful without a written scope, so the answer depends on what the work includes. Duration grows with the number of environments, whether SQL Server already exists in your estate, how many interfaces and resource types need functional testing, and whether load testing and restore testing are part of the work. Several steps wait on people: a DBA must approve accounts and maintenance windows, security reviewers must sign off service accounts and TLS settings, and data owners must supply samples. Most engagements are fixed-scope, so the timeline appears in the written agreement along with the dependencies on your side. Ask the provider to show each validation step, who performs it and what evidence it produces.
What must our team provide before a SQL Server engagement starts?
Before work starts, you need to supply four things:
- Licensing: a SQL Server edition or Azure SQL subscription confirmed with your Microsoft agreement, plus the core or vCore count you plan to use.
- Environments: non-production and production hosts or resource groups, network paths from the application and reverse proxy, and backup storage.
- Data samples: representative FHIR data, synthetic or de-identified, large enough to test search behavior and index use.
- DBA and security time: people to approve database accounts, collation and recovery model decisions, TLS settings and maintenance windows.
Name an owner for each item in the kickoff plan so delays show up early. Missing samples and slow approvals are the most common reasons a validation phase runs longer than planned, so confirm their dates in the written scope.
Can an internal team set up HAPI FHIR on SQL Server alone?
Often yes, if the team already runs Java services and has SQL Server administration skills, but the cost of mistakes should decide it. Deploying the starter needs Java, Spring Boot or Docker experience, while the database settings need DBA judgment on collation, compatibility level and index tuning. Errors tend to appear late, when data volume grows. A wrong Unicode JDBC setting, a case-sensitive collation or an unsuitable compatibility level can slow large ID searches, and reversing them after data loads takes planned effort. An internal team should record each decision, test it on a copy of representative data and complete a restore test. A partner can take on the fixed-scope build inside your infrastructure, with documentation of the configuration handed over as part of the agreed deliverables.
How does the 8.8 migration change the SQL Server plan?
The 8.8 migration affects deployments that depend on case-sensitive IDs, so the first step is to find out whether your data or client applications rely on IDs that differ only in letter case. Read the 8.8 release notes in the HAPI FHIR releases list and confirm how the change interacts with your SQL Server collation. Check whether your target is the latest release, which is 8.8.2 and was released on 25 September 2026, or an earlier 8.8 build. Then rehearse the upgrade on a restored copy of production, time the schema migration and document a rollback path backed by a verified backup. Add this work to the schedule and the quote from the start, because it changes the testing effort.
Does the JPA server starter support SQL Server for production?
Yes. The starter defaults to an embedded H2 database, supports PostgreSQL and Microsoft SQL Server for production, and does not support MySQL. H2 is intended for development only, so plan the move to SQL Server before any shared environment is built. Confirm the exact starter version you deploy and its documented SQL Server configuration, because the Unicode JDBC setting, collation and compatibility level all affect index use on large ID searches. Check the hapi-fhir-jpaserver-starter repository for the current database configuration before you write the deployment. Include a restore test and a representative data load in the acceptance tests so the configuration is checked under load, not only at startup.
How the starter, JDBC driver and SQL Server fit together
Requests start at the reverse proxy, which forwards them to the HAPI FHIR JPA server starter. The starter reaches SQL Server or Azure SQL through the JDBC driver, and the connection URL carries the Unicode and collation-sensitive settings that decide whether indexes are used. The migrator and the backup job run as separate paths against the same database, so check that each one uses the same connection settings as the running server.
Request path from client to SQL Server, with the migrator and backup paths beside it.
How DeployOpen works on this
DeployOpen plans, implements, hardens, documents and supports self-hosted open-source platforms inside your own cloud accounts, data centers or air-gapped networks. For HAPI FHIR on Microsoft SQL Server and Azure SQL, that means the database settings, schema setup and compatibility choices are agreed in writing before the server goes into production.
How we scope
- Written scope confirms whether the target is on-premises SQL Server or Azure SQL and which HAPI FHIR version is in use.
- Scope records the JDBC connection settings, collation decision and compatibility level for each database the server uses.
- Engagements are fixed-scope, with deliverables and timelines agreed in writing before work starts.
How we build
- Build covers the JPA server starter configured for SQL Server, with the Unicode JDBC setting and collation checked against your search requirements.
- Large ID search behavior is tested at the compatibility level chosen in scope, with query plans reviewed before sign-off.
- Case-sensitive ID handling is tested against the 8.8 migration path, using data sets that match your real identifiers.
How we hand over
- Handover includes a written record of database settings, schema decisions, collation choices and the reasons behind each one.
- Runbooks cover backups, restore tests, storage growth monitoring and the steps to follow during HAPI FHIR upgrades.
- Documentation is written so your database administrators and security team can review the configuration without DeployOpen present.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer after handover.
- Retained support can cover HAPI FHIR version upgrades, including checks on collation and case-sensitive ID behavior.
- Confirm response expectations, change control and escalation terms in the written retainer scope before the engagement starts.

