azure keyvault - How to store an object data as secret value -


i need store 2 strings 1 secret value in key vault. account="aa" key="1254"

but setsecretasync syntaxes accept 1 string secret value..

i not sure if tags can revelevant here.

please help!

you use newtonsoft json.net serialize object json string:

var account = new account { account = "aa", key = "1254" };  string json = jsonconvert.serializeobject(account); 

this string contain this:

{"account":"aa","key":"1254"} 

which can stored secret.

when subsequently load secret, use json.net deserialize string object:

var account = jsonconvert.deserializeobject<account>(json); 

as tags, use tag indicate what's contained within secret, , useful if you'll storing different object types within secrets (not accounts, instance). tags key-value pairs, create tag so:

secret.tags = new dictionary<string, string>(); secret.tags["type"] = "account"; 

but if you're going storing accounts, isn't strictly necessary.


Comments