Skip to content

Emulate Storage and CosmosDB E2E Tests #62

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Jul 29, 2025
Merged
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
2 changes: 1 addition & 1 deletion app/v3-oldConfig/cosmosDBTrigger/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "documents",
"direction": "in",
"leaseCollectionName": "leases",
"connectionStringSetting": "e2eTest_cosmosDB",
"connectionStringSetting": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"collectionName": "e2eTestContainerTrigger",
"createLeaseCollectionIfNotExists": true,
Expand Down
4 changes: 2 additions & 2 deletions app/v3-oldConfig/cosmosDBTriggerAndOutput/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "documents",
"direction": "in",
"leaseCollectionName": "leases",
"connectionStringSetting": "e2eTest_cosmosDB",
"connectionStringSetting": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"collectionName": "e2eTestContainerTriggerAndOutput",
"createLeaseCollectionIfNotExists": true,
Expand All @@ -15,7 +15,7 @@
"type": "cosmosDB",
"name": "$return",
"direction": "out",
"connectionStringSetting": "e2eTest_cosmosDB",
"connectionStringSetting": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"collectionName": "e2eTestContainerTrigger"
}
Expand Down
2 changes: 1 addition & 1 deletion app/v3-oldConfig/httpTriggerCosmosDBInput/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"type": "cosmosDB",
"name": "inputDoc",
"direction": "in",
"connectionStringSetting": "e2eTest_cosmosDB",
"connectionStringSetting": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"collectionName": "e2eTestContainerTriggerAndOutput",
"partitionKey": "testPartKey",
Expand Down
2 changes: 1 addition & 1 deletion app/v3-oldConfig/httpTriggerCosmosDBOutput/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"type": "cosmosDB",
"name": "outputDoc",
"direction": "out",
"connectionStringSetting": "e2eTest_cosmosDB",
"connectionStringSetting": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"collectionName": "e2eTestContainerTriggerAndOutput"
}
Expand Down
2 changes: 1 addition & 1 deletion app/v3/cosmosDBTrigger/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "documents",
"direction": "in",
"leaseContainerName": "leases",
"connection": "e2eTest_cosmosDB",
"connection": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"containerName": "e2eTestContainerTrigger",
"createLeaseContainerIfNotExists": true,
Expand Down
20 changes: 10 additions & 10 deletions app/v3/cosmosDBTrigger/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context } from '@azure/functions';
import { AzureFunction, Context } from '@azure/functions';

// const cosmosDBTrigger: AzureFunction = async function (context: Context, documents: any[]): Promise<void> {
// context.log(`cosmosDBTrigger processed ${documents.length} documents`);
// for (const document of documents) {
// context.log(`cosmosDBTrigger was triggered by "${document.testData}"`);
// }
// };
const cosmosDBTrigger: AzureFunction = async function (context: Context, documents: any[]): Promise<void> {
context.log(`cosmosDBTrigger processed ${documents.length} documents`);
for (const document of documents) {
context.log(`cosmosDBTrigger was triggered by "${document.testData}"`);
}
};

// export default cosmosDBTrigger;
export default cosmosDBTrigger;
4 changes: 2 additions & 2 deletions app/v3/cosmosDBTriggerAndOutput/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"name": "documents",
"direction": "in",
"leaseContainerName": "leases",
"connection": "e2eTest_cosmosDB",
"connection": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"containerName": "e2eTestContainerTriggerAndOutput",
"createLeaseContainerIfNotExists": true,
Expand All @@ -15,7 +15,7 @@
"type": "cosmosDB",
"name": "$return",
"direction": "out",
"connection": "e2eTest_cosmosDB",
"connection": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"containerName": "e2eTestContainerTrigger"
}
Expand Down
22 changes: 11 additions & 11 deletions app/v3/cosmosDBTriggerAndOutput/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context } from '@azure/functions';
import { AzureFunction, Context } from '@azure/functions';

// const cosmosDBTrigger: AzureFunction = async function (context: Context, documents: any[]): Promise<any[]> {
// context.log(`cosmosDBTriggerAndOutput processed ${documents.length} documents`);
// for (const document of documents) {
// context.log(`cosmosDBTriggerAndOutput was triggered by "${document.testData}"`);
// }
// return documents;
// };
const cosmosDBTrigger: AzureFunction = async function (context: Context, documents: any[]): Promise<any[]> {
context.log(`cosmosDBTriggerAndOutput processed ${documents.length} documents`);
for (const document of documents) {
context.log(`cosmosDBTriggerAndOutput was triggered by "${document.testData}"`);
}
return documents;
};

