繁体   English   中英

Azure简易表:请求实体太大

[英]Azure Easy Table: Request Entity Too Large

如何解决在Microsoft Azure门户中创建的Easy Table的错误消息? 当我调用MobileServiceClient.SyncContext.PushAsync时,会发生此错误:

OperationKind: Insert

Error Result: {
  "error": "request entity too large"
}

NuGet软件包

我正在使用以下NuGet软件包:

  • Microsoft.Azure.Mobile.Client v3.1.0
  • Microsoft.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));
    }

Azure移动应用程序后端只是为您预先配置的Node.js网站。 您可以使用App Service编辑器在后台查看代码。

查看Azure移动应用程序Node.js HOWTO-其中包含有关使接受的有效负载大小变大的部分。 只需在App Service编辑器中实施更改,然后重新启动服务即可。 寻找HOWTO:处理大文件上传

如果要进行插入,则数据应该不会那么大。 请勿将图片或其他较大的物品插入表格中-这是一种不好的做法。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM