-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IngestionClient] Use Isolated Worker model in .Net 8.0 (#2482)
- Loading branch information
1 parent
b329c0a
commit 4c4f8ea
Showing
28 changed files
with
596 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
.vscode | ||
local.settings.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
...ingestion/ingestion-client/Connector/Extensions/AppInsightsServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// <copyright file="AppInsightsServiceCollectionExtensions.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace Connector | ||
{ | ||
using System.Linq; | ||
|
||
using Microsoft.Azure.Functions.Worker; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
/// <summary> | ||
/// Extension methods for configuring Application Insights. | ||
/// </summary> | ||
public static class AppInsightsServiceCollectionExtensions | ||
{ | ||
/// <summary> | ||
/// Configures the logger for the Ingestion Client and removes the default logging filter added by the Application Insights SDK. | ||
/// </summary> | ||
/// <param name="services">The Service Collection</param> | ||
/// <returns>The Service Collection</returns> | ||
public static IServiceCollection ConfigureIngestionClientLogging(this IServiceCollection services) | ||
{ | ||
services.AddApplicationInsightsTelemetryWorkerService(); | ||
services.ConfigureFunctionsApplicationInsights(); | ||
|
||
services.Configure<LoggerFilterOptions>(options => | ||
{ | ||
// The Application Insights SDK adds a default logging filter that instructs ILogger to capture only Warning and more severe logs. Application Insights requires an explicit override. | ||
// Log levels can also be configured using appsettings.json. For more information, see https://learn.microsoft.com/en-us/azure/azure-monitor/app/worker-service#ilogger-logs | ||
LoggerFilterRule toRemove = options.Rules.FirstOrDefault(rule => rule.ProviderName | ||
== "Microsoft.Extensions.Logging.ApplicationInsights.ApplicationInsightsLoggerProvider"); | ||
if (toRemove is not null) | ||
{ | ||
options.Rules.Remove(toRemove); | ||
} | ||
}); | ||
|
||
return services; | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
samples/ingestion/ingestion-client/FetchTranscription/.vscode/launch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Attach to Fetch Transcription from Queue", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processId": "${command:azureFunctions.pickProcess}" | ||
} | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
samples/ingestion/ingestion-client/FetchTranscription/.vscode/settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"azureFunctions.deploySubpath": "bin/Release/net8.0/publish", | ||
"azureFunctions.projectLanguage": "C#", | ||
"azureFunctions.projectRuntime": "~4", | ||
"azureFunctions.preDeployTask": "publish (functions)" | ||
} |
69 changes: 69 additions & 0 deletions
69
samples/ingestion/ingestion-client/FetchTranscription/.vscode/tasks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "clean (functions)", | ||
"command": "dotnet", | ||
"args": [ | ||
"clean", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"type": "process", | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "build (functions)", | ||
"command": "dotnet", | ||
"args": [ | ||
"build", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"type": "process", | ||
"dependsOn": "clean (functions)", | ||
"group": { | ||
"kind": "build", | ||
"isDefault": true | ||
}, | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "clean release (functions)", | ||
"command": "dotnet", | ||
"args": [ | ||
"clean", | ||
"--configuration", | ||
"Release", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"type": "process", | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"label": "publish (functions)", | ||
"command": "dotnet", | ||
"args": [ | ||
"publish", | ||
"--configuration", | ||
"Release", | ||
"/property:GenerateFullPaths=true", | ||
"/consoleloggerparameters:NoSummary" | ||
], | ||
"type": "process", | ||
"dependsOn": "clean release (functions)", | ||
"problemMatcher": "$msCompile" | ||
}, | ||
{ | ||
"type": "func", | ||
"dependsOn": "build (functions)", | ||
"options": { | ||
"cwd": "${workspaceFolder}/bin/Debug/net8.0" | ||
}, | ||
"command": "host start --port 7072", | ||
"isBackground": true, | ||
"problemMatcher": "$func-dotnet-watch" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
samples/ingestion/ingestion-client/FetchTranscription/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// <copyright file="Program.cs" company="Microsoft Corporation"> | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE.md file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace FetchTranscription | ||
{ | ||
using System.Threading.Tasks; | ||
|
||
using Connector; | ||
using Connector.Database; | ||
|
||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
public static class Program | ||
{ | ||
public static async Task Main(string[] args) | ||
{ | ||
var host = new HostBuilder() | ||
.ConfigureFunctionsWorkerDefaults() | ||
.ConfigureServices(s => | ||
{ | ||
// This is a unified way to configure logging filter for all functions. | ||
s.ConfigureIngestionClientLogging(); | ||
|
||
if (FetchTranscriptionEnvironmentVariables.UseSqlDatabase) | ||
{ | ||
s.AddDbContext<IngestionClientDbContext>( | ||
options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, FetchTranscriptionEnvironmentVariables.DatabaseConnectionString)); | ||
} | ||
}) | ||
.Build(); | ||
|
||
await host.RunAsync(); | ||
} | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
samples/ingestion/ingestion-client/FetchTranscription/Startup.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
samples/ingestion/ingestion-client/StartTranscriptionByServiceBus/.vscode/launch.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Attach to Start Transcription by Service Bus", | ||
"type": "coreclr", | ||
"request": "attach", | ||
"processId": "${command:azureFunctions.pickProcess}" | ||
} | ||
] | ||
} |
6 changes: 6 additions & 0 deletions
6
samples/ingestion/ingestion-client/StartTranscriptionByServiceBus/.vscode/settings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"azureFunctions.deploySubpath": "bin/Release/net8.0/publish", | ||
"azureFunctions.projectLanguage": "C#", | ||
"azureFunctions.projectRuntime": "~4", | ||
"azureFunctions.preDeployTask": "publish (functions)" | ||
} |
Oops, something went wrong.