Choosing between IConfiguration and IOptionsSnapshot in a .Net Core application

If you are building a .Net Core api and are using appsettings and/or Azure App configuration, you might have this question in mind. Since, this is the AI era, I keep asking my queries to chatgpt or copilot or bard and use my blog as the notes for myself and for my readers: Here is the prompt: What is the difference between IConfiguration and IOptionsSnapshot. When I am using Azure App Configuration in a .net core api what should I use out of the two? Let’s delve into the differences between  IConfiguration  and  IOptionsSnapshot , especially in the context of using Azure App Configuration in a .NET Core API. IConfiguration: Purpose :  IConfiguration  provides access to configuration settings (such as app settings, connection strings, etc.) from various sources (e.g., JSON files, environment variables, command-line arguments). Lifetime : It is a singleton service, meaning it retrieves configuration values once during application startup and caches them. Use Case : Suitable when you don’

How to minify JSON in powershell?

 Recently, I had a requirement to minify json using powershell and I learnt that it is pretty simple and thought of adding it to my blog as well so that it can serve as future notes for me as well.

Here is my sample JSON

    "name": "gaurav",
    "age": "32",
    "id": 1
    "name": "sunny",
    "age": "35",
    "id": 2

Here is the powershell script:
$report = Get-Content './report.json' | Out-String
$minifiedJSON = (ConvertFrom-Json $report) | ConvertTo-Json -Compress;
Write-Host $minifiedJSON;
$minifiedJSON | Out-File -FilePath '.\minified.json'
Here is the output: