I'm using WindowsAzure.Storage nuget package version 9.0.0.
Install-Package WindowsAzure.Storage -Version 9.0.0
The following code (table.CreateIfNotExistsAsync()
) throws the error: The remote server returned an error: (409) Conflict.
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference(tableName);
try
{
if (await table.CreateIfNotExistsAsync())
{
log.Info(string.Format("Created Table named: {0}", tableName));
}
}
catch (StorageException)
{
log.Error("If you are running with the default configuration please make sure you have started the storage emulator. Press the Windows key and type Azure Storage to select and run it from the list of applications - then restart the sample.");
throw;
}
return table;
If I check the StorageException details, I find this message: The table specified already exists.
Stack Trace:
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.EndExecuteAsync[T](IAsyncResult result) in c:\Program Files (x86)\Jenkins\workspace\release_dotnet_master\Lib\ClassLibraryCommon\Core\Executor\Executor.cs:line 57
This code works fine:
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference(tableName);
try
{
//if (await table.CreateIfNotExistsAsync())
//{
// log.Info(string.Format("Created Table named: {0}", tableName));
//}
if (!table.Exists())
{
await table.CreateAsync();
log.Info(string.Format("Created Table named: {0}", tableName));
}
}
catch (StorageException)
{
log.Error("If you are running with the default configuration please make sure you have started the storage emulator. Press the Windows key and type Azure Storage to select and run it from the list of applications - then restart the sample.");
throw;
}
return table;
I know I have tables that already exists and they are NOT currently being deleted. Why am I getting this error? Since the table does exist, I would expect this to perform and existence check and just return true, not throw a storage exception.
Edit: This is how I'm creating the CloudStorageAccount
public static CloudStorageAccount CreateStorageAccountFromConnectionString(string storageConnectionString)
{
CloudStorageAccount storageAccount;
try
{
storageAccount = CloudStorageAccount.Parse(storageConnectionString);
}
catch (FormatException fe)
{
log.Error("Invalid storage account information provided. Please confirm the AccountName and AccountKey are valid in the app.config file - then restart the application.", fe);
throw;
}
catch (ArgumentException ae)
{
log.Error("Invalid storage account information provided. Please confirm the AccountName and AccountKey are valid in the app.config file - then restart the sample.", ae);
throw;
}
return storageAccount;
}
Storage connection string looks like this:
<add key="StorageConnectionString" value="DefaultEndpointsProtocol=https;AccountName=something;AccountKey=somekeygoeshere==" />