I am trying to create a storage from c# in asp.net MVC application but it throws me error Account type StandardLRS is invalid as you can see below

Below is the code which I am using for creation
string token = GetAccessToken("sub id", "app name", "tenant id");
var Credentials = new TokenCredentials(token);
var resourceManagementClient = new ResourceManagementClient(Credentials);
resourceManagementClient.SubscriptionId = "sub id";
var storageProvider = resourceManagementClient.Providers.Register("Microsoft.Storage");
var storageManagementClient = new StorageManagementClient(Credentials);
storageManagementClient.SubscriptionId = "sub id";
string rgName = "TimedCloudRG" + location.Trim().Replace(" ", string.Empty);
var resourceGroup = new Microsoft.Azure.Management.Resources.Models.ResourceGroup
{
Location = location
};
var rgResult = resourceManagementClient.ResourceGroups.CreateOrUpdate(rgName, resourceGroup);
Microsoft.Azure.Management.Storage.Models.Sku DefaultSku = new Microsoft.Azure.Management.Storage.Models.Sku(Microsoft.Azure.Management.Storage.Models.SkuName.StandardLRS);
Microsoft.Azure.Management.Storage.Models.Kind DefaultKind = Microsoft.Azure.Management.Storage.Models.Kind.Storage;
Microsoft.Azure.Management.Storage.Models.StorageAccountCreateParameters parameters = new Microsoft.Azure.Management.Storage.Models.StorageAccountCreateParameters()
{
Kind = DefaultKind,
Sku = DefaultSku,
Location = rgResult.Location
};
string stAccName = "TCStorageAccount"+Guid.NewGuid().ToString().Substring(0, 8);
var storageAccount = await storageManagementClient.StorageAccounts.CreateAsync(rgName, stAccName, parameters);
Surprisingly it works fine when I run it on console application. I also try to install Microsoft.Azure.Management.Storage.Fluent package but unable to install as my project .net framework selected as 4.5.1 and this package not supported to that version.
Any help would be greatly appreciated. Thanks
According to your description, I leveraged Microsoft.Azure.Management.Storage 6.2.0-preview which supports
.NETFramework 4.5to check this issue. I specified theLocationasWest USand I could create my storage account.AFAIK, your account name is not a valid storage account name. Storage account name must be between 3 and 24 characters in length and use numbers and lower-case letters only.
I tried to create storage account on Azure Portal and accidentally found the following result:
As Locally redundant storage mentioned as follows:
Additionally, you could use Microsoft.Azure.Management.Storage.Fluent 1.0.0 which supports
.NETFramework 4.5.UPDATE:
I created a sample AspDotNet-MVC-CreateAzureStorageAccount and defined the
CreateAzureStorageAccountaction for creating storage account under HomeController.cs. Here is the test result, you could refer to it as follows: