Skip to content

Commit 9e3c669

Browse files
krishnajajuKrishna Jaju
andauthored
FileSystemReadOnly when functions running in ACA environment (#11338)
* FileSystemReadOnly when functions running in ACA environment * add UT * minor change * revert minor change --------- Co-authored-by: Krishna Jaju <[email protected]>
1 parent 7c3c86d commit 9e3c669

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
@@ -80,6 +80,13 @@ private bool IsZipDeployment(out bool isScmRunFromPackage)
8080
return true;
8181
}
8282

83+
// Functions on Container Apps always have a read-only filesystem
84+
if (_environment.IsManagedAppEnvironment())
85+
{
86+
isScmRunFromPackage = false;
87+
return true;
88+
}
89+
8390
// Check app settings for run from package.
8491
bool runFromPkgConfigured = Utility.IsValidZipSetting(_environment.GetEnvironmentVariable(AzureWebsiteZipDeployment)) ||
8592
Utility.IsValidZipSetting(_environment.GetEnvironmentVariable(AzureWebsiteAltZipDeployment)) ||

src/WebJobs.Script/Environment/EnvironmentExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ public static bool IsAnyKubernetesEnvironment(this IEnvironment environment)
305305
}
306306

307307
/// <summary>
308-
/// Gets a value indicating whether the application is running in Managed App environment.
308+
/// Gets a value indicating whether the application is running in Managed App environment (Azure Container Apps environment).
309309
/// </summary>
310310
/// <param name="environment">The environment to verify.</param>
311311
/// <returns><see cref="true"/> if running in Managed App environment; otherwise, false.</returns>

test/WebJobs.Script.Tests/Configuration/ScriptApplicationHostOptionsSetupTests.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
@@ -113,6 +113,18 @@ public void IsFileSystemReadOnly_AlwaysAppliesForFlex()
113113
Assert.Equal(options.IsFileSystemReadOnly, true);
114114
}
115115

116+
[Fact]
117+
public void IsFileSystemReadOnly_AlwaysAppliesForContainerAppsEnvironment()
118+
{
119+
var environment = new TestEnvironment();
120+
environment.SetEnvironmentVariable(EnvironmentSettingNames.ManagedEnvironment, "true");
121+
122+
ScriptApplicationHostOptions options = new ScriptApplicationHostOptions();
123+
ConfiguredOptions(options, inStandbyMode: false, environment);
124+
125+
Assert.Equal(options.IsFileSystemReadOnly, true);
126+
}
127+
116128
private void ConfiguredOptions(ScriptApplicationHostOptions options, bool inStandbyMode, IEnvironment environment = null, bool blobExists = false)
117129
{
118130
var builder = new ConfigurationBuilder();

0 commit comments

Comments
 (0)