I'm inserting a new xml file created with in the code into our file share folder in Azure. I have Secure transfer required set to enabled but still getting "Microsoft.Azure.Storage.StorageException: The account being accessed does not support http". I'm not sure where to look. Here is my code.
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");
If you review the constructor, the second parameter specifies to use https:
public CloudStorageAccount (
Microsoft.Azure.Storage.Auth.StorageCredentials storageCredentials,
bool useHttps);
Change this code:
var storageAccount =
new CloudStorageAccount(
new StorageCredentials(storageAccountName, storageAccountKey), false);
To:
var storageAccount =
new CloudStorageAccount(
new StorageCredentials(storageAccountName, storageAccountKey), useHttps: true);