asp.net mvc 4 - Cannot save to Azure table -
i dataservicerequestexception exception when try save entity azure table. happens @ line _mycontext.savechangeswithretries(); i've tried google see problem be. not find answer it.
anyone kow problem be?
storage creator
public cloudtableclient getmusicclient() { //retrieve connection string settings cloudstorageaccount storageaccount = cloudstorageaccount.parse( roleenvironment.getconfigurationsettingvalue("storageconnectionstring")); //create table client cloudtableclient tableclient = storageaccount.createcloudtableclient(); //create table if doesn't exist string tablename = "music"; tableclient.createtableifnotexist(tablename); return tableclient; } webapi
public music postmusic(string genre, string artist, string random) { cloudtableclient _mytableclient = _mytablerepo.getmusicclient(); tableservicecontext _mycontext = _mytableclient.getdataservicecontext(); music music = new music(genre, artist); music.score = "10"; music.year = "2012"; music.random = random; try { _mycontext.addobject(random, music); _mycontext.savechangeswithretries(); } catch (storageclientexception e) { } catch (dataservicerequestexception e) { system.diagnostics.debug.writeline(e.stacktrace); } return music; } stacktrace
an error occurred while processing request. @ microsoft.windowsazure.storageclient.tasks.task`1.get_result() @ microsoft.windowsazure.storageclient.tasks.task`1.executeandwait() @ mywebapi.controllers.valuescontroller.postmusic(string genre, string artist, string random) in c:\mywebapi\mywebapi\controllers\valuescontroller.cs:line 61 music.cs
public class music : tableserviceentity { public music(string genre, string artist) { this.partitionkey = genre; this.rowkey = artist; } public music() {} public string score { get; set; } public string year { get; set; } public string random { get; set; } }
oh, looks first argument addobject wrong? should "music," name of table, if parameter name believed, looks you're passing in random string.
Comments
Post a Comment