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()
117
117
bool isLocal = string . IsNullOrEmpty ( home ) ;
118
118
if ( isLocal )
119
119
{
120
- settings . ScriptPath = Path . Combine ( HostingEnvironment . ApplicationPhysicalPath , @"..\..\sample ") ;
120
+ settings . ScriptPath = Environment . GetEnvironmentVariable ( "AzureWebJobsScriptRoot ") ;
121
121
settings . LogPath = Path . Combine ( Path . GetTempPath ( ) , @"Functions" ) ;
122
122
settings . SecretsPath = HttpContext . Current . Server . MapPath ( "~/App_Data/Secrets" ) ;
123
123
}
@@ -129,6 +129,11 @@ private static WebHostSettings GetDefaultSettings()
129
129
settings . SecretsPath = Path . Combine ( home , @"data\Functions\secrets" ) ;
130
130
}
131
131
132
+ if ( string . IsNullOrEmpty ( settings . ScriptPath ) )
133
+ {
134
+ throw new InvalidOperationException ( "Unable to determine function script root directory." ) ;
135
+ }
136
+
132
137
return settings ;
133
138
}
134
139
}
Original file line number Diff line number Diff line change @@ -144,6 +144,8 @@ public override async Task BindAsync(BindingContext context)
144
144
}
145
145
else
146
146
{
147
+ string json = null ;
148
+
147
149
if ( ! string . IsNullOrEmpty ( boundPartitionKey ) &&
148
150
! string . IsNullOrEmpty ( boundRowKey ) )
149
151
{
@@ -152,11 +154,7 @@ public override async Task BindAsync(BindingContext context)
152
154
DynamicTableEntity tableEntity = await context . Binder . BindAsync < DynamicTableEntity > ( runtimeContext ) ;
153
155
if ( tableEntity != null )
154
156
{
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 ( ) ;
160
158
}
161
159
}
162
160
else
@@ -172,11 +170,16 @@ public override async Task BindAsync(BindingContext context)
172
170
entityArray . Add ( ConvertEntityToJObject ( entity ) ) ;
173
171
}
174
172
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 ( ) ;
180
183
}
181
184
}
182
185
}
You can’t perform that action at this time.
0 commit comments