Skip to content

Commit 9046059

Browse files
authored
V4: Increase extension bundle download timeout (#3185)
* Increase extension bundle download timeout * - Increased time to 10 mins - Moved the call in the condition in TemplatesManager.
1 parent 2b1102b commit 9046059

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

src/Azure.Functions.Cli/Actions/HostActions/StartHostAction.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading.Tasks;
99
using Azure.Functions.Cli.Common;
1010
using Azure.Functions.Cli.Diagnostics;
11+
using Azure.Functions.Cli.ExtensionBundle;
1112
using Azure.Functions.Cli.Extensions;
1213
using Azure.Functions.Cli.Helpers;
1314
using Azure.Functions.Cli.Interfaces;
@@ -369,9 +370,9 @@ public override async Task RunAsync()
369370

370371
(var listenUri, var baseUri, var certificate) = await Setup();
371372

373+
await ExtensionBundleHelper.GetExtensionBundle();
372374
IWebHost host = await BuildWebHost(hostOptions, listenUri, baseUri, certificate);
373375
var runTask = host.RunAsync();
374-
375376
var hostService = host.Services.GetRequiredService<WebJobsScriptHostService>();
376377

377378
await hostService.DelayUntilHostReady();

src/Azure.Functions.Cli/Common/TemplatesManager.cs

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ private static async Task<IEnumerable<Template>> GetTemplates()
3636

3737
if(extensionBundleManager.IsExtensionBundleConfigured())
3838
{
39+
await ExtensionBundleHelper.GetExtensionBundle();
3940
var contentProvider = ExtensionBundleHelper.GetExtensionBundleContentProvider();
4041
templatesJson = await contentProvider.GetTemplates();
4142
}

src/Azure.Functions.Cli/ExtensionBundle/ExtensionBundleHelper.cs

+21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
using Microsoft.Extensions.Logging.Abstractions;
88
using System;
99
using System.IO;
10+
using System.Net.Http;
11+
using System.Threading.Tasks;
1012

1113
namespace Azure.Functions.Cli.ExtensionBundle
1214
{
@@ -42,5 +44,24 @@ public static string GetBundleDownloadPath(string bundleId)
4244
{
4345
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), Constants.UserCoreToolsDirectory, "Functions", ScriptConstants.ExtensionBundleDirectory, bundleId);
4446
}
47+
48+
public static async Task GetExtensionBundle()
49+
{
50+
var extensionBundleManager = GetExtensionBundleManager();
51+
try
52+
{
53+
using (var httpClient = new HttpClient())
54+
{
55+
httpClient.Timeout = TimeSpan.FromMinutes(10);
56+
await extensionBundleManager.GetExtensionBundlePath(httpClient);
57+
}
58+
}
59+
catch (Exception)
60+
{
61+
// Don't do anything here.
62+
// There will be another attempt by the host to download the Extension Bundle.
63+
// If Extension Bundle download fails again in the host then the host will return the appropriate customer facing error.
64+
}
65+
}
4566
}
4667
}

0 commit comments

Comments
 (0)