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。 –