Skip to content
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

Internet access is required for running azure functions on local machine #3821

Open
William1104 opened this issue Sep 12, 2024 · 6 comments
Open

Comments

@William1104
Copy link

Version

$ func --version
4.0.6280
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"

Description

func start would fail to execute when there is no Internet access. Some developers may have to work in a network without Internet access (or very limited access). It potentially makes azure-functions-core-tools not work..

When the machine has Internet access, we can run the tools locally.

$ func start

Azure Functions Core Tools
Core Tools Version:       4.0.6280 Commit hash: N/A +421f0144b42047aa289ce691dc6db4fc8b6143e6 (64-bit)
Function Runtime Version: 4.834.3.22875

[2024-09-12T16:11:30.915Z] OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.

Functions:

        echo: [GET,POST] http://localhost:7071/api/echo

        hello: [GET,POST] http://localhost:7071/api/hello

        uppercase: [GET,POST] http://localhost:7071/api/uppercase

For detailed output, run func with --verbose flag.
[2024-09-12T16:11:31.526Z] Worker process started and initialized.
[2024-09-12T16:11:35.788Z] Host lock lease acquired by instance ID '000000000000000000000000E7A1833D'.
^C[2024-09-12T16:11:41.082Z] Language Worker Process exited. Pid=6500.
[2024-09-12T16:11:41.082Z] /usr/lib/jvm/java-21-openjdk-amd64/bin/java exited with code 130 (0x82). .

But when we stop the Internet access, the tool would fail to build configuration in an external class. It looks like this process needs to download something from a CDN (functionscdn.azureedge.net:443).

$ func start

Azure Functions Core Tools
Core Tools Version:       4.0.6280 Commit hash: N/A +421f0144b42047aa289ce691dc6db4fc8b6143e6 (64-bit)
Function Runtime Version: 4.834.3.22875

[2024-09-12T16:12:09.804Z] Error building configuration in an external startup class.
[2024-09-12T16:12:09.804Z] Error building configuration in an external startup class. System.Net.Http: Resource temporarily unavailable (functionscdn.azureedge.net:443). System.Net.Sockets: Resource temporarily unavailable.
[2024-09-12T16:12:09.806Z] A host error has occurred during startup operation 'b37baf23-c6f0-476d-a961-41fd6ebcdbf5'.
[2024-09-12T16:12:09.806Z] Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. System.Net.Http: Resource temporarily unavailable (functionscdn.azureedge.net:443). System.Net.Sockets: Resource temporarily unavailable.
Value cannot be null. (Parameter 'provider')
[2024-09-12T16:12:09.823Z] Host startup operation has been canceled

Steps to reproduce

simply stop the Internet access and then run func start. We should see error following messages:

[2024-09-12T16:12:09.804Z] Error building configuration in an external startup class.
[2024-09-12T16:12:09.804Z] Error building configuration in an external startup class. System.Net.Http: Resource temporarily unavailable (functionscdn.azureedge.net:443). System.Net.Sockets: Resource temporarily unavailable.
[2024-09-12T16:12:09.806Z] A host error has occurred during startup operation 'b37baf23-c6f0-476d-a961-41fd6ebcdbf5'.
[2024-09-12T16:12:09.806Z] Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. System.Net.Http: Resource temporarily unavailable (functionscdn.azureedge.net:443). System.Net.Sockets: Resource temporarily unavailable.
@kshyju
Copy link
Member

kshyju commented Sep 12, 2024

@umangsriv Could you investigate this? You can use fiddler to find out what exact URL it is pinging.

May be it's related to Azure/azure-functions-host#9434

@umangsriv
Copy link
Contributor

@umangsriv Could you investigate this? You can use fiddler to find out what exact URL it is pinging.

May be it's related to Azure/azure-functions-host#9434

Sure @kshyju , I'll look into this.

@umangsriv
Copy link
Contributor

Hello @kshyju, I have investigated the issue and performed debugging in both online and offline modes. During my analysis, I identified two suspected URLs:

  1. The first URL appears to be related to issue 9434, which you already mentioned, where an error occurs with ExtensionBundles. However, this URL is only being captured in online mode.
    image
  2. The second URL is associated with 'devstoreaccount', which is causing errors in both online and offline modes.
    image

Beyond these, I did not observe and significant issues, if anything else you would suggest I explore or if there are further steps you would recommend, please let me know.

@umangsriv
Copy link
Contributor

Hey @kshyju, could you please provide an update so we can proceed?

@umangsriv
Copy link
Contributor

Hi @kshyju , I wanted to provide an update on the offline mode issue I've been investigating and seek some guidance on the best approach to move forward.

Issue Summary :

The core problem arises when trying to run 'func start' in offline mode, as certain components in the application continue to make network calls to external resources, specifically to 'functionscdn.azureedge.net'.

Example :

A host error has occurred during startup operation '647a2997-d85f-4c99-9bac-49186e155f1d'.
[2024-11-04T11:56:26.811Z] Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. System.Net.Http: No such host is known. (functionscdn.azureedge.net:443). System.Net.Sockets: No such host is known.

Findings

Network Dependencies in multiple components like:

  • 'GetExtensionBundle' method, which calls the ExtensionBundleManager, is one of the sources of this issue, this method attempts to retrieve bundles from a CDN path, causing the application to fail in offline mode. [Line 454 and 456 : https://github.com/Azure/azure-functions-core-tools/blob/v4.x/src/Azure.Functions.Cli/Actions/HostActions/StartHostAction.cs]

  • host.RunAsync() in IWebHost, where it seems that network dependencies are embedded within the startup configuration of 'IWebHost', application attempts to resolve certain configurations online, leading to similar connection failures in offline mode.

Proposed Solution

Mocking or Bypass Network Dependencies:

  • Incorporate caching, for components like 'ExtensionBundleManager', we could consider adding a mechanism to download and store the required resources locally when online, then load these from a local path in offline mode.

  • Similarly, for configurations in IWebHost (such as host.RunAsync()), we could explore mocking-dependent services or configurations in offline mode, possibly using a condition to switch implementations based on network availability.

I would appreciate any guidance or suggestions on ensuring we address offline mode compatibility comprehensively. Additionally, if there are existing strategies or preferred practices for handling offline mode, insights on those would be very helpful.

@liliankasem
Copy link
Member

@kshyju just a heads up that there are updates here! Thanks :)

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

No branches or pull requests

4 participants