【发布时间】: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错误表示您尝试创建的实体已存在于该表中。请检查。