Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/v4/host.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"version": "2.0",
"logging": {
"logLevel": {
"Microsoft.Azure.Functions.Extensions.Connector": "Information"
},
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
Expand All @@ -9,10 +12,7 @@
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[4.*, 5.0.0)"
},
"mcp": {
"enabled": true
"id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
"version": "[4.43.*, 5.0.0)"
}
}
}
70 changes: 48 additions & 22 deletions app/v4/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion app/v4/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"test": "echo \"No tests yet...\""
},
"dependencies": {
"@azure/functions": "^4.12.0"
"@azure/functions": "4.16.0-preview"
},
"devDependencies": {
"@types/long": "^4.0.0",
Expand Down
22 changes: 22 additions & 0 deletions app/v4/src/functions/cosmosDBMongoTrigger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

import { app, InvocationContext } from '@azure/functions';

export async function cosmosDBMongoTrigger(change: any, context: InvocationContext): Promise<void> {
const document = change && change.fullDocument;
const documentId = (document && document._id) || (change && change.documentKey && change.documentKey._id);

context.log(`cosmosDBMongoTrigger operation "${change && change.operationType}" for "${documentId}"`);
context.log(`cosmosDBMongoTrigger saw "${document && document.testData}"`);
}

app.cosmosDBMongo('cosmosDBMongoTrigger', {
connectionStringSetting: 'CosmosDBMongoConnection',
databaseName: 'e2eTestCosmosDBMongo',
collectionName: 'e2eTestCollectionTrigger',
createIfNotExists: true,
leaseDatabaseName: 'e2eTestCosmosDBMongo',
leaseCollectionName: 'e2eLeasesTrigger',
handler: cosmosDBMongoTrigger,
});
34 changes: 34 additions & 0 deletions app/v4/src/functions/cosmosDBMongoTriggerAndOutput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

import { app, InvocationContext, output } from '@azure/functions';

const cosmosDBMongoOutput = output.cosmosDBMongo({
connectionStringSetting: 'CosmosDBMongoConnection',
databaseName: 'e2eTestCosmosDBMongo',
collectionName: 'e2eTestCollectionTrigger',
createIfNotExists: true,
});

export async function cosmosDBMongoTriggerAndOutput(change: any, context: InvocationContext): Promise<void> {
const document = change && change.fullDocument;
const documentId = (document && document._id) || (change && change.documentKey && change.documentKey._id);

context.log(`cosmosDBMongoTriggerAndOutput operation "${change && change.operationType}" for "${documentId}"`);
context.log(`cosmosDBMongoTriggerAndOutput saw "${document && document.testData}"`);

if (document) {
context.extraOutputs.set(cosmosDBMongoOutput, document);
}
}

app.cosmosDBMongo('cosmosDBMongoTriggerAndOutput', {
connectionStringSetting: 'CosmosDBMongoConnection',
databaseName: 'e2eTestCosmosDBMongo',
collectionName: 'e2eTestCollectionTriggerAndOutput',
createIfNotExists: true,
leaseDatabaseName: 'e2eTestCosmosDBMongo',
leaseCollectionName: 'e2eLeasesTriggerAndOutput',
extraOutputs: [cosmosDBMongoOutput],
handler: cosmosDBMongoTriggerAndOutput,
});
29 changes: 29 additions & 0 deletions app/v4/src/functions/httpTriggerCosmosDBMongoInput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

import { app, HttpRequest, HttpResponseInit, input, InvocationContext } from '@azure/functions';

const cosmosDBMongoInput = input.cosmosDBMongo({
connectionStringSetting: 'CosmosDBMongoConnection',
databaseName: 'e2eTestCosmosDBMongo',
collectionName: 'e2eTestCollectionTriggerAndOutput',
queryString: '{{"_id":"{Query.id}"}}',
createIfNotExists: true,
});

export async function httpTriggerCosmosDBMongoInput(
_request: HttpRequest,
context: InvocationContext
): Promise<HttpResponseInit> {
const result = context.extraInputs.get(cosmosDBMongoInput);
const documents = typeof result === 'string' ? JSON.parse(result) : result;
const document = Array.isArray(documents) ? documents[0] : documents;
return { body: document ? (<any>document).testData : '' };
}

app.http('httpTriggerCosmosDBMongoInput', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
extraInputs: [cosmosDBMongoInput],
handler: httpTriggerCosmosDBMongoInput,
});
27 changes: 27 additions & 0 deletions app/v4/src/functions/httpTriggerCosmosDBMongoOutput.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

import { app, HttpRequest, HttpResponseInit, InvocationContext, output } from '@azure/functions';

const cosmosDBMongoOutput = output.cosmosDBMongo({
connectionStringSetting: 'CosmosDBMongoConnection',
databaseName: 'e2eTestCosmosDBMongo',
collectionName: 'e2eTestCollectionTrigger',
createIfNotExists: true,
});

export async function httpTriggerCosmosDBMongoOutput(
request: HttpRequest,
context: InvocationContext
): Promise<HttpResponseInit> {
const body = await request.json();
context.extraOutputs.set(cosmosDBMongoOutput, body);
return { body: 'done' };
}

app.http('httpTriggerCosmosDBMongoOutput', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
extraOutputs: [cosmosDBMongoOutput],
handler: httpTriggerCosmosDBMongoOutput,
});
Loading
Loading