0
问题
如何解决,我已经在微软的Azure门户创建了一个简单的表此错误消息?当我打电话MobileServiceClient.SyncContext.PushAsync
出现此错误:Azure的简易表:请求实体太大
OperationKind: Insert
Error Result: {
"error": "request entity too large"
}
的NuGet软件包
我使用下面的NuGet包:
- Microsoft.Azure.Mobile.Client V3.1.0
- 微软。 Azure.Mobile.Client.SQLiteStore v3.1.0
代码
static bool _isInitialized;
static MobileServiceClient _mobileService;
public static async Task<IEnumerable<T>> GetItemsAsync<T>() where T : EntityData
{
await Initialize<T>();
await SyncItemsAsync<T>();
return await _mobileService.GetSyncTable<T>().ToEnumerableAsync();
}
public static async Task<T> GetItem<T>(string id) where T : EntityData
{
await Initialize<T>();
await SyncItemsAsync<T>();
return await _mobileService.GetSyncTable<T>().LookupAsync(id);
}
public static async Task AddItemAsync<T>(T item) where T : EntityData
{
await Initialize<T>();
await _mobileService.GetSyncTable<T>().InsertAsync(item);
await SyncItemsAsync<T>();
}
public static async Task UpdateItemAsync<T>(T item) where T : EntityData
{
await Initialize<T>();
await _mobileService.GetSyncTable<T>().UpdateAsync(item);
await SyncItemsAsync<T>();
}
public static async Task RemoveItemAsync<T>(T item) where T : EntityData
{
await Initialize<T>();
await _mobileService.GetSyncTable<T>().DeleteAsync(item);
await SyncItemsAsync<T>();
}
static async Task SyncItemsAsync<T>() where T : EntityData
{
await Initialize<T>();
try
{
await _mobileService.SyncContext.PushAsync();
await _mobileService.GetSyncTable<T>().PullAsync($"all{typeof(T).Name}", _mobileService.GetSyncTable<T>().CreateQuery());
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Error during Sync occurred: {ex.Message}");
}
}
async static Task Initialize<T>() where T : EntityData
{
if (_isInitialized)
return;
_mobileService = new MobileServiceClient(AzureConstants.AppServiceUrl);
await ConfigureOnlineOfflineSync<T>();
_isInitialized = true;
}
static async Task ConfigureOnlineOfflineSync<T>() where T : EntityData
{
var path = Path.Combine(MobileServiceClient.DefaultDatabasePath, "azureSyncDatabase.db");
var store = new MobileServiceSQLiteStore(path);
store.DefineTable<T>();
await _mobileService.SyncContext.InitializeAsync(store, new SyncHandler(_mobileService));
}
这有帮助吗? http://stackoverflow.com/questions/36496043/azure-app-service-limits-body-size-to-64kb – Krumelur
嘿@Krumelur!这是有道理的,但我不知道如何配置后端,因为我使用了Azure Easy Tables,而且我没有手动创建API。 –