File tree Expand file tree Collapse file tree 2 files changed +13
-2
lines changed
src/WebJobs.Script.WebHost
test/WebJobs.Script.Tests Expand file tree Collapse file tree 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ private StartupContext GetStartupContextOrNull()
104
104
{
105
105
try
106
106
{
107
+ contextPath = Environment . ExpandEnvironmentVariables ( contextPath ) ;
107
108
_logger . LogDebug ( $ "Loading startup context from { contextPath } ") ;
108
109
string content = File . ReadAllText ( contextPath ) ;
109
110
Original file line number Diff line number Diff line change @@ -141,6 +141,15 @@ public void GetContext_InvalidPath_ReturnsNull()
141
141
VerifyLastLog ( LogLevel . Error , "Failed to load startup context" ) ;
142
142
}
143
143
144
+ [ Fact ]
145
+ public void GetContext_ExpandsEnvironmentVariables ( )
146
+ {
147
+ string path = Path . Combine ( "%TEMP%" , $ "{ Guid . NewGuid ( ) } .txt") ;
148
+ WriteStartupContext ( path : path ) ;
149
+
150
+ Assert . NotNull ( _startupContextProvider . Context ) ;
151
+ }
152
+
144
153
[ Fact ]
145
154
public void GetContext_EnvVarNotSet_ReturnsNull ( )
146
155
{
@@ -193,9 +202,10 @@ public void SetContext_AppliesHostAssignmentContext()
193
202
Assert . Equal ( _secrets . Host . System , secrets . SystemKeys ) ;
194
203
}
195
204
196
- private string WriteStartupContext ( string context = null )
205
+ private string WriteStartupContext ( string context = null , string path = null )
197
206
{
198
- var path = Path . Combine ( Path . GetTempPath ( ) , $ "{ Guid . NewGuid ( ) } .txt") ;
207
+ path = path ?? Path . Combine ( Path . GetTempPath ( ) , $ "{ Guid . NewGuid ( ) } .txt") ;
208
+ path = Environment . ExpandEnvironmentVariables ( path ) ;
199
209
_environment . SetEnvironmentVariable ( EnvironmentSettingNames . AzureWebsiteStartupContextCache , path ) ;
200
210
201
211
if ( context == null )
You can’t perform that action at this time.
0 commit comments