Skip to content

Commit 4af158f

Browse files
committed
Updating environment extension method names for clarity
1 parent ccb0e84 commit 4af158f

29 files changed

+158
-121
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public async Task<IActionResult> SetState([FromBody] string state)
239239
}
240240
else if (desiredState == ScriptHostState.Running && currentState == ScriptHostState.Offline)
241241
{
242-
if (_environment.FileSystemIsReadOnly())
242+
if (_environment.IsFileSystemReadOnly())
243243
{
244244
return BadRequest();
245245
}
@@ -249,7 +249,7 @@ public async Task<IActionResult> SetState([FromBody] string state)
249249
}
250250
else if (desiredState == ScriptHostState.Offline && currentState != ScriptHostState.Offline)
251251
{
252-
if (_environment.FileSystemIsReadOnly())
252+
if (_environment.IsFileSystemReadOnly())
253253
{
254254
return BadRequest();
255255
}
@@ -278,7 +278,7 @@ public async Task<IActionResult> SetState([FromBody] string state)
278278
[Authorize(Policy = PolicyNames.AdminAuthLevel)]
279279
public IActionResult GetAdminToken()
280280
{
281-
if (!_environment.IsLinuxContainerEnvironment())
281+
if (!_environment.IsLinuxConsumption())
282282
{
283283
return BadRequest("Endpoint is only available when running in Linux Container");
284284
}

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
@@ -59,9 +59,9 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args = null)
5959

6060
config.Add(new WebScriptHostConfigurationSource
6161
{
62-
IsAppServiceEnvironment = SystemEnvironment.Instance.IsAppServiceEnvironment(),
63-
IsLinuxContainerEnvironment = SystemEnvironment.Instance.IsLinuxContainerEnvironment(),
64-
IsLinuxAppServiceEnvironment = SystemEnvironment.Instance.IsLinuxAppServiceEnvironment()
62+
IsAppServiceEnvironment = SystemEnvironment.Instance.IsAppService(),
63+
IsLinuxContainerEnvironment = SystemEnvironment.Instance.IsLinuxConsumption(),
64+
IsLinuxAppServiceEnvironment = SystemEnvironment.Instance.IsLinuxAppService()
6565
});
6666
})
6767
.ConfigureLogging((context, loggingBuilder) =>
@@ -80,7 +80,7 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args = null)
8080
/// </summary>
8181
private static void InitializeProcess()
8282
{
83-
if (SystemEnvironment.Instance.IsLinuxContainerEnvironment())
83+
if (SystemEnvironment.Instance.IsLinuxConsumption())
8484
{
8585
// Linux containers always start out in placeholder mode
8686
SystemEnvironment.Instance.SetEnvironmentVariable(EnvironmentSettingNames.AzureWebsitePlaceholderMode, "1");
@@ -94,7 +94,7 @@ private static void InitializeProcess()
9494
SystemEnvironment.Instance.SetEnvironmentVariable(DataProtectionCostants.AzureWebsiteEnvironmentMachineKey, authEncryptionKey);
9595
}
9696

97-
ConfigureMinimumThreads(SystemEnvironment.Instance.IsDynamic());
97+
ConfigureMinimumThreads(SystemEnvironment.Instance.IsWindowsConsumption());
9898
}
9999

100100
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
@@ -85,11 +85,11 @@ public static void AddWebJobsScriptHost(this IServiceCollection services, IConfi
8585
services.AddSingleton<IEventGenerator>(p =>
8686
{
8787
var environment = p.GetService<IEnvironment>();
88-
if (environment.IsLinuxContainerEnvironment())
88+
if (environment.IsLinuxConsumption())
8989
{
9090
return new LinuxContainerEventGenerator(environment);
9191
}
92-
else if (SystemEnvironment.Instance.IsLinuxAppServiceEnvironment())
92+
else if (SystemEnvironment.Instance.IsLinuxAppService())
9393
{
9494
return new LinuxAppServiceEventGenerator(new LinuxAppServiceFileLoggerFactory());
9595
}
@@ -161,7 +161,7 @@ private static void AddLinuxContainerServices(this IServiceCollection services)
161161
services.AddSingleton<IHostedService>(s =>
162162
{
163163
var environment = s.GetService<IEnvironment>();
164-
if (environment.IsLinuxContainerEnvironment())
164+
if (environment.IsLinuxConsumption())
165165
{
166166
var instanceManager = s.GetService<IInstanceManager>();
167167
var logger = s.GetService<ILogger<LinuxContainerInitializationHostService>>();

0 commit comments

Comments
 (0)