File tree Expand file tree Collapse file tree 2 files changed +19
-11
lines changed
WebJobs.Script.WebHost/App_Start Expand file tree Collapse file tree 2 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ private static WebHostSettings GetDefaultSettings()
117117 bool isLocal = string . IsNullOrEmpty ( home ) ;
118118 if ( isLocal )
119119 {
120- settings . ScriptPath = Path . Combine ( HostingEnvironment . ApplicationPhysicalPath , @"..\..\sample ") ;
120+ settings . ScriptPath = Environment . GetEnvironmentVariable ( "AzureWebJobsScriptRoot ") ;
121121 settings . LogPath = Path . Combine ( Path . GetTempPath ( ) , @"Functions" ) ;
122122 settings . SecretsPath = HttpContext . Current . Server . MapPath ( "~/App_Data/Secrets" ) ;
123123 }
@@ -129,6 +129,11 @@ private static WebHostSettings GetDefaultSettings()
129129 settings . SecretsPath = Path . Combine ( home , @"data\Functions\secrets" ) ;
130130 }
131131
132+ if ( string . IsNullOrEmpty ( settings . ScriptPath ) )
133+ {
134+ throw new InvalidOperationException ( "Unable to determine function script root directory." ) ;
135+ }
136+
132137 return settings ;
133138 }
134139 }
Original file line number Diff line number Diff line change @@ -144,6 +144,8 @@ public override async Task BindAsync(BindingContext context)
144144 }
145145 else
146146 {
147+ string json = null ;
148+
147149 if ( ! string . IsNullOrEmpty ( boundPartitionKey ) &&
148150 ! string . IsNullOrEmpty ( boundRowKey ) )
149151 {
@@ -152,11 +154,7 @@ public override async Task BindAsync(BindingContext context)
152154 DynamicTableEntity tableEntity = await context . Binder . BindAsync < DynamicTableEntity > ( runtimeContext ) ;
153155 if ( tableEntity != null )
154156 {
155- string json = ConvertEntityToJObject ( tableEntity ) . ToString ( ) ;
156- using ( StreamWriter sw = new StreamWriter ( valueStream ) )
157- {
158- await sw . WriteAsync ( json ) ;
159- }
157+ json = ConvertEntityToJObject ( tableEntity ) . ToString ( ) ;
160158 }
161159 }
162160 else
@@ -172,11 +170,16 @@ public override async Task BindAsync(BindingContext context)
172170 entityArray . Add ( ConvertEntityToJObject ( entity ) ) ;
173171 }
174172
175- string json = entityArray . ToString ( Formatting . None ) ;
176- using ( StreamWriter sw = new StreamWriter ( valueStream ) )
177- {
178- await sw . WriteAsync ( json ) ;
179- }
173+ json = entityArray . ToString ( Formatting . None ) ;
174+ }
175+
176+ if ( json != null )
177+ {
178+ // We're explicitly NOT disposing the StreamWriter because
179+ // we don't want to close the underlying Stream
180+ StreamWriter sw = new StreamWriter ( valueStream ) ;
181+ await sw . WriteAsync ( json ) ;
182+ sw . Flush ( ) ;
180183 }
181184 }
182185 }
You can’t perform that action at this time.
0 commit comments