Skip to content

Revert "Adding the SDK Binding Support for Storage Blob (#341)" #348

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 3 commits into from
May 22, 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
9 changes: 0 additions & 9 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,6 @@
"request": "launch",
"skipFiles": ["<node_internals>/**"],
"type": "pwa-node"
},
{
"name": "Current TS Tests File",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": ["-r", "ts-node/register", "${relativeFile}"],
"cwd": "${workspaceRoot}",
"protocol": "inspector"
}
]
}
26 changes: 4 additions & 22 deletions package-lock.json

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

11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/functions",
"version": "4.7.1-preview",
"version": "4.7.0",
"description": "Microsoft Azure Functions NodeJS Framework",
"keywords": [
"azure",
Expand Down Expand Up @@ -41,10 +41,9 @@
"watch": "webpack --watch --mode development"
},
"dependencies": {
"@azure/functions-extensions-base": "0.1.0-preview",
"cookie": "^0.7.0",
"long": "^4.0.0",
"undici": "^5.13.0"
"undici": "^5.29.0"
},
"devDependencies": {
"@types/chai": "^4.2.22",
Expand All @@ -56,7 +55,6 @@
"@types/mocha": "^9.1.1",
"@types/node": "^18.0.0",
"@types/semver": "^7.3.9",
"@types/sinon": "^17.0.4",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
"chai": "^4.2.0",
Expand All @@ -67,8 +65,8 @@
"eslint-plugin-header": "^3.1.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-webpack-plugin": "^3.2.0",
"eslint-plugin-simple-import-sort": "^10.0.0",
"fork-ts-checker-webpack-plugin": "^7.2.13",
"fs-extra": "^10.0.1",
"globby": "^11.0.0",
Expand All @@ -78,10 +76,9 @@
"mocha-multi-reporters": "^1.5.1",
"prettier": "^2.4.1",
"semver": "^7.3.5",
"sinon": "^20.0.0",
"ts-loader": "^9.3.1",
"ts-node": "^3.3.0",
"typescript": "^4.9.5",
"typescript": "^4.5.5",
"typescript4": "npm:typescript@~4.0.0",
"webpack": "^5.74.0",
"webpack-cli": "^4.10.0"
Expand Down
2 changes: 2 additions & 0 deletions src/InvocationModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ export class InvocationModel implements coreTypes.InvocationModel {
} else {
input = fromRpcTypedData(binding.data);
}

if (isTimerTrigger(bindingType)) {
input = toCamelCaseValue(input);
}

if (isTrigger(bindingType)) {
inputs.push(input);
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT License.

export const version = '4.7.1-preview';
export const version = '4.7.0';

export const returnBindingKey = '$return';
15 changes: 2 additions & 13 deletions src/converters/fromRpcTypedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.

import { RpcTypedData } from '@azure/functions-core';
import { ResourceFactoryResolver } from '@azure/functions-extensions-base';
import { HttpRequest } from '../http/HttpRequest';
import { isDefined } from '../utils/nonNull';

Expand Down Expand Up @@ -31,18 +30,8 @@ export function fromRpcTypedData(data: RpcTypedData | null | undefined): unknown
return data.collectionDouble.double;
} else if (data.collectionSint64 && isDefined(data.collectionSint64.sint64)) {
return data.collectionSint64.sint64;
} else if (data.modelBindingData && isDefined(data.modelBindingData.content)) {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
const resourceFactoryResolver: ResourceFactoryResolver = ResourceFactoryResolver.getInstance();
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
return resourceFactoryResolver.createClient(data.modelBindingData.source, data.modelBindingData);
} catch (exception) {
throw new Error(
'Unable to create client. Please register the extensions library with your function app. ' +
`Error: ${exception instanceof Error ? exception.message : String(exception)}`
);
}
} else {
return undefined;
}
}

Expand Down
47 changes: 1 addition & 46 deletions src/converters/toCoreFunctionMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,17 @@ import * as coreTypes from '@azure/functions-core';
import { returnBindingKey } from '../constants';
import { AzFuncSystemError } from '../errors';
import { isTrigger } from '../utils/isTrigger';
import { workerSystemLog } from '../utils/workerSystemLog';
import { toRpcDuration } from './toRpcDuration';

export function toCoreFunctionMetadata(name: string, options: GenericFunctionOptions): coreTypes.FunctionMetadata {
const bindings: Record<string, coreTypes.RpcBindingInfo> = {};
const bindingNames: string[] = [];
const trigger = options.trigger;

const trigger = options.trigger;
bindings[trigger.name] = {
...trigger,
direction: 'in',
type: isTrigger(trigger.type) ? trigger.type : trigger.type + 'Trigger',
properties: addSdkBindingsFlag(options.trigger?.sdkBinding, name, trigger.type, trigger.name, false),
};
bindingNames.push(trigger.name);

Expand All @@ -27,7 +25,6 @@ export function toCoreFunctionMetadata(name: string, options: GenericFunctionOpt
bindings[input.name] = {
...input,
direction: 'in',
properties: addSdkBindingsFlag(input?.sdkBinding, name, input.type, input.name, true),
};
bindingNames.push(input.name);
}
Expand Down Expand Up @@ -77,45 +74,3 @@ export function toCoreFunctionMetadata(name: string, options: GenericFunctionOpt

return { name, bindings, retryOptions };
}

/**
* Adds the deferred binding flags to function bindings based on the binding configuration
* @param sdkBindingType Boolean indicating if this is an SDK binding
* @param functionName The name of the function for logging purposes
* @param triggerType The type of the trigger or binding
* @param bindingOrTriggerName The name of the trigger or binding
* @param isBinding Boolean indicating if this is a binding (vs a trigger)
* @returns Object with supportsDeferredBinding property set to 'true' or 'false'
*/
export function addSdkBindingsFlag(
sdkBindingType?: boolean | unknown,
functionName?: string,
triggerType?: string,
bindingOrTriggerName?: string,
isBinding?: boolean
): { [key: string]: string } {
// Ensure that trigger type is valid and supported
if (sdkBindingType !== undefined && sdkBindingType === true) {
const entityType = isBinding ? 'binding' : 'trigger';

// Create structured JSON log entry
const logData = {
operation: 'EnableDeferredBinding',
properties: {
functionName: functionName || 'unknown',
entityType: entityType,
triggerType: triggerType || 'unknown',
bindingOrTriggerName: bindingOrTriggerName || 'unknown',
supportsDeferredBinding: true,
},
message: `Enabled Deferred Binding of type '${triggerType || 'unknown'}' for function '${
functionName || 'unknown'
}'`,
};
// Log both the structured data
workerSystemLog('information', JSON.stringify(logData));
return { supportsDeferredBinding: 'true' };
}

return { supportsDeferredBinding: 'false' };
}
2 changes: 1 addition & 1 deletion src/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
HttpTrigger,
HttpTriggerOptions,
MySqlTrigger,
MySqlTriggerOptions,
MySqlTriggerOptions,
ServiceBusQueueTrigger,
ServiceBusQueueTriggerOptions,
ServiceBusTopicTrigger,
Expand Down
Loading
Loading