我试图将一些数据上传到Windows Azure存储帐户,并在执行代码时遇到异常。异常如下:


  Microsoft.WindowsAzure.Storage.dll中发生了类型为“ Microsoft.WindowsAzure.Storage.StorageException”的异常,但未在用户代码中处理。附加信息:远程服务器返回错误:(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;


不好意思的格式,第一个问题。任何帮助将是巨大的,谢谢!

最佳答案

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

10-07 13:12
查看更多