С моей стороны все работает нормально. Я могу загрузить, а также обновить.
Это код моего функционального приложения:
index.ts:
import { AzureFunction, Context, HttpRequest } from "@azure/functions"
const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
context.log('HTTP trigger function processed a request.');
const name = (req.query.name || (req.body && req.body.name));
try {
if (req.body) {
const body: Body = req.body
context.bindings.employeeDocument = JSON.stringify(body);
context.res = {
status: 200,
body: 'Successfully persisted document'
};
}
} catch (error) {
context.res = {
status: 400,
body: 'Colliding id'
}
}
if (name) {
context.res = {
// status: 200, /* Defaults to 200 */
body: "Hello " + (req.query.name || req.body.name)
};
}
else {
context.res = {
status: 400,
body: "Please pass a name on the query string or in the request body"
};
}
};
export default httpTrigger;
функция. json:
{
"bindings": [
{
"authLevel": "function",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"type": "http",
"direction": "out",
"name": "res"
},
{
"name": "employeeDocument",
"type": "cosmosDB",
"databaseName": "ToDoList",
"collectionName": "Items",
"createIfNotExists": true,
"connectionStringSetting": "MyAccount_COSMOSDB",
"direction": "out"
}
],
"scriptFile": "../dist/HttpTrigger1/index.js"
}
И это почтальон: (Я поместил файл json в test.txt)
test.txt:
{
"id": "934a2153-fdb1-40e3-9e90-61c43fcef220",
"shipmentId": "shipmentId2",
"timestamp": 1586327829354,
"totalVolume": 1,
"totalWeight": 1,
"packages": [{
"packageId": "courierPackageId",
"shipmentId": "shipmentId",
"weight:": 1000,
"dimensions": {
"length": 100,
"width": 100,
"height": 100
}
}]
}
В случае того же идентификатора, если вы измените другие детали и затем активируете функцию, azure cosmosdb будет соответственно обновлен.