7
7
using System . Linq ;
8
8
using System . Net . Http ;
9
9
using System . Threading . Tasks ;
10
- using Azure ;
11
- using Azure . Core ;
12
10
using Microsoft . AspNetCore . Http ;
11
+ using Microsoft . Azure . WebJobs . Script . Config ;
13
12
using Microsoft . Azure . WebJobs . Script . Description ;
14
13
using Microsoft . Azure . WebJobs . Script . Management . Models ;
15
14
using Microsoft . Azure . WebJobs . Script . WebHost . Extensions ;
16
15
using Microsoft . Azure . WebJobs . Script . Workers . Rpc ;
17
- using Microsoft . Extensions . DependencyInjection ;
18
16
using Microsoft . Extensions . Logging ;
19
17
using Microsoft . Extensions . Options ;
20
18
using Newtonsoft . Json ;
@@ -33,9 +31,10 @@ public class WebFunctionsManager : IWebFunctionsManager
33
31
private readonly IFunctionMetadataManager _functionMetadataManager ;
34
32
private readonly IHostFunctionMetadataProvider _hostFunctionMetadataProvider ;
35
33
private readonly IOptionsMonitor < LanguageWorkerOptions > _languageWorkerOptions ;
34
+ private readonly IOptionsMonitor < FunctionsHostingConfigOptions > _hostingConfigOptions ;
36
35
37
36
public WebFunctionsManager ( IOptionsMonitor < ScriptApplicationHostOptions > applicationHostOptions , ILoggerFactory loggerFactory , IHttpClientFactory httpClientFactory , ISecretManagerProvider secretManagerProvider , IFunctionsSyncManager functionsSyncManager , HostNameProvider hostNameProvider , IFunctionMetadataManager functionMetadataManager , IHostFunctionMetadataProvider hostFunctionMetadataProvider ,
38
- IOptionsMonitor < LanguageWorkerOptions > languageWorkerOptions )
37
+ IOptionsMonitor < LanguageWorkerOptions > languageWorkerOptions , IOptionsMonitor < FunctionsHostingConfigOptions > hostingConfigOptions )
39
38
{
40
39
_applicationHostOptions = applicationHostOptions ;
41
40
_logger = loggerFactory ? . CreateLogger ( ScriptConstants . LogCategoryHostGeneral ) ;
@@ -46,21 +45,22 @@ public WebFunctionsManager(IOptionsMonitor<ScriptApplicationHostOptions> applica
46
45
_functionMetadataManager = functionMetadataManager ;
47
46
_hostFunctionMetadataProvider = hostFunctionMetadataProvider ;
48
47
_languageWorkerOptions = languageWorkerOptions ;
48
+ _hostingConfigOptions = hostingConfigOptions ;
49
49
}
50
50
51
51
public async Task < IEnumerable < FunctionMetadataResponse > > GetFunctionsMetadata ( bool includeProxies )
52
52
{
53
53
var hostOptions = _applicationHostOptions . CurrentValue . ToHostOptions ( ) ;
54
54
var functionsMetadata = GetFunctionsMetadata ( includeProxies , forceRefresh : false ) ;
55
55
56
- return await GetFunctionMetadataResponse ( functionsMetadata , hostOptions , _hostNameProvider ) ;
56
+ return await GetFunctionMetadataResponse ( functionsMetadata , hostOptions , _hostNameProvider , excludeTestData : _hostingConfigOptions . CurrentValue . IsTestDataSuppressionEnabled ) ;
57
57
}
58
58
59
- internal static async Task < IEnumerable < FunctionMetadataResponse > > GetFunctionMetadataResponse ( IEnumerable < FunctionMetadata > functionsMetadata , ScriptJobHostOptions hostOptions , HostNameProvider hostNameProvider )
59
+ internal static async Task < IEnumerable < FunctionMetadataResponse > > GetFunctionMetadataResponse ( IEnumerable < FunctionMetadata > functionsMetadata , ScriptJobHostOptions hostOptions , HostNameProvider hostNameProvider , bool excludeTestData )
60
60
{
61
61
string baseUrl = GetBaseUrl ( hostNameProvider ) ;
62
62
string routePrefix = await GetRoutePrefix ( hostOptions . RootScriptPath ) ;
63
- var tasks = functionsMetadata . Select ( p => p . ToFunctionMetadataResponse ( hostOptions , routePrefix , baseUrl ) ) ;
63
+ var tasks = functionsMetadata . Select ( p => p . ToFunctionMetadataResponse ( hostOptions , routePrefix , baseUrl , excludeTestData ) ) ;
64
64
65
65
return await tasks . WhenAll ( ) ;
66
66
}
@@ -148,7 +148,7 @@ await functionMetadata
148
148
configChanged = true ;
149
149
}
150
150
151
- if ( functionMetadata . TestData != null )
151
+ if ( functionMetadata . TestData != null && ! _hostingConfigOptions . CurrentValue . IsTestDataSuppressionEnabled )
152
152
{
153
153
await FileUtility . WriteAsync ( dataFilePath , functionMetadata . TestData ) ;
154
154
}
@@ -161,7 +161,7 @@ await functionMetadata
161
161
FunctionMetadataResponse functionMetadataResult = null ;
162
162
if ( metadata != null )
163
163
{
164
- functionMetadataResult = await GetFunctionMetadataResponseAsync ( metadata , hostOptions , request ) ;
164
+ functionMetadataResult = await GetFunctionMetadataResponseAsync ( metadata , hostOptions , request , _hostingConfigOptions . CurrentValue . IsTestDataSuppressionEnabled ) ;
165
165
success = true ;
166
166
}
167
167
@@ -197,7 +197,7 @@ await functionMetadata
197
197
198
198
if ( functionMetadata != null )
199
199
{
200
- var functionMetadataResponse = await GetFunctionMetadataResponseAsync ( functionMetadata , hostOptions , request ) ;
200
+ var functionMetadataResponse = await GetFunctionMetadataResponseAsync ( functionMetadata , hostOptions , request , _hostingConfigOptions . CurrentValue . IsTestDataSuppressionEnabled ) ;
201
201
return ( true , functionMetadataResponse ) ;
202
202
}
203
203
else
@@ -245,11 +245,11 @@ private void DeleteFunctionArtifacts(FunctionMetadataResponse function)
245
245
}
246
246
}
247
247
248
- private static async Task < FunctionMetadataResponse > GetFunctionMetadataResponseAsync ( FunctionMetadata functionMetadata , ScriptJobHostOptions hostOptions , HttpRequest request )
248
+ private async Task < FunctionMetadataResponse > GetFunctionMetadataResponseAsync ( FunctionMetadata functionMetadata , ScriptJobHostOptions hostOptions , HttpRequest request , bool excludeTestData )
249
249
{
250
250
string routePrefix = await GetRoutePrefix ( hostOptions . RootScriptPath ) ;
251
251
var baseUrl = $ "{ request . Scheme } ://{ request . Host } ";
252
- return await functionMetadata . ToFunctionMetadataResponse ( hostOptions , routePrefix , baseUrl ) ;
252
+ return await functionMetadata . ToFunctionMetadataResponse ( hostOptions , routePrefix , baseUrl , excludeTestData ) ;
253
253
}
254
254
255
255
// TODO : Due to lifetime scoping issues (this service lifetime is longer than the lifetime
0 commit comments