Я получаю исключение DataServiceRequestException
, когда я пытаюсь сохранить объект в лазурной таблице. Это происходит в этой строке _myContext.SaveChangesWithRetries();
Я пытался Google, чтобы узнать, в чем проблема. Но не смог найти ответа на него.Не удается сохранить таблицу Azure
Кто-нибудь может решить проблему?
хранения создатель
public CloudTableClient GetMusicClient() {
//retrieve connection string from 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 this request.
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
at 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; }
}
Можете ли вы поделиться кодом для музыки? Есть ли ключ раздела и ключ строки? Какие другие области? – smarx
В общем, это помогает использовать Fiddler для отладки таких вещей. Вы можете получить более точную информацию о точной ошибке. – smarx
@smarx Да, у меня есть ключ раздела и ключ строки. Я добавил код для музыки на мой вопрос сейчас. Что такое Fiddler, он включен в VS2010? – starcorn