Johnny D Smithy
Johnny D Smithy

Reputation: 23

Receiving 409 Error when uploading data to Windows Azure

I am trying to upload some data to my Windows Azure storage account, and running into an exception when executing the code. The exception is as follows:

An exception of type 'Microsoft.WindowsAzure.Storage.StorageException' occurred in Microsoft.WindowsAzure.Storage.dll but was not handled in user code. Additional information: The remote server returned an error: (409) Conflict.

And here is my code, Visual Studio keeps telling me it breaks in different places each time I try.

// Retrieve storage account from the connection string.
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("StorageConnectionString"));
        // Create the table client.
        CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
        // Create the table if it doesn't exist.
        CloudTable table = tableClient.GetTableReference("articles");
        table.CreateIfNotExists();
        // Create a new article entity.
        Article neumeier = new Article("Israel will strike Iran in the next 5 years", "NeumeierJ.R");
        neumeier.User = "NeumeierJ.R";
        neumeier.Tagline = "Israel will strike Iran in the next 5 years";
        neumeier.UserCredentials = "Founder of Codex.Library";
        neumeier.UserEmail = "[email protected]";
        neumeier.Author = "Chomsky";
        neumeier.AuthorCredentials = "Everyone knows Chomsky...";
        neumeier.Category = "LD2015";
        neumeier.Citation = "CNN or something like that.";
        neumeier.Content = "It is inevitable that Israel will attack Iran, or vice versa. In the hotbed of conflict in the MidEast.";
        // Create the TableOperation that inserts the article entity.
        TableOperation insertOperation = TableOperation.Insert(neumeier);
        // Execute the insert operation.
        table.Execute(insertOperation);
        // End Azure Test

And I should be using all the correct References and using statements...

using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
using Microsoft.WindowsAzure.Storage.Auth;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Security.Claims;
using System.Web.Http;
using System.Configuration;

Apologies for the shoddy formatting, first question. Any help would be great, thanks!

Upvotes: 2

Views: 2161

Answers (1)

Kiran Bhagat
Kiran Bhagat

Reputation: 73

The Partition Key + the Row Key together act as a primary key for that entry into the table, this combination must be unique. You can have a virtually unlimited number of rowkeys within a single partition, as long as you don't violate the PK+RK=unique constraint. But i seen you didnt specify the partition key and row key.

Upvotes: 2

Related Questions