3

I am using a docker compose file to set the appsettings.json array section with enviornment variables as below:

AppSettings.json section

---
"PluginManager": {      
      "Plugins": [
        {
          "Service": "TestPlugin",          
          "NugetRepository": {
            "Url": "",
            "NugetKey": "",
            "NugetValue": ""
          },
          "Package": {
            "Name": "SamplePackage",
            "Version": "1.0.0"
          }
        }        
      ]
    },
---

Docker compose file:

- PluginManager__Plugins__0__ServiceId=TestService_1
- PluginManager__Plugins__0__SubServiceId=
- PluginManager__Plugins__0__NugetRepository_Url=https://nugetUrl
- PluginManager__Plugins__0__NugetRepository_Username=username
- PluginManager__Plugins__0__NugetRepository_Password=Password
- PluginManager__Plugins__0__Package_Name=TestPackage
- PluginManager__Plugins__0__Package_Version=1.0.0

- PluginManager__Plugins__1__ServiceId=TestService_2
- PluginManager__Plugins__1__SubServiceId=
- PluginManager__Plugins__1__NugetRepository_Url=https://nugetUrl
- PluginManager__Plugins__1__NugetRepository_Username=username
- PluginManager__Plugins__1__NugetRepository_Password=Password
- PluginManager__Plugins__1__Package_Name=TestPackage
- PluginManager__Plugins__1__Package_Version=1.0.3

I wanted to pass one or more these array blocks dynamically. Currently I am unable to pass these dynamic environment values. These are getting ignored. Is there a way to achieve this without changing my appsettings.json structure?

3
  • Seems like you are on the right path, might be a typo or something. Could you provide the full docker-compose? Commented Aug 20, 2021 at 7:22
  • Looks like after NugetRepository part you still need two underscores, not one. The same with other lines. Can this be the issue? Commented Aug 22, 2021 at 6:27
  • @AndrewSilver As you suggested there was an issue with the underscores. This is solved.. Thanks for the help! Commented Oct 1, 2021 at 8:14

1 Answer 1

4

Problem was with the _(Single Underscore) charecters. Updated config follows:

  • PluginManager__Plugins__0__ServiceId=TestService_1

  • PluginManager__Plugins__0__SubServiceId=

  • PluginManager__Plugins__0__NugetRepository__Url=https://nugetUrl

  • PluginManager__Plugins__0__NugetRepository__Username=username

  • PluginManager__Plugins__0__NugetRepository__Password=Password

  • PluginManager__Plugins__0__Package__Name=TestPackage

  • PluginManager__Plugins__0__Package__Version=1.0.0

  • PluginManager__Plugins__1__ServiceId=TestService_2

  • PluginManager__Plugins__1__SubServiceId=

  • PluginManager__Plugins__1__NugetRepository__Url=https://nugetUrl

  • PluginManager__Plugins__1__NugetRepository__Username=username

  • PluginManager__Plugins__1__NugetRepository__Password=Password

  • PluginManager__Plugins__1__Package__Name=TestPackage

  • PluginManager__Plugins__1__Package__Version=1.0.3

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

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.