将数据上载到Windows Azure时收到409错误

时间:2015-07-10 06:06:33

标签: c# .net linq azure

我正在尝试将一些数据上传到我的Windows Azure存储帐户,并在执行代码时遇到异常。例外情况如下:

  

类型' Microsoft.WindowsAzure.Storage.StorageException'的例外情况发生在Microsoft.WindowsAzure.Storage.dll但未在用户代码中处理。附加信息:远程服务器返回错误:(409)冲突。

这是我的代码,Visual Studio一直告诉我每次尝试都会在不同的地方打破。

// 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 = "NeumeierJ.R@outlook.com";
        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

我应该使用所有正确的参考资料并使用陈述......

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;

为劣质格式表示道歉,第一个问题。任何帮助都会很棒,谢谢!

1 个答案:

答案 0 :(得分:2)

分区键+行键一起充当表中该条目的主键,此组合必须是唯一的。只要您不违反PK + RK =唯一约束,您就可以在一个分区中拥有几乎无限数量的rowkey。但我发现你没有指定分区键和行键。