Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.32k stars 435 forks source link

Running local functions fails without internet connection #2060

Open milesfrain opened 4 years ago

milesfrain commented 4 years ago

I cannot run local Azure functions while offline.

Initial setup with internet connection

func init myapp --worker-runtime node --language javascript
cd myapp
npm install
func new --name HttpExample --template "HTTP trigger"
func host start

The above commands work fine. But then if I go offline and re-run func host start, I encounter this error:

Looking for extension bundle Microsoft.Azure.Functions.ExtensionBundle at /tmp/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle
[6/23/20 6:12:26 PM] Found a matching extension bundle at /tmp/Functions/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/1.1.1
[6/23/20 6:12:26 PM] Fetching information on versions of extension bundle Microsoft.Azure.Functions.ExtensionBundle available on https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/index.json
[6/23/20 6:12:26 PM] A host error has occurred during startup operation 'fd540883-3fd6-457a-a864-29232c8e703f'.
[6/23/20 6:12:26 PM] System.Net.Http: No such device or address. System.Private.CoreLib: No such device or address.
Value cannot be null.
Parameter name: provider
Application is shutting down...

Version Info

$ func --version 
2.7.2508
$ node --version
v10.21.0
$ lsb_release -d
Description:    Ubuntu 20.04 LTS
anthonychu commented 4 years ago

@soninaren Do you think we can skip this check if there's no internet connection?

soninaren commented 4 years ago

Yes, we should skip bundle load check when there is no internet.

frarteaga commented 3 years ago

Yes, we should skip bundle load check when there is no internet.

When this change is available?

fsudderthrenfroe commented 2 years ago

Is this being worked on?

akibrk commented 2 years ago

Any update on this?

iancoetzer commented 1 year ago

Hi, I am having a similar issue while trying to debug offline. But my error message is slightly different:

[2023-04-19T16:34:23.264Z] A host error has occurred during startup operation '885dde36-fb96-4440-a98b-d4499664b3b4'. [2023-04-19T16:34:23.272Z] System.Net.Http: No such host is known. (functionscdn.azureedge.net:443). System.Net.Sockets: No such host is known. Value cannot be null. (Parameter 'provider')

piotr-napadlek commented 1 year ago

I understand that working on triggers like servicebus etc. would require an internet connection, but when I'm running azurite and want my function only to implement http endpoints and write to DevelopmentMode storage (also disabled appinsights logging), why would I require to be connected to internet? Any update on this?

iancoetzer commented 1 year ago

Hi, this is something that is also on my radar.

I do not myself understand why we must be connected to the internet to debug a local function which makes use of local storage?

nawafmkutty commented 1 year ago

Any updates on this issue?

The Url "functionscdn.azureedge.net" is unreachable even with the internet access.

[2023-08-14T08:44:14.742Z] Error building configuration in an external startup class. [2023-08-14T08:44:14.743Z] Error building configuration in an external startup class. System.Net.Http: Network is unreachable (functionscdn.azureedge.net:443). System.Net.Sockets: Network is unreachable. [2023-08-14T08:44:14.777Z] A host error has occurred during startup operation '7d6327e8-4f64-4706-b6c0-32c52a2fa6ab'. [2023-08-14T08:44:14.778Z] Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. System.Net.Http: Network is unreachable (functionscdn.azureedge.net:443). System.Net.Sockets: Network is unreachable. Value cannot be null. (Parameter 'provider') [2023-08-14T08:44:14.826Z] Host startup operation has been canceled

offbeatful commented 1 year ago

So for anyone who is looking for a solution to run their functions without Internet access:

I was required to remove extensionBundle section from host.json file. Why does this work?

It seems there is a code introduced in src/Azure.Functions.Cli/Actions/HostActions/Startup.cs that will check if extensionBundle is defined and if it is, it will set environment variables to check for latest version.

private void SetBundlesEnvironmentVariables()
{
    var bundleId = ExtensionBundleHelper.GetExtensionBundleOptions(_hostOptions).Id;
    if (!string.IsNullOrEmpty(bundleId))
    {
        Environment.SetEnvironmentVariable("AzureFunctionsJobHost__extensionBundle__downloadPath", ExtensionBundleHelper.GetBundleDownloadPath(bundleId));
        Environment.SetEnvironmentVariable("AzureFunctionsJobHost__extensionBundle__ensureLatest", "true");
    }
}

That code was actually introduced as part of another issues:

  // workaround for https://github.com/Azure/azure-functions-core-tools/issues/2097
  SetBundlesEnvironmentVariables();

I am running javascript functions and I confirmed that this section is not required for Development Model 4 when deploying in Azure. So extensionBundle section can be safely removed.

KuSh commented 4 months ago

I am running javascript functions and I confirmed that this section is not required for Development Model 4 when deploying in Azure. So extensionBundle section can be safely removed.

Unfortunately, this workaround only works if you don't use extensions. I use durable functions and this problem is a real blocker

[2024-06-20T16:07:58.639Z] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
[2024-06-20T16:07:58.685Z] The 'aaa' function is in error: The binding type(s) 'queueTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.
[2024-06-20T16:07:58.686Z] The 'bbb' function is in error: The binding type(s) 'activityTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.
[2024-06-20T16:07:58.686Z] The 'ccc' function is in error: The binding type(s) 'orchestrationClient' are not registered. Please ensure the type is correct and the binding extension is installed.
[2024-06-20T16:07:58.686Z] The 'ddd' function is in error: The binding type(s) 'orchestrationTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.
perenna-dan commented 3 months ago

I am too experiencing this issue. The point of local development should not require internet checks.