0

I have created my first ASP Core MVC 3.1 app and published it in Azure. This works fine but I noticed that my settings.json file is visible in the root exposing my db connection string and Azure AD info.

I have been successful in 'hiding' the db connection string by adding a new connection string called Database in App Service>Settings>configuration. I named it the same as the entry in my settings.json file and it magically works. I have now removed this from the settings.json file.

In Startup I use

 var connection = Configuration.GetConnectionString("Database");
        services.AddDbContext<BookStoreContext>(options => options.UseSqlServer(connection));

The Azure login info is in an Array so I am not sure how I add this to the App Service Settings:

"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"Domain": "xxxx.onmicrosoft.com",
"TenantId": "xxxxxx-a2dd-4fde-bf8f-f75ab18b21ac",
"ClientId": "xxxxxxxxx-a9bb-4722-b615-6dcbdc646326",
"ClientSecret":xxxxxxxxxxxxxxxxxxxxxxxxxx",
"CallbackPath": "/signin-oidc"

},

In Startup I use:

services.AddAuthentication(AzureADDefaults.AuthenticationScheme)
    .AddAzureAD(options => Configuration.Bind("AzureAd", options));

Any help will be much appeciated.

Thanks,

1
  • Do yiu have any update? Commented Dec 5, 2020 at 6:26

2 Answers 2

1

According to my test, if you want to store array settings in Azure App Service configuration. You have two choices.

With Azure APP service window, you can store it like {"AzureAd:Domain" :""}

enter image description here

enter image description here

With App Service on Linux or Web App for Containers, you can store it like {"AzureAd_Domain" :""}

enter image description here enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

The Azure login info is in an Array so I am not sure how I add this to the App Service Settings

You can try to add these setting data with nested JSON key structure as below in Application settings.

enter image description here

For more information about setting configuration keys and values, please check these Docs:

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.