asp.net - C# - Using Azure Key Vault with Azure Storage on Native App -


i'm using following code upload image container in azure storange account. connection string in app.config is:

<appsettings>     <add key="storageconnectionstring" value="myconnectionstring" /> </appsettings> 

cloudstorageaccount storageaccount = cloudstorageaccount.parse cloudconfigurationmanager.getsetting("storageconnectionstring")); cloudblobclient blobclient = storageaccount.createcloudblobclient(); // retrieve reference created container. cloudblobcontainer container = blobclient.getcontainerreference("imagestorage"); // retrieve reference blob named "myblob". cloudblockblob blockblob = container.getblockblobreference("img1.png");             // create or overwrite "myblob" blob contents local file. using (var filestream = system.io.file.openread(@"d:\untitled.png")) {    blockblob.uploadfromstream(filestream); } 

question how intergrate azure key vault native application api keys not compromised annoying reverse engineers?

i've registered app in azure active directory , given permissions azure key vault.

also, ever tries use native desktop app has log in asp.net web api app individual accounts , receive token, before using other features. of controllers require authorization.

i believe you're trying integrate azure keyvault c# application. can using 2 api. 1 being microsoft.azure.keyvault , other being adal.

following these steps may answer:

public async task<string> gettoken(string authority, string resource, string scope) {  var authcontext = new authenticationcontext(authority);         clientcredential clientcred = new clientcredential(configurationmanager.appsettings["clientid"], configurationmanager.appsettings["clientsecret"]);         authenticationresult result = await authcontext.acquiretokenasync(resource, clientcred);         if(result == null)         {             throw new invalidoperationexception("failed obtain jwt token");          }         console.writeline("retrieved password");         return result.accesstoken; } 

and value of you're trying return running this:

public async task getvaluesasync() { var kv = new keyvaultclient(new keyvaultclient.authenticationcallback(gettoken));         var sec = await kv.getsecretasync(configurationmanager.appsettings["secreturi"]);         encryptsecret = sec.value; } 

replace appropriate values of clientid, client secret , secreturi values in app.config file. use getter , setter method "ecryptsecret" doing like,

public static string encryptsecret { get; set; } 

this continuously store password / db connections further use.

a few helpful articles be: https://docs.microsoft.com/en-us/azure/key-vault/key-vault-developers-guide


Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -