Skip to content

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

Merged
Aishwarya Bhandari (aishwaryabh) merged 10 commits into
mainfrom
aibhandari/fallback-to-bundles
Feb 23, 2026
Merged

Fallback to cached bundles if there is no network connection#4772
Aishwarya Bhandari (aishwaryabh) merged 10 commits into
mainfrom
aibhandari/fallback-to-bundles

Conversation

@aishwaryabh

@aishwaryabh Aishwarya Bhandari (aishwaryabh) commented Jan 12, 2026

Copy link
Copy Markdown
Contributor

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
Aishwarya Bhandari (aishwaryabh) marked this pull request as ready for review January 14, 2026 02:01
Comment thread src/Cli/func/Actions/HostActions/StartHostAction.cs Outdated
Comment thread src/Cli/func/Actions/HostActions/StartHostAction.cs Outdated
Comment thread src/Cli/func/Actions/HostActions/StartHostAction.cs Outdated
Comment thread src/Cli/func/Actions/HostActions/StartHostAction.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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

Comment thread test/Cli/Func.E2ETests/Commands/FuncStart/Core/BaseOfflineBundleTests.cs Outdated
Comment thread test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/NodeV4Tests.cs Outdated
Comment thread test/Cli/Func.E2ETests/Commands/FuncStart/TestsWithFixtures/NodeV3Tests.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/Actions/HostActions/StartHostAction.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread test/Cli/Func.UnitTests/HelperTests/ExtensionBundleHelperTests.cs Outdated
Comment thread test/Cli/Func.UnitTests/HelperTests/ExtensionBundleHelperTests.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
@aishwaryabh

Copy link
Copy Markdown
Contributor Author

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

Copilot AI commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Aishwarya Bhandari (@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.

Copy link
Copy Markdown
Member

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

Comment thread src/Cli/func/Azure.Functions.Cli.csproj Outdated
Comment thread src/Cli/func/Helpers/RetryHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/Helpers/GlobalCoreToolsSettings.cs Outdated
Comment thread src/Cli/func/Helpers/OfflineHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/Actions/HostActions/StartHostAction.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs
Comment thread src/Cli/func/Actions/HostActions/StartHostAction.cs Outdated

Copy link
Copy Markdown
Member

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

Comment thread src/Cli/func/Helpers/OfflineHelper.cs Outdated
Comment thread src/Cli/func/Helpers/OfflineHelper.cs
Comment thread src/Cli/func/Helpers/OfflineHelper.cs Outdated
Comment thread src/Cli/func/Helpers/GlobalCoreToolsSettings.cs Outdated
Comment thread src/Cli/func/Actions/LocalActions/DownloadBundleAction.cs Outdated
Comment thread src/Cli/func/Actions/LocalActions/GetBundlePathAction.cs Outdated
Comment thread src/Cli/func/Actions/HostActions/StartHostAction.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs
Comment thread src/Cli/func/Helpers/OfflineHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/Helpers/GlobalCoreToolsSettings.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread test/Cli/Func.UnitTests/HelperTests/ExtensionBundleHelperTests.cs Outdated
Comment thread release_notes.md Outdated
@liliankasem

Copy link
Copy Markdown
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.

Aishwarya Bhandari added 2 commits February 19, 2026 16:50
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
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
Comment thread src/Cli/func/Actions/HelpAction.cs Outdated
Comment thread src/Cli/func/Helpers/GlobalCoreToolsSettings.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs
Comment thread src/Cli/func/Actions/LocalActions/DownloadBundleAction.cs
Comment thread src/Cli/func/Actions/HelpAction.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleConfigurationBuilder.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated

Copy link
Copy Markdown
Member

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.

Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/ExtensionBundle/ExtensionBundleHelper.cs Outdated
Comment thread src/Cli/func/Helpers/GlobalCoreToolsSettings.cs
Comment thread src/Cli/func/Helpers/OfflineHelper.cs
Comment thread src/Cli/func/Helpers/OfflineHelper.cs
@aishwaryabh
Aishwarya Bhandari (aishwaryabh) merged commit a7a5dc9 into main Feb 23, 2026
39 checks passed
@aishwaryabh
Aishwarya Bhandari (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