English 中文(简体)
"One of the request inputs not valid" error when attempting to update Azure Table Storage
原标题:

I am attempting to update an entry in Azure Table Storage. The function is:

public void SaveBug(DaBug bug)
        {
            bug.PartitionKey = "bugs";
            bug.Timestamp = DateTime.UtcNow;

            if (bug.RowKey == null || bug.RowKey == string.Empty)
            {
                bug.RowKey = Guid.NewGuid().ToString();

                _context.AddObject(c_TableName, bug);
            }
            else
            {
                _context.AttachTo(c_TableName, bug);
                _context.UpdateObject(bug);
            }

            _context.SaveChanges();
        }

If it is a new entry (the "bug.RowKey == null" path), then it works fine. If it is an update to an existing entity, then the "AttachTo", and the "UpdateObject" calls work, but when it gets to "SaveChanges", it throws the "One of the request inputs not valid" exception.

The class that is being stored is:

[DataContract]
[DataServiceKey("RowKey")]
public class DaBug
{
    [DataMember]
    public bool IsOpen { get; set; }
    [DataMember]
    public string Title { get; set; }
    [DataMember]
    public string Description { get; set; }
    [DataMember]
    public string SubmittedBy { get; set; }
    [DataMember]
    public DateTime SubmittedDate { get; set; }
    [DataMember]
    public string RowKey { get; set; }

    public DateTime Timestamp { get; set; }
    public string PartitionKey { get; set; }
}

Does anyone know what the problem is?

Thanks for any help.

最佳回答

In case anyone is looking for the answer:

http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/0c9d476e-7970-422a-8b34-e987e41734df


Working through the table context, I had to change the call from:

_context.AttachTo(c_TableName, bug); 

to:

_context.AttachTo(c_TableName, bug, "*"); 
问题回答

You can also get this error if you mistakenly set the RowKey to a value you ve already used (not that you d get this problem with code in the question). I tried to push 50+ entities in one go and accidentally had the RowKey set to the same value for two of the entities.





相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...

热门标签