我將在代碼中創建的新 xml 檔案插入到 Azure 中的檔案共享檔案夾中。我已將需要安全傳輸設定為啟用,但仍然收到“Microsoft.Azure.Storage.StorageException:正在訪問的帳戶不支持 http”。我不知道在哪里看。這是我的代碼。
const string storageAccountName = "TestAccount";
const string storageAccountKey = "AccountKey";
var storageAccount =
new CloudStorageAccount(
new StorageCredentials(storageAccountName, storageAccountKey), false);
//See if FileShare folder is there
var share = storageAccount.CreateCloudFileClient().GetShareReference("MainFolder");
share.CreateIfNotExists();
//Get a reference to the root of the FileShare folder
var rootDirectory = share.GetRootDirectoryReference();
//Get a reference to the next level folder
var folder1 = rootDirectory.GetDirectoryReference("Folder1");
folder1.CreateIfNotExists();
//Get a reference to the next level folder
var pendingFolder = rootDirectory.GetDirectoryReference("Pending");
pendingFolder.CreateIfNotExists();
pendingFolder.GetFileReference("tested.txt").UploadText("Testing CreateCloudFileClient");
uj5u.com熱心網友回復:
如果您查看建構式,則第二個引數指定使用 https:
public CloudStorageAccount (
Microsoft.Azure.Storage.Auth.StorageCredentials storageCredentials,
bool useHttps);
更改此代碼:
var storageAccount =
new CloudStorageAccount(
new StorageCredentials(storageAccountName, storageAccountKey), false);
到:
var storageAccount =
new CloudStorageAccount(
new StorageCredentials(storageAccountName, storageAccountKey), useHttps: true);
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/408494.html
標籤:
上一篇:ARM模板-有條件地添加到陣列
