Offline Access Console Application

Here’s a small console application that illustrates how to do offline access. It presumes that the user has already done authorization through the Offline sample application in the SDK, and that you have saved away the user id and record id of the user.


using System;

using System.Collections.Generic;

using System.Text;

using Microsoft.Health;

using Microsoft.Health.Web;

using Microsoft.Health.ItemTypes;

namespace ConsoleApplication1


class Program

static Guid personId = new Guid("<saved person guid from online app>");

static Guid recordId = new Guid("<saved record guide from online app>");

static void Main(string[] args)


// Do the offline connection

OfflineWebApplicationConnection offlineConn =

new OfflineWebApplicationConnection(personId);


HealthRecordAccessor accessor =

new HealthRecordAccessor(offlineConn, recordId);

HealthRecordSearcher searcher = accessor.CreateSearcher();

HealthRecordFilter filter = new HealthRecordFilter(Height.TypeId);


HealthRecordItemCollection items = searcher.GetMatchingItems()[0];

foreach (Height height in items)


string k = height.ToString();

int l = 12;