Skip to content

Build and debug locally

Brendan Kowitz edited this page Dec 6, 2023 · 10 revisions

One-time steps

  1. Install your favorite editor (VS 2019, VS Code)
  2. Install the Cosmos DB Emulator: https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator
  3. Install the Azurite Storage Emulator: https://learn.microsoft.com/azure/storage/common/storage-use-azurite (also included with Visual Studio: https://learn.microsoft.com/azure/storage/common/storage-use-azurite?tabs=visual-studio#azurite-executable-file-location)
  4. Install SQL Server Developer: https://www.microsoft.com/en-us/sql-server/sql-server-downloads
  5. git clone https://github.com/Microsoft/fhir-server
  6. Install .Net core SDK version as listed in the global.json file (fhir-server/global.json, and backwards compat version fhir-server/build/dotnet6-compat/global.json) https://dotnet.microsoft.com/en-us/download/dotnet

Build

  • The solution should now build without errors

Running and debugging locally

  • Ensure the Cosmos DB Emulator and Storage Emulator are running
  • Open Microsoft.Health.Fhir.sln, set Microsoft.Health.Fhir.R4.Web (or Microsoft.Health.Fhir.Stu3.Web) as StartUp Project, and press F5
    • If you get a timeout error with respect to initializing the DocumentClient (which is used to talk to the Cosmos DB instance) make sure Cosmos DB emulator is running and you are able to access it normally. If it still does not work, create an actual Cosmos DB instance on Azure and update the Host and Key properties in appsettings.json file
  • Launch a web browser and navigate to https://localhost:44348. If the web page shows a HTTP 401 error, that is expected. As long as you are able to hit the metadata endpoint (https://localhost:44348/metadata?_format=json&_pretty=true) it means that the server is running.
  • (Optional) If you would like to debug locally without the need to fetch an auth token, you can disable the "FhirServer:Security:Enabled" setting in the "appSettings.json" file.
  • From here we recommend looking at the example FHIR HTTP Requests in the docs/rest folder such as the SearchExamples.

Ramping up

Our service is built on ASP .NET Core. In case you are not already familiar with the framework, the following resource(s) might be a good place to start.

Clone this wiki locally