Вот соответствующее содержание Appsettings.json: < /p>
Код: Выделить всё
{
"SecretName":"mysecrect", // key for secret in Azure Keyvault
"secret":"hush~hush~1234", // to be replaced
"AdminKey" : "admin-list", // key for admin list in Azure Keyvault
"Admins": ["a", "b"] // to be replaced
}
< /code>
код в программе. // For reference
var kvUri = $"https://abcd1234.vault.azure.net";
var client = new SecretClient(new Uri(kvUri), new DefaultAzureCredential());
var secretName = builder.Configuration["SecretName"];
var secret = client.GetSecret(secretName); // returns "hemlig~nemlig1234"
builder.Configuration.Bind("Secret", secret.Value.Value); // this Bind works fine. the old value is replaced
// Here comes the problem
var Admkey = builder.Configuration["AdminKey"]; // returns "admin-list"
var Adm = client.GetSecret(AdmKey); // returns "alice,bob"
var s = konAdm.Value.Value.Split(',');
var json = JsonConvert.SerializeObject(s); // creates ["alice","bob"]
builder.Configuration.Bind("Admins", json); // ["a", "b"] are NOT replaced with ["alice","bob"]
Подробнее здесь: https://stackoverflow.com/questions/797 ... ith-arrays
Мобильная версия