Open mbartenschlag opened 1 year ago
Any update on this?
I am often developing locally without an internet connection and can not run the functions at all (I have to wait until connection comes back online). From a developer's point of view it would be nice to use the already downloaded extension bundles that I have already installed on my machine and not completely fail when trying to get the latest online.
Hoping this gets fixed :)
Hi all,
I agree a solution is needed, I can't test locally while traveling. Any updates?
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.
The
func host start
command unnecessarily fails when not connected to the internet. This is trivial to reproduce:func new --name "HttpTrigger" --template "HTTP Trigger"
within that directory. Choosepython
when prompted.func host start --verbose
while connected to the internet.func host start --verbose
again.While disconnected from the internet, the second
func host start
fails even though the function has everything it needs to run locally. The specific issue is that even though a version of theMicrosoft.Azure.Functions.ExtensionBundle
is found, a call goes out to https://functionscdn.azureedge.net/public/ExtensionBundles/Microsoft.Azure.Functions.ExtensionBundle/index.json anyway to see if the found version is the latest version.This is shown in the logs below. In the first execution of
func host start --verbose
, we see:After disconnecting from the internet, we get:
This is a bug based on a bad assumption - not all development and test environments are connected to the internet. If a matching version of the ExtensionBundle is found, failing to determine if the found version is the latest version should emit a warning if internet connectivity is unavailable.
Version information provided below:
Attempted Workarounds
❌ Removing the bundle from host.json is not an option because the real-world scenario involves durable functions where the bindings provided by the bundle are required. Manually including the extensions via the Azure Core Tools CLI is not an option as that attempts to reach out to nuget.org. ❌ Specifying
"version": "=3.17.0"
orversion": "==3.17.0"
inhost.json
prior tofunc host start
fails as those values are recognized as invalid. ❌ Specifying"version": "3.17.0"
inhost.json
instead of a version range prior to startup surprisingly attempts to retrieve version 4.0.2 of the bundle without error or warning. This may be a bug - I haven't looked at the documentation for this value. ❌ Specifying"version": "[3.17.0, 3.17.0]"
inhost.json
after that version has already been downloaded does not prevent latest version checks - even though it already found the exact version we wanted.