I get an error “MissingBlobsEnvironmentError” when I try to use Netlify Blobs

My netlify site name is “netlifynote2.netlify.app”.
I am using Netlify Blobs, but at “const notesStore = getStore(‘notepad-notes’);” it fails with an error “MissingBlobsEnvironmentError”.
This error is the error in the Functions log.
I have tried redeploying with cache clear.
I have also tried explicitly setting the site ID and access token.
The error and source code are listed below.

source code

import { getStore } from '@netlify/blobs';

export const handler = async (event) => {
    try {
        const notesStore = getStore('notepad-notes');
        const notesData = await notesStore.get('user-notes', { type: 'json' });

        return {
            statusCode: 200, 
            headers: { "Content-Type": "application/json" }, 
            body: JSON.stringify({ notes: notesData || [] }), 
        };
    } catch (error) {
        console.error('Error loading notes from Blobs:', error);
        return {
            statusCode: 500, 
            headers: { "Content-Type": "application/json" },
            body: JSON.stringify({ error: 'Failed to load notes' }), 
        };
    }
};

error

Jun 19, 04:43:08 PM: 675fbd8f ERROR  Error loading notes from Blobs: MissingBlobsEnvironmentError: The environment has not been configured to use Netlify Blobs. To use it manually, supply the following properties when creating a store: siteID, token
Jun 19, 04:43:08 PM: 675fbd8f ERROR      at getClientOptions (/var/task/netlify/functions/load-notes.js:312:11)
Jun 19, 04:43:08 PM: 675fbd8f ERROR      at getStore (/var/task/netlify/functions/load-notes.js:585:27)
Jun 19, 04:43:08 PM: 675fbd8f ERROR      at Runtime.handler (/var/task/netlify/functions/load-notes.js:624:24)
Jun 19, 04:43:08 PM: 675fbd8f ERROR      at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1187:29)

Please help me.

Functions v1 needs Lambda compatibility mode: primitives/packages/blobs at main · netlify/primitives

The method described worked, thank you!

what is “Functions v1”, how could i known?

It’s documented here: Lambda compatibility for Functions | Netlify Docs

Hi @hrishikesh please consider updating the document Netlify Blobs | Netlify Docs . This is where connectLambda would have been extremely useful.

The docs are meant to suggest users to use the modern Netlify Functions syntax (Functions 2.0 that I mentioned above. So any kind of secrecy here is slightly intentional. Unless you’ve strong reasons to continue using the Lambda Compatible syntax, I’d recommend migrating.

Even still, your response here would be very useful in the Netlify Blobs docs troubleshooting section. Had your paragraph been in the docs, it would have saved me 30 minutes of lost time and frustration. Several high-ranked articles on Netlify still use the Lambda syntax which is why users may first start using that syntax and iterating on it.

I agree, I like the new Functions 2.0 syntax more since it uses the standard Request/Response objects along with Context (which is why I already migrated my code yesterday). But to avoid frustrating new Netlify users, it may be a good idea to listen to the voice of the new customer OR the customer coming from AWS with lots of functions OR the customer that’s afraid of vendor lock-in. The README file’s “Lambda” section should probably also exist in the Netlify Blobs Docs “Troubleshooting” section for “MissingBlobsEnvironmentError”, since that Error provides incorrect details on how to fix. The eyeballs of the users may be in either the README or the Troubleshooting section. You can still put words in there to discourage the use of Lambda mode OR provide migration tools to make it easier for your users.

Lambda compatibility mode

The environment is not configured automatically when running functions in the Lambda compatibility mode. To use Netlify Blobs, you must initialize the environment manually by calling the connectLambda method with the Lambda event as a parameter.

You should call this method immediately before calling getStore or getDeployStore.”