Question: My appsettings.json looks something like following: `{ "Server": "ABC", "DefaultDatabase": "XYZ", "delayTimer" : 10,}`

I have another class scheduler.cs(Data layer) in which I am reading "delayTimer" from Appsettings in the constructor as follows:

```
    public class Scheduler
    {    
       public Scheduler(IConfiguration configSrc)
       {           
          this.delayTime = configSrc.GetValue<int>("delayTimer");
          CallScheduler();
       }
    }

```

Now, I need to call this class from "Startup.cs" when the application is loading, but how do I create an instance of it? I am aware that as the Scheduler class is having constructor dependency then I may need to pass object of a class which implements "IConfiguration" interface. In Startup.cs, I am trying following:

```
    public void ConfigureServices(IServiceCollection services)
    {            
        services.AddControllers();

        services.AddSingleton(typeof(Config));
        services.AddSingleton(typeof(TokenHelper));

        // The next line gives an error: I need to pass a class object
        // implementing IConfiguration interface but when I try to
        // create a new class which implements IConfiguration it result
        // in errors.
        Scheduler obj = new Scheduler();
        services.AddSingleton<Scheduler>(obj);

        Thread t1 = new Thread(new ThreadStart(obj.CallScheduler));
        t1.Start();

```

My question: How do I read the appsettings.json value of "delayTimer" in data layer class??. I read lot of posts which speaks about reading the content from asppsetting to controller class. Example: [Read asppsetting.json to controller](https://stackoverflow.com/questions/31453495/how-to-read-appsettings-values-from-a-json-file-in-asp-net-core) but I am not looking for this requirement.

Answer: 
I think I found something interesting for you.

Go to

```
C:\Users\user\AppData\Roaming\Microsoft\Teams 

```

you'll find a file called **logs.txt**

In this file you see if your current state changed

```
(current state: Available -> DoNotDisturb)

```

I would write a script with php or VB (depends on your skills) that read that logs.txt file like every minute and check for the last "current state" line.
What those posts are doing (certainly the first one, I didn't check the 2nd one) is calling the Microsoft Graph, which has a "presence" endpoint to get a user's status. There's actually even a specific "/me" endpoint, to get your own personal preference (less access rights needed). See more about this here: <https://learn.microsoft.com/en-us/graph/api/presence-get?view=graph-rest-1.0&tabs=http>

In order for this to work, as you've mentioned, you do need to have an Azure AD App registration. However, importantly, this will only require "delegated" permission (i.e. only permission from the single user, you, to access just data for that single user, you). As a result, you can use "delegated" and not "Application" permissions, which means that it does -not- require Admin consent for the tenant.

It -does- require and Azure Add Application though, at the risk of stating the obvious. While you don't have tenant admin rights, you need to see if you have Azure rights, just to create an application (you might have this anyway as a developer in your org). If you don't even have this, you can sign up for an M365 Developer account, and use that tenant. Importantly - the application does't *have* to be in the same tenant. If it's not, it's just a simple multi-tenant app, like any 3rd party Azure AD-backed application is.