// export default cosmosDBTrigger;
export default cosmosDBTrigger;
2 changes: 1 addition & 1 deletion app/v3/httpTriggerCosmosDBInput/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"type": "cosmosDB",
"name": "inputDoc",
"direction": "in",
"connection": "e2eTest_cosmosDB",
"connection": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"containerName": "e2eTestContainerTriggerAndOutput",
"partitionKey": "testPartKey",
Expand Down
24 changes: 12 additions & 12 deletions app/v3/httpTriggerCosmosDBInput/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
import { AzureFunction, Context, HttpRequest } from '@azure/functions';

// const httpTriggerCosmosDBInput: AzureFunction = async function (
// context: Context,
// _request: HttpRequest
// ): Promise<void> {
// context.res = {
// body: context.bindings.inputDoc.testData,
// };
// };
const httpTriggerCosmosDBInput: AzureFunction = async function (
context: Context,
_request: HttpRequest
): Promise<void> {
context.res = {
body: context.bindings.inputDoc.testData,
};
};

// export default httpTriggerCosmosDBInput;
export default httpTriggerCosmosDBInput;
2 changes: 1 addition & 1 deletion app/v3/httpTriggerCosmosDBOutput/function.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"type": "cosmosDB",
"name": "outputDoc",
"direction": "out",
"connection": "e2eTest_cosmosDB",
"connection": "CosmosDBConnection",
"databaseName": "e2eTestDB",
"containerName": "e2eTestContainerTriggerAndOutput"
}
Expand Down
22 changes: 11 additions & 11 deletions app/v3/httpTriggerCosmosDBOutput/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
import { AzureFunction, Context, HttpRequest } from '@azure/functions';

// const httpTriggerCosmosDBOutput: AzureFunction = async function (
// context: Context,
// request: HttpRequest
// ): Promise<void> {
// context.bindings.outputDoc = request.body;
// context.res = { body: 'done' };
// };
const httpTriggerCosmosDBOutput: AzureFunction = async function (
context: Context,
request: HttpRequest
): Promise<void> {
context.bindings.outputDoc = request.body;
context.res = { body: 'done' };
};

// export default httpTriggerCosmosDBOutput;
export default httpTriggerCosmosDBOutput;
22 changes: 11 additions & 11 deletions app/v3/httpTriggerStorageQueueOutput/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
import { AzureFunction, Context, HttpRequest } from '@azure/functions';

// const httpTriggerStorageQueueOutput: AzureFunction = async function (
// context: Context,
// request: HttpRequest
// ): Promise<void> {
// context.bindings.outputMsg = request.body.output;
// context.res = { body: 'done' };
// };
const httpTriggerStorageQueueOutput: AzureFunction = async function (
context: Context,
request: HttpRequest
): Promise<void> {
context.bindings.outputMsg = request.body.output;
context.res = { body: 'done' };
};

// export default httpTriggerStorageQueueOutput;
export default httpTriggerStorageQueueOutput;
20 changes: 10 additions & 10 deletions app/v3/httpTriggerTableInput/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
import { AzureFunction, Context, HttpRequest } from '@azure/functions';

// const httpTriggerTableInput: AzureFunction = async function (context: Context, request: HttpRequest): Promise<void> {
// context.log(`httpTriggerTableInput was triggered`);
// context.res = {
// body: context.bindings.inputItem,
// };
// };
const httpTriggerTableInput: AzureFunction = async function (context: Context, request: HttpRequest): Promise<void> {
context.log(`httpTriggerTableInput was triggered`);
context.res = {
body: context.bindings.inputItem,
};
};

// export default httpTriggerTableInput;
export default httpTriggerTableInput;
22 changes: 11 additions & 11 deletions app/v3/httpTriggerTableOutput/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context, HttpRequest } from '@azure/functions';
import { AzureFunction, Context, HttpRequest } from '@azure/functions';

// const httpTriggerTableOutput: AzureFunction = async function (context: Context, request: HttpRequest): Promise<void> {
// context.log(`httpTriggerTableOutput was triggered`);
// context.bindings.outputItem = request.body;
// context.res = {
// status: 201,
// };
// };
const httpTriggerTableOutput: AzureFunction = async function (context: Context, request: HttpRequest): Promise<void> {
context.log(`httpTriggerTableOutput was triggered`);
context.bindings.outputItem = request.body;
context.res = {
status: 201,
};
};

// export default httpTriggerTableOutput;
export default httpTriggerTableOutput;
16 changes: 8 additions & 8 deletions app/v3/storageBlobTrigger/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context } from '@azure/functions';
import { AzureFunction, Context } from '@azure/functions';

// const blobTrigger: AzureFunction = async function (context: Context, myBlob: any): Promise<void> {
// const blobPath = context.bindingData.blobTrigger;
// context.log(`storageBlobTrigger was triggered by blob "${blobPath}" with content "${myBlob.toString()}"`);
// };
const blobTrigger: AzureFunction = async function (context: Context, myBlob: any): Promise<void> {
const blobPath = context.bindingData.blobTrigger;
context.log(`storageBlobTrigger was triggered by blob "${blobPath}" with content "${myBlob.toString()}"`);
};

// export default blobTrigger;
export default blobTrigger;
18 changes: 9 additions & 9 deletions app/v3/storageBlobTriggerAndOutput/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context } from '@azure/functions';
import { AzureFunction, Context } from '@azure/functions';

// const blobTrigger: AzureFunction = async function (context: Context, myBlob: any): Promise<any> {
// const blobPath = context.bindingData.blobTrigger;
// context.log(`storageBlobTriggerAndOutput was triggered by blob "${blobPath}" with content "${myBlob.toString()}"`);
// return myBlob;
// };
const blobTrigger: AzureFunction = async function (context: Context, myBlob: any): Promise<any> {
const blobPath = context.bindingData.blobTrigger;
context.log(`storageBlobTriggerAndOutput was triggered by blob "${blobPath}" with content "${myBlob.toString()}"`);
return myBlob;
};

// export default blobTrigger;
export default blobTrigger;
14 changes: 7 additions & 7 deletions app/v3/storageQueueTrigger/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context } from '@azure/functions';
import { AzureFunction, Context } from '@azure/functions';

// const queueTrigger: AzureFunction = async function (context: Context, myQueueItem: string): Promise<void> {
// context.log(`storageQueueTrigger was triggered by "${myQueueItem}"`);
// };
const queueTrigger: AzureFunction = async function (context: Context, myQueueItem: string): Promise<void> {
context.log(`storageQueueTrigger was triggered by "${myQueueItem}"`);
};

// export default queueTrigger;
export default queueTrigger;
16 changes: 8 additions & 8 deletions app/v3/storageQueueTriggerAndOutput/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

// import { AzureFunction, Context } from '@azure/functions';
import { AzureFunction, Context } from '@azure/functions';

// const queueTrigger: AzureFunction = async function (context: Context, myQueueItem: string): Promise<string> {
// context.log(`storageQueueTriggerAndOutput was triggered by "${myQueueItem}"`);
// return myQueueItem;
// };
const queueTrigger: AzureFunction = async function (context: Context, myQueueItem: string): Promise<string> {
context.log(`storageQueueTriggerAndOutput was triggered by "${myQueueItem}"`);
return myQueueItem;
};

// export default queueTrigger;
export default queueTrigger;
34 changes: 17 additions & 17 deletions app/v4-oldConfig/src/functions/cosmosDBTrigger.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// // Copyright (c) .NET Foundation. All rights reserved.
// // Licensed under the MIT License.
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

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

// export async function cosmosDBTrigger(documents: unknown[], context: InvocationContext): Promise<void> {
// context.log(`cosmosDBTrigger processed ${documents.length} documents`);
// for (const document of documents) {
// context.log(`cosmosDBTrigger was triggered by "${(<any>document).testData}"`);
// }
// }
export async function cosmosDBTrigger(documents: unknown[], context: InvocationContext): Promise<void> {
context.log(`cosmosDBTrigger processed ${documents.length} documents`);
for (const document of documents) {
context.log(`cosmosDBTrigger was triggered by "${(<any>document).testData}"`);
}
}

// app.cosmosDB('cosmosDBTrigger', {
// connectionStringSetting: 'e2eTest_cosmosDB',
// databaseName: 'e2eTestDB',
// collectionName: 'e2eTestContainerTrigger',
// createLeaseCollectionIfNotExists: true,
// leaseCollectionPrefix: '2',
// handler: cosmosDBTrigger,
// });
app.cosmosDB('cosmosDBTrigger', {
connectionStringSetting: 'CosmosDBConnection',
databaseName: 'e2eTestDB',
collectionName: 'e2eTestContainerTrigger',
createLeaseCollectionIfNotExists: true,
leaseCollectionPrefix: '2',
handler: cosmosDBTrigger,
});
Loading