locked
Cannot create any tables in Azure Storage RRS feed

  • Question

  • I have no idea what I'm doing wrong. I'm using .dll version 2.0.1.0 of the Microsoft.WindowsAzure.Storage and 1.7.0.0 of Microsoft.WindowsAzure.Configuration.

    This is the code I'm running

    // Retrieve the storage account from the connection string.
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                    ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString);
    
                // Create the table client.
                CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
    
                // Create the table if it doesn't exist.
                CloudTable table = tableClient.GetTableReference("feedbackAnswers");
                bool a = table.CreateIfNotExists();
    
                // Create a new answer entity.
                FeedbackAnswer answer = new FeedbackAnswer(Request.QueryString["Email"].ToString());
                
                // Create the TableOperation that inserts the customer entity.
                TableOperation insertOperation = TableOperation.Insert(answer);
    
                // Execute the insert operation.
                table.Execute(insertOperation);

    I've configured a variable called a to save the data returned by .CreateIfNotExists() and it returns 'false' every single time.

    I've also tripled checked the web.config, but it seems that I am missing something here.

    Alex

    Thursday, November 29, 2012 12:55 AM

Answers

  • I used the storage account credentials from above and looked up the tables in your storage account. I found that the table you're trying to create already exists in your storage account. As I mentioned in my 1st response, "CreateIfNotExists()" will only return true if it was able to create a table. If a table by the same name is already present in the storage account, this function is will return false instead of throwing "409 Conflict" exception.

    Also, please regenerate your storage account key as soon as possible as anybody who has access to this post can access your storage account. In general, please refrain from posting storage account credentials in public forums to avoid misuse.

    Hope this helps.

    • Proposed as answer by Nabarun Sengupta Thursday, November 29, 2012 8:19 AM
    • Marked as answer by Mang AlexMVP Thursday, November 29, 2012 12:45 PM
    Thursday, November 29, 2012 8:00 AM

All replies

  • Moreover, if I simply call .Create(), I get this as an StorageException:

    The remote server returned an error: (409) Conflict.

    Thursday, November 29, 2012 12:59 AM
  • Please note that "CreateIfNotExists()" will only return true if it was able to create a table. If a table by the same name is already present in the storage account, this function is will return false instead of throwing "409 Conflict" exception.

    Hope this helps.

    Thursday, November 29, 2012 3:14 AM
  • Can you post the content of web.config file ?
    Thursday, November 29, 2012 5:32 AM
  • <configuration>
      <connectionStrings>
        <add name="StorageConnectionString" connectionString="DefaultEndpointsProtocol=https;AccountName=dsadsadsadsa;AccountKey=sdadsadsadsa>
      </connectionStrings>
      <system.web>
        <compilation debug="true"/>
      </system.web>
    </configuration>


    • Edited by Mang AlexMVP Thursday, November 29, 2012 7:50 AM security
    Thursday, November 29, 2012 7:50 AM
  • I used the storage account credentials from above and looked up the tables in your storage account. I found that the table you're trying to create already exists in your storage account. As I mentioned in my 1st response, "CreateIfNotExists()" will only return true if it was able to create a table. If a table by the same name is already present in the storage account, this function is will return false instead of throwing "409 Conflict" exception.

    Also, please regenerate your storage account key as soon as possible as anybody who has access to this post can access your storage account. In general, please refrain from posting storage account credentials in public forums to avoid misuse.

    Hope this helps.

    • Proposed as answer by Nabarun Sengupta Thursday, November 29, 2012 8:19 AM
    • Marked as answer by Mang AlexMVP Thursday, November 29, 2012 12:45 PM
    Thursday, November 29, 2012 8:00 AM
  • Thank you! I am currently using Windows Azure Storage Explorer from Neudesic, available on Codeplex and it doesn't show any tables. I'll try another version or tool --> it's probably that why I got so confused about this in the first place.

    Thanks!

    Thursday, November 29, 2012 8:04 AM
  • You can try Cloud Storage Studio (a tool my company built) [http://www.cerebrata.com/Products/CloudStorageStudio] or ClumsyLeaf's TableXplorer [http://www.clumsyleaf.com] to view the contents of table storage. Here's what I see in Cloud Storage Studio:

    Hope this helps.

    Thursday, November 29, 2012 8:08 AM