Skip to content

Adding the SDK Binding Support for Storage Blob #341

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

Open
wants to merge 12 commits into
base: v4.x
Choose a base branch
from

Conversation

swapnil-nagar
Copy link

@swapnil-nagar swapnil-nagar commented Apr 28, 2025

This pull request introduces support for SDK binding for Azure Storage Blob in the Azure Functions Node.js library. Key changes include adding a new boolean property, deferredBinding, which allows users to enable deferred binding for storage blobs. When deferredBinding is enabled, the StorageBlobClient is returned to the user, which contains both the blobClient and containerClient, providing enhanced functionality for interacting with blob storage.

Example

app.storageBlob("storageBlobTrigger", {
  path: "snippets/{name}",
  connection: "SwapnilUserMiTest",
  deferredBinding: true,
  handler: storageBlobTrigger1,
});
export async function storageBlobTrigger1(
  blobStorageClient: StorageBlobClient,
  context: InvocationContext
): Promise<void> {
  context.log(
    `Storage blob function processed blob "${context.triggerMetadata.name}"`
  );
  try {
    // Download the blob content
    const downloadBlockBlobResponse =
      await blobStorageClient.blobClient.download();

    context.log("Contemt: ", downloadBlockBlobResponse );
  } catch (error) {
    console.error("Error downloading blob content:", error.message);
    throw error;
  }
  context.log("Storage blob trigger function executed successfully!");
}

Definition of StorageBlobClient

{
    /**
     * Blob client to be used by this blob input or output. This is the client that will be used to perform operations on the blob storage.
     */
    blobClient: BlobClient;

    /**
     * Container client to be used by this blob input or output. This is the client that will be used to perform operations on the container storage.
     */
    conatinerClient: ContainerClient;
}

@swapnil-nagar swapnil-nagar marked this pull request as ready for review April 28, 2025 03:41
@swapnil-nagar swapnil-nagar requested a review from a team as a code owner April 28, 2025 03:41
@@ -0,0 +1,90 @@
// Copyright (c) .NET Foundation. All rights reserved.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should move this file inside storage blob? Each extension should gets its own connection details. There is no common method that can be shared with all extensions.,

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the modelBindingData( deferred binding) that we are processing, I would think for all the types we will need a way to parse the data in buffer object.

Based on the model parameter for other deferred binding types, we may have to change the logic slightly. I will refactor when, I will see the data from service bus or cosmos.

But today I will keep it unchanged

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, currently model binding data is core-types I need to see what needs to be exposed. As there is no customer impact and customer is unaware of this, I will lkeep it this iteration. Later I will refactir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants