Skip to content

Commit

Permalink
V4: Increase extension bundle download timeout (#3185)
Browse files Browse the repository at this point in the history
* Increase extension bundle download timeout

* - Increased time to 10 mins

- Moved the call in the condition in TemplatesManager.
  • Loading branch information
khkh-ms authored Oct 27, 2022
1 parent 2b1102b commit 9046059
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Threading.Tasks;
using Azure.Functions.Cli.Common;
using Azure.Functions.Cli.Diagnostics;
using Azure.Functions.Cli.ExtensionBundle;
using Azure.Functions.Cli.Extensions;
using Azure.Functions.Cli.Helpers;
using Azure.Functions.Cli.Interfaces;
Expand Down Expand Up @@ -369,9 +370,9 @@ public override async Task RunAsync()

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

await ExtensionBundleHelper.GetExtensionBundle();
IWebHost host = await BuildWebHost(hostOptions, listenUri, baseUri, certificate);
var runTask = host.RunAsync();

var hostService = host.Services.GetRequiredService<WebJobsScriptHostService>();

await hostService.DelayUntilHostReady();
Expand Down
1 change: 1 addition & 0 deletions src/Azure.Functions.Cli/Common/TemplatesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private static async Task<IEnumerable<Template>> GetTemplates()

if(extensionBundleManager.IsExtensionBundleConfigured())
{
await ExtensionBundleHelper.GetExtensionBundle();
var contentProvider = ExtensionBundleHelper.GetExtensionBundleContentProvider();
templatesJson = await contentProvider.GetTemplates();
}
Expand Down
21 changes: 21 additions & 0 deletions src/Azure.Functions.Cli/ExtensionBundle/ExtensionBundleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using Microsoft.Extensions.Logging.Abstractions;
using System;
using System.IO;
using System.Net.Http;
using System.Threading.Tasks;

namespace Azure.Functions.Cli.ExtensionBundle
{
Expand Down Expand Up @@ -42,5 +44,24 @@ public static string GetBundleDownloadPath(string bundleId)
{
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), Constants.UserCoreToolsDirectory, "Functions", ScriptConstants.ExtensionBundleDirectory, bundleId);
}

public static async Task GetExtensionBundle()
{
var extensionBundleManager = GetExtensionBundleManager();
try
{
using (var httpClient = new HttpClient())
{
httpClient.Timeout = TimeSpan.FromMinutes(10);
await extensionBundleManager.GetExtensionBundlePath(httpClient);
}
}
catch (Exception)
{
// Don't do anything here.
// There will be another attempt by the host to download the Extension Bundle.
// If Extension Bundle download fails again in the host then the host will return the appropriate customer facing error.
}
}
}
}

0 comments on commit 9046059

Please sign in to comment.