我正在使用庫
const string sasToken = "SAS Token";
StorageCredentials storageCredentials = new StorageCredentials(sasToken);
const string accountName = "teststorage65";//Account Name
const string blobContainerName = "test";
const string blobName = "test.txt";
const string myFileLocation = @"Local Path ";
var storageAccount = new CloudStorageAccount(storageCredentials, accountName, null, true);
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer blobContainer = blobClient.GetContainerReference(blobContainerName);
//blobContainer.CreateIfNotExists();
CloudBlockBlob cloudBlob = blobContainer.GetBlockBlobReference(blobName);
cloudBlob.UploadFromFile(myFileLocation);
如您所知,您可以使用Storage 連接字串與 Storage 連接。
CloudStorageAccount storageAccount = CloudStorageAccount.Parse("Connection string");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("test");
你的應用程式需要在運行時訪問連接字串以授權對 Azure 存盤的請求。
您有多種選項可以存盤連接字串或 SAS 令牌
1)您可以將連接字串存盤在環境變數中。
2)在桌面或設備上運行的應用程式可以將連接字串存盤在app.config或web.config檔案中。將連接字串添加到這些檔案中的AppSettings部分。
3)在 Azure 云服務中運行的應用程式可以將連接字串存盤在Azure 服務配置架構 (.cscfg) 檔案中。將連接字串添加到服務組態檔的 ConfigurationSettings 部分。
參考:https : //docs.microsoft.com/en-us/azure/storage/common/storage-configure-connection-string
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/367679.html
標籤:天蓝色 .net核心 azure-blob-storage 连接字符串 证书
