Redeploy Netlify Function Without Full Rebuild

At times I need to modify an environment variable in my settings, and have my functions pick up this new environment variable. In such situations typically no rebuild is required.

  • Is it possible to do this currently somehow (without waiting for a full rebuild to happen)?
  • If not, is a feature like this on the roadmap?

No, it’s not possible to do that, and with Netlify’s current architecture, it won’t be possible to change this any time soon (if at all).

Thanks for the quick response @hrishikesh . That’s unfortunate. Would be a really nice feature.

Just spitballing and thinking about what is happening underneath the hood (I am obviously simplifying it) but I understand that functions are deployed with environment variables in the headers, that are then available at runtime.

Couldn’t they just be redeployed again with the new headers equating to updated environment variables?
Previously built files seem to be cached and available via the UI.

Would be an amazing feature. Save alot of unecessary building as well for those of us making use of environment variables for configuration.

Unfortunately, it’s not that simple. Here’s how Netlify deploys:

  1. We check the list of files in your deploy and generate a SHA1 for each. For all functions, we generate a SHA256.
  2. We send this list to our backend.
  3. Backend compares what SHAs already exist on our CDN and what need to be uploaded. This happens only for files, not for functions.
  4. The required files are uploaded.

Now, if you send a deploy with only a function as a required file, that deploy would contain only the function. It won’t have any other file in it, because our backend knows that, that particular deploy should only have a function, no files. Since it’s required for the backend to know which file exists in a deploy, you always have to send a list of files, and to do that, we always rebuild the site.

I’m not saying your suggestion doesn’t make sense, it’s indeed valid, but given the current constraints, this would be much harder to implement. Yes, we can use the same list of files from the current deploy and simply update it to include the function, but this will take much longer to implement and given other priorities, it might not get picked-up any time soon.