【问题标题】:Receiving 409 Error when uploading data to Windows Azure将数据上传到 Windows Azure 时收到 409 错误
【发布时间】:2015-09-28 18:40:10
【问题描述】:

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

Microsoft.WindowsAzure.Storage.dll 中出现“Microsoft.WindowsAzure.Storage.StorageException”类型的异常,但未在用户代码中处理。附加信息:远程服务器返回错误:(409) Conflict。

这是我的代码,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;

对于粗制滥造的格式,第一个问题表示歉意。任何帮助都会很棒,谢谢!

【问题讨论】:

  • Conflict 错误表示您尝试创建的实体已存在于该表中。请检查。

标签: c# .net linq azure


【解决方案1】:

Partition Key + Row Key 一起作为该表项的主键,这个组合必须是唯一的。只要不违反 PK+RK=unique 约束,您可以在单个分区中拥有几乎无限数量的行键。但是我看到你没有指定分区键和行键。

【讨论】:

    猜你喜欢
    • 2018-03-15
    • 2018-07-06
    • 1970-01-01
    • 2014-08-24
    • 1970-01-01
    • 2013-03-27
    • 2021-11-08
    • 2021-04-03
    • 2014-02-17
    相关资源
    最近更新 更多