问题描述
我有一个复杂的 azure 函数,它在检查几个条件的同时在 dataverse 的表中创建/更新大约 400 条记录
我正在使用 ExecuteTransactionRequest 创建/更新记录,执行逻辑大约需要 15 秒。有没有办法让它更快,在执行转换的同时引入并行处理?
解决方法
我不确定我的回答是否适用于您的情况,但我会提及以供参考。
WebApi 接受批处理请求,从而为您节省顺序和并发请求的延迟时间。一个包含多个内部请求的请求被发送到 api 一次,并将立即在他们的服务器上运行并返回结果。
也就是说,如果您使用 WebApi 而不是使用连接器与 CDS 通信。
如果是这样,请参考下面的例子发布2种货币并获得全部:
--batch_ABC123
Content-Type: multipart/mixed; boundary=changeset_ABC111
--changeset_ABC111
Content-Type: application/http
Content-Transfer-Encoding: binary
POST YOUR-RESOURCE_URL/api/data/v9.1/transactioncurrencies HTTP/1.1
Content-ID: 1
Accept: application/json;
Content-Type: application/json;type=entry
{"currencyname": "Dansk Krona1","currencysymbol": "$","isocurrencycode": "PPV","exchangerate": 0.90}
--changeset_ABC111
Content-Type: application/http
Content-Transfer-Encoding: binary
POST YOUR-RESOURCE_URL/api/data/v9.1/transactioncurrencies HTTP/1.1
Content-ID: 2
Accept: application/json;
Content-Type: application/json;type=entry
{"currencyname": "Dansk Krona2","isocurrencycode": "UPV","exchangerate": 0.90}
--changeset_ABC111--
--batch_ABC123
Content-Type: application/http
Content-Transfer-Encoding:binary
GET YOUR-RESOURCE_URL/api/data/v9.1/transactioncurrencies HTTP/1.1
Accept: application/json
--batch_ABC123--