Connect to Azure from C# With launchsettings.json

This post will show how to connect to Azure from a .NET C# application using a LunchSettings.Json file.

launchsettings.json

The launchsettings.json file is a configuration file used in .NET development. It stores environment variables and profiles and is used mainly during development. It is supported only by the Visual Studio IDE.

Configuration

To use the file, create a folder called Properties in the root of your project in Visual Studio, as shown below.

Under the Properties, create a file called launchsettings.json

To connect to Azure, create a service principal account and give it permissions to the subscription or a resource group.

File Content

Below is the file content; replace the values and run your application.

{
    "profiles": {
        "SampleProject": {
            "commandName": "Project",
            "dotnetRunMessages": true,
            "launchBrowser": true,
            "applicationUrl": "https://localhost:7177;http://localhost:5177",
            "environmentVariables": {
                "ASPNETCORE_ENVIRONMENT": "Development",
                "AZURE_CLIENT_ID": "ADD VALUE",
                "AZURE_TENANT_ID": "ADD VALUE",
                "AZURE_CLIENT_SECRET": "ADD VALUE"
            }
        }
    }
}


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.