英文:
Add environment variables to AWS from appsettings.json C#
问题
在我的C# API项目的appsettings.json文件中,例如,我有以下变量:
"Recursos":{
"tipoRecurso":"plasticos",
"ValorRecurso":"2000",
"TieneExpedicion":"no"
},
"OtherProperty": "some value"
如何将该对象属性添加到AWS的环境中?我不知道这是否正确:
英文:
In the appsettings.json file of my API project in C#, I have this variable for example:
"Recursos":{
"tipoRecurso":"plasticos",
"ValorRecurso":"2000",
"TieneExpedicion":"no"
},
"OtherProperty": "some value"
How to add that object property in the environment of AWS? I don't know if this is correct:
答案1
得分: 1
You need to address every JSON field as a separate environment variable rather than addressing the object as a string of JSON.
Environment Variable | Field Value |
---|---|
Recursos__tipoRecurso | plasticos |
Recursos__ValorRecurso | 2000 |
Recursos__TieneExpedicion | no |
OtherProperty | some value |
Because :
can't typically be used as part of an environment variable's name, you have to use double underscore instead, __
, to get to the fields of a complex object.
Ankush's comment references this.
Minor note: If
Recursos__TieneExpedicion
is a boolean, and not a string, you might need to set the field value tofalse
.
英文:
You need to address every JSON field as a separate environment variable rather than addressing the object as a string of JSON.
Environment Variable | Field Value |
---|---|
Recursos__tipoRecurso | plasticos |
Recursos__ValorRecurso | 2000 |
Recursos__TieneExpedicion | no |
OtherProperty | some value |
Because :
can't typically be used as part of an evironment variable's name, you have to use double underscore instead, __
, to get to the fields of a complex object.
Ankush's comment references this.
> Minor note: If Reursos_TieneExpedicion
is a boolean, and not a string, you might need to set the field value to false
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论