Skip to content

Fallback to cached bundles if there is no network connection#4772

Merged
aishwaryabh merged 10 commits intomainfrom
aibhandari/fallback-to-bundles
Feb 23, 2026
Merged

Fallback to cached bundles if there is no network connection#4772
aishwaryabh merged 10 commits intomainfrom
aibhandari/fallback-to-bundles

Conversation

@aishwaryabh
Copy link
Contributor

@aishwaryabh aishwaryabh commented Jan 12, 2026

Issue describing the changes in this PR

resolves ##4770

This PR addresses the scenario if we want to fallback to cached bundles specifically for func start. For detecting if the system is online, we check by trying to ping an endpoint and cache if the system is offline or not for a specified interval for future calls. We also only download bundles in func start if the customer has specified AzureFunctionsJobHost__extensionBundle__ensureLatest to be true OR if we detect that the system is offline.

Example of running with no internet connection with no bundles cached:
image

Example of running with no internet connection but with bundles cached already:
image

Pull request checklist

  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • I have added all required tests (Unit tests, E2E tests)

Additional information

Additional PR information

@aishwaryabh aishwaryabh marked this pull request as ready for review January 14, 2026 02:01
@aishwaryabh aishwaryabh requested review from a team as code owners January 14, 2026 02:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements fallback to cached extension bundles when network connectivity is unavailable during func start. The implementation adds offline detection capabilities, caches offline status for performance, and provides fallback logic to use locally cached bundles when downloads fail. The PR also introduces conditional bundle downloading based on the AzureFunctionsJobHost__extensionBundle__ensureLatest setting.

Changes:

  • Added offline detection with caching to avoid excessive network checks
  • Implemented cached bundle lookup functionality with version range matching
  • Modified func start to conditionally download bundles based on ensureLatest setting
  • Added comprehensive unit and E2E tests for offline scenarios

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 24 comments.

Show a summary per file
File Description
src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Adds offline detection, cached bundle lookup, and network failure handling
src/Cli/func/Actions/HostActions/StartHostAction.cs Implements conditional bundle downloading based on ensureLatest setting
src/Cli/func/Actions/HostActions/Startup.cs Sets ensureLatest environment variable based on offline status
src/Cli/func/ExtensionBundle/ExtensionBundleConfigurationBuilder.cs Configures ensureLatest setting based on offline status
src/Cli/func/Helpers/RetryHelper.cs Adds support for non-retryable exceptions
src/Cli/func/Azure.Functions.Cli.csproj Exposes internals to test assembly
test/Cli/Func.UnitTests/HelperTests/ExtensionBundleHelperTests.cs Adds comprehensive unit tests for bundle helper methods
test/Cli/Func.E2ETests/Commands/FuncStart/Core/BaseOfflineBundleTests.cs Adds E2E test infrastructure for offline scenarios
test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/NodeV4Tests.cs Adds E2E tests for Node v4 runtime
test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/NodeV3Tests.cs Adds E2E tests for Node v3 runtime
test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/PowershellTests.cs Adds E2E tests for PowerShell runtime
release_notes.md Documents the new offline bundle fallback feature

@aishwaryabh
Copy link
Contributor Author

@copilot open a new PR addressing the comments in this thread. Can you also rebase to main for the conflicts?

Copy link
Contributor

Copilot AI commented Feb 6, 2026

@aishwaryabh I've opened a new pull request, #4789, to work on those changes. Once the pull request is ready, I'll request review from you.

@aishwaryabh aishwaryabh force-pushed the aibhandari/fallback-to-bundles branch from 9f44007 to efe7dc0 Compare February 6, 2026 21:11
Copy link
Member

@liliankasem liliankasem left a comment

Choose a reason for hiding this comment

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

offline mode should be a global settting and not connected to ext bundles

@aishwaryabh aishwaryabh force-pushed the aibhandari/fallback-to-bundles branch 2 times, most recently from f4c2d83 to 1d79909 Compare February 12, 2026 22:35
@liliankasem liliankasem self-requested a review February 13, 2026 19:31
Copy link
Member

@liliankasem liliankasem left a comment

Choose a reason for hiding this comment

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

Sorry meant to request changes not approve :D

@aishwaryabh aishwaryabh force-pushed the aibhandari/fallback-to-bundles branch from a5c411d to f5de440 Compare February 19, 2026 20:13
@liliankasem
Copy link
Member

Tested this with a happy and edge cases and its working really well! Only other thing I think we should fix is thr error messaging when offline i.e.

Offline check failed: No route to host (cdn.functions.azure.com:443)

Offline check failed: nodename nor servname provided, or not known (cdn.functions.azure.com:443)

Could do:

// IsOfflineAsync
            catch (Exception ex)
            {
                ColoredConsole.WriteLine(WarningColor("Unable to resolve network connection, running the CLI in offline mode."));

                if (GlobalCoreToolsSettings.IsVerbose)
                {
                    ColoredConsole.WriteLine(VerboseColor($"Details: {ex.Message}"));
                }

                return true;
            }
  }

I think we should log a better message here i.e.

Otherwise lgtm - ready to approve with this and above comments are addressed. Please also make sure to rebase and clean up commits.

@aishwaryabh aishwaryabh force-pushed the aibhandari/fallback-to-bundles branch from f5de440 to e890718 Compare February 20, 2026 00:49
seeing if latest changes work with func new

using bundle path

changing back

adding reference to ensureLatest env variable

adding release notes
fixing syntax

rebasing and fixing tests
aishwaryabh and others added 3 commits February 19, 2026 16:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

addressing syntax issue

addressing comments

fixing not needed file changes

updating scenarios to work

turn offline method into async and methods calling it as well

addressing comments
updating global offline flag to not override if user has explicit --offline flag

updating offline logic to work
@aishwaryabh aishwaryabh force-pushed the aibhandari/fallback-to-bundles branch from e890718 to 3e81a05 Compare February 20, 2026 00:53
Copy link
Member

@kshyju kshyju left a comment

Choose a reason for hiding this comment

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

A few more questions to clarify. Otherwise looking good.

@aishwaryabh aishwaryabh merged commit a7a5dc9 into main Feb 23, 2026
39 checks passed
@aishwaryabh aishwaryabh deleted the aibhandari/fallback-to-bundles branch February 23, 2026 21:56
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.

7 participants