Skip to content

Commit 4688fab

Browse files
committed
Merge branch 'dev' into v3.x
2 parents 8154d1d + 3a6577f commit 4688fab

32 files changed

+195
-158
lines changed

src/WebJobs.Script.WebHost/Configuration/HttpOptionsSetup.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ public HttpOptionsSetup(IEnvironment environment)
1919

2020
public void Configure(HttpOptions options)
2121
{
22-
if (_environment.IsDynamic())
22+
if (_environment.IsWindowsConsumption())
2323
{
2424
// when running under dynamic, we choose some default
2525
// throttle settings.
2626
// these can be overridden by the user in host.json
27-
if (_environment.IsAppServiceEnvironment())
27+
if (_environment.IsAppService())
2828
{
2929
// dynamic throttles are based on sandbox counters
3030
// which only exist in AppService

src/WebJobs.Script.WebHost/ContainerManagement/LinuxContainerInitializationHostService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public async Task StartAsync(CancellationToken cancellationToken)
3434
_cancellationToken = cancellationToken;
3535

3636
// The service should be registered in IsLinuxContainerEnvironment only. But do additional check here.
37-
if (_environment.IsLinuxContainerEnvironment())
37+
if (_environment.IsLinuxConsumption())
3838
{
3939
await ApplyContextIfPresent();
4040
}

src/WebJobs.Script.WebHost/Controllers/HostController.cs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
using Microsoft.Azure.WebJobs.Script.WebHost.Security;
2626
using Microsoft.Azure.WebJobs.Script.WebHost.Security.Authorization;
2727
using Microsoft.Azure.WebJobs.Script.WebHost.Security.Authorization.Policies;
28+
using Microsoft.Extensions.DependencyInjection;
2829
using Microsoft.Extensions.Logging;
2930
using Microsoft.Extensions.Options;
3031
using Newtonsoft.Json;
@@ -47,7 +48,6 @@ public class HostController : Controller
4748
private readonly IEnvironment _environment;
4849
private readonly IScriptHostManager _scriptHostManager;
4950
private readonly IFunctionsSyncManager _functionsSyncManager;
50-
private readonly IExtensionBundleManager _extensionBundleManager;
5151

5252
public HostController(IOptions<ScriptApplicationHostOptions> applicationHostOptions,
5353
IOptions<JobHostOptions> hostOptions,
@@ -56,8 +56,7 @@ public HostController(IOptions<ScriptApplicationHostOptions> applicationHostOpti
5656
IWebFunctionsManager functionsManager,
5757
IEnvironment environment,
5858
IScriptHostManager scriptHostManager,
59-
IFunctionsSyncManager functionsSyncManager,
60-
IExtensionBundleManager extensionBundleManager)
59+
IFunctionsSyncManager functionsSyncManager)
6160
{
6261
_applicationHostOptions = applicationHostOptions;
6362
_hostOptions = hostOptions;
@@ -67,14 +66,13 @@ public HostController(IOptions<ScriptApplicationHostOptions> applicationHostOpti
6766
_environment = environment;
6867
_scriptHostManager = scriptHostManager;
6968
_functionsSyncManager = functionsSyncManager;
70-
_extensionBundleManager = extensionBundleManager;
7169
}
7270

7371
[HttpGet]
7472
[Route("admin/host/status")]
7573
[Authorize(Policy = PolicyNames.AdminAuthLevelOrInternal)]
7674
[TypeFilter(typeof(EnableDebugModeFilter))]
77-
public async Task<IActionResult> GetHostStatus([FromServices] IScriptHostManager scriptHostManager, [FromServices] IHostIdProvider hostIdProvider)
75+
public async Task<IActionResult> GetHostStatus([FromServices] IScriptHostManager scriptHostManager, [FromServices] IHostIdProvider hostIdProvider, [FromServices] IServiceProvider serviceProvider = null)
7876
{
7977
var status = new HostStatus
8078
{
@@ -85,14 +83,18 @@ public async Task<IActionResult> GetHostStatus([FromServices] IScriptHostManager
8583
ProcessUptime = (long)(DateTime.UtcNow - Process.GetCurrentProcess().StartTime).TotalMilliseconds
8684
};
8785

88-
var bundleInfo = await _extensionBundleManager.GetExtensionBundleDetails();
89-
if (bundleInfo != null)
86+
var bundleManager = serviceProvider.GetService<IExtensionBundleManager>();
87+
if (bundleManager != null)
9088
{
91-
status.ExtensionBundle = new Models.ExtensionBundle()
89+
var bundleInfo = await bundleManager.GetExtensionBundleDetails();
90+
if (bundleInfo != null)
9291
{
93-
Id = bundleInfo.Id,
94-
Version = bundleInfo.Version
95-
};
92+
status.ExtensionBundle = new Models.ExtensionBundle()
93+
{
94+
Id = bundleInfo.Id,
95+
Version = bundleInfo.Version
96+
};
97+
}
9698
}
9799

98100
var lastError = scriptHostManager.LastError;
@@ -239,7 +241,7 @@ public async Task<IActionResult> SetState([FromBody] string state)
239241
}
240242
else if (desiredState == ScriptHostState.Running && currentState == ScriptHostState.Offline)
241243
{
242-
if (_environment.FileSystemIsReadOnly())
244+
if (_environment.IsFileSystemReadOnly())
243245
{
244246
return BadRequest();
245247
}
@@ -249,7 +251,7 @@ public async Task<IActionResult> SetState([FromBody] string state)
249251
}
250252
else if (desiredState == ScriptHostState.Offline && currentState != ScriptHostState.Offline)
251253
{
252-
if (_environment.FileSystemIsReadOnly())
254+
if (_environment.IsFileSystemReadOnly())
253255
{
254256
return BadRequest();
255257
}
@@ -278,7 +280,7 @@ public async Task<IActionResult> SetState([FromBody] string state)
278280
[Authorize(Policy = PolicyNames.AdminAuthLevel)]
279281
public IActionResult GetAdminToken()
280282
{
281-
if (!_environment.IsLinuxContainerEnvironment())
283+
if (!_environment.IsLinuxConsumption())
282284
{
283285
return BadRequest("Endpoint is only available when running in Linux Container");
284286
}

src/WebJobs.Script.WebHost/DependencyInjection/JobHostServiceProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private Container BuildContainer(IServiceCollection descriptors)
6363
// preferInterpretation will be set to true to significanly improve cold start in consumption mode
6464
// it will be set to false for premium and appservice plans to make sure throughput is not impacted
6565
// there is no throughput drop in consumption with this setting.
66-
var preferInterpretation = SystemEnvironment.Instance.IsDynamic() ? true : false;
66+
var preferInterpretation = SystemEnvironment.Instance.IsWindowsConsumption() ? true : false;
6767
var container = new Container(r => rules, preferInterpretation: preferInterpretation);
6868

6969
container.Populate(descriptors);

src/WebJobs.Script.WebHost/DependencyInjection/WebHostServiceProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public WebHostServiceProvider(IServiceCollection descriptors)
3232
// preferInterpretation will be set to true to significanly improve cold start in consumption mode
3333
// it will be set to false for premium and appservice plans to make sure throughput is not impacted
3434
// there is no throughput drop in consumption with this setting.
35-
var preferInterpretation = SystemEnvironment.Instance.IsDynamic() ? true : false;
35+
var preferInterpretation = SystemEnvironment.Instance.IsWindowsConsumption() ? true : false;
3636
_container = new Container(_defaultContainerRules, preferInterpretation: preferInterpretation);
3737
_container.Populate(descriptors);
3838
_container.UseInstance<IServiceProvider>(this);

src/WebJobs.Script.WebHost/Management/FunctionsSyncManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public async Task<SyncTriggersResult> TrySyncTriggersAsync(bool checkHash = fals
137137

138138
internal static bool IsSyncTriggersEnvironment(IScriptWebHostEnvironment webHostEnvironment, IEnvironment environment)
139139
{
140-
if (environment.IsCoreToolsEnvironment())
140+
if (environment.IsCoreTools())
141141
{
142142
// don't sync triggers when running locally or not running in a cloud
143143
// hosted environment
@@ -160,7 +160,7 @@ internal static bool IsSyncTriggersEnvironment(IScriptWebHostEnvironment webHost
160160

161161
// Windows (Dedicated/Consumption)
162162
// Linux Consumption
163-
if ((environment.IsAppServiceWindowsEnvironment() || environment.IsLinuxContainerEnvironment()) &&
163+
if ((environment.IsWindowsAzureManagedHosting() || environment.IsLinuxConsumption()) &&
164164
!environment.IsContainerReady())
165165
{
166166
// container ready flag not set yet – site not fully specialized/initialized

src/WebJobs.Script.WebHost/Middleware/HostWarmupMiddleware.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public async Task WarmUp(HttpRequest request)
4848
public static bool IsWarmUpRequest(HttpRequest request, IScriptWebHostEnvironment webHostEnvironment, IEnvironment environment)
4949
{
5050
return webHostEnvironment.InStandbyMode &&
51-
((environment.IsAppServiceEnvironment() && request.IsAppServiceInternalRequest(environment)) || environment.IsLinuxContainerEnvironment()) &&
51+
((environment.IsAppService() && request.IsAppServiceInternalRequest(environment)) || environment.IsLinuxConsumption()) &&
5252
(request.Path.StartsWithSegments(new PathString($"/api/{WarmUpConstants.FunctionName}")) ||
5353
request.Path.StartsWithSegments(new PathString($"/api/{WarmUpConstants.AlternateRoute}")));
5454
}

src/WebJobs.Script.WebHost/Program.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args = null)
6262

6363
config.Add(new WebScriptHostConfigurationSource
6464
{
65-
IsAppServiceEnvironment = SystemEnvironment.Instance.IsAppServiceEnvironment(),
66-
IsLinuxContainerEnvironment = SystemEnvironment.Instance.IsLinuxContainerEnvironment(),
67-
IsLinuxAppServiceEnvironment = SystemEnvironment.Instance.IsLinuxAppServiceEnvironment()
65+
IsAppServiceEnvironment = SystemEnvironment.Instance.IsAppService(),
66+
IsLinuxContainerEnvironment = SystemEnvironment.Instance.IsLinuxConsumption(),
67+
IsLinuxAppServiceEnvironment = SystemEnvironment.Instance.IsLinuxAppService()
6868
});
6969
})
7070
.ConfigureLogging((context, loggingBuilder) =>
@@ -83,7 +83,7 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args = null)
8383
/// </summary>
8484
private static void InitializeProcess()
8585
{
86-
if (SystemEnvironment.Instance.IsLinuxContainerEnvironment())
86+
if (SystemEnvironment.Instance.IsLinuxConsumption())
8787
{
8888
// Linux containers always start out in placeholder mode
8989
SystemEnvironment.Instance.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsitePlaceholderMode, "1");
@@ -97,7 +97,7 @@ private static void InitializeProcess()
9797
SystemEnvironment.Instance.SetEnvironmentVariable(DataProtectionCostants.AzureWebsiteEnvironmentMachineKey, authEncryptionKey);
9898
}
9999

100-
ConfigureMinimumThreads(SystemEnvironment.Instance.IsDynamic());
100+
ConfigureMinimumThreads(SystemEnvironment.Instance.IsWindowsConsumption());
101101
}
102102

103103
private static void ConfigureMinimumThreads(bool isDynamicSku)

src/WebJobs.Script.WebHost/Security/KeyManagement/DefaultKeyValueConverterFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ public DefaultKeyValueConverterFactory(bool allowEncryption)
2323

2424
private static bool IsEncryptionSupported()
2525
{
26-
return SystemEnvironment.Instance.IsAppServiceEnvironment() ||
27-
SystemEnvironment.Instance.IsLinuxContainerEnvironment() ||
26+
return SystemEnvironment.Instance.IsAppService() ||
27+
SystemEnvironment.Instance.IsLinuxConsumption() ||
2828
SystemEnvironment.Instance.GetEnvironmentVariable(AzureWebsiteLocalEncryptionKey) != null;
2929
}
3030

src/WebJobs.Script.WebHost/WebHostServiceCollectionExtensions.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ public static void AddWebJobsScriptHost(this IServiceCollection services, IConfi
8686
services.AddSingleton<IEventGenerator>(p =>
8787
{
8888
var environment = p.GetService<IEnvironment>();
89-
if (environment.IsLinuxContainerEnvironment())
89+
if (environment.IsLinuxConsumption())
9090
{
9191
return new LinuxContainerEventGenerator(environment);
9292
}
93-
else if (SystemEnvironment.Instance.IsLinuxAppServiceEnvironment())
93+
else if (SystemEnvironment.Instance.IsLinuxAppService())
9494
{
9595
return new LinuxAppServiceEventGenerator(new LinuxAppServiceFileLoggerFactory());
9696
}
@@ -162,7 +162,7 @@ private static void AddLinuxContainerServices(this IServiceCollection services)
162162
services.AddSingleton<IHostedService>(s =>
163163
{
164164
var environment = s.GetService<IEnvironment>();
165-
if (environment.IsLinuxContainerEnvironment())
165+
if (environment.IsLinuxConsumption())
166166
{
167167
var instanceManager = s.GetService<IInstanceManager>();
168168
var logger = s.GetService<ILogger<LinuxContainerInitializationHostService>>();

0 commit comments

Comments
 (0)