简体   繁体   中英

How to get Azure Storage Account Key (connectionString) using azure .net sdk or fluent API?

I want get Azure Storage Account Key (connectionString) using azure .NET SDK or fluent API.

在此处输入图像描述

Try this:

    var azure = Azure.Configure().Authenticate(credentials).WithSubscription(subscriptionID);

    var storageName = "<storage name>";
    var resourceGroup = "<storage resource group>";

    var keys = azure.StorageAccounts.GetByResourceGroup(resourceGroup, storageName).GetKeys();
    
    var key1 = keys[0];
    var key2 = keys[1];

    var connStr1 = "DefaultEndpointsProtocol=https;AccountName=" + storageName + ";AccountKey="+ key1.Value + ";EndpointSuffix=core.windows.net";
    var connStr2 = "DefaultEndpointsProtocol=https;AccountName=" + storageName + ";AccountKey=" + key2.Value + ";EndpointSuffix=core.windows.net";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM