Skip to content

Commit

Permalink
[IngestionClient] Complete Azure Functions Isolated Worker migration (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryvanderVegte authored Jul 11, 2024
1 parent aac2918 commit 439ec61
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 110 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ingestion_client.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ jobs:
run: dotnet publish -c Release -f net8.0 --no-self-contained --output ./StartTranscriptionByTimer samples/ingestion/ingestion-client/StartTranscriptionByTimer/StartTranscriptionByTimer.csproj

- name: Zip StartTranscriptionByTimer
run: cd StartTranscriptionByTimer && zip -r ../StartTranscriptionByTimer.zip *
run: cd StartTranscriptionByTimer && zip -r ../StartTranscriptionByTimer.zip .

- name: Publish StartTranscriptionByServiceBus function
run: dotnet publish -c Release -f net8.0 --no-self-contained --output ./StartTranscriptionByServiceBus samples/ingestion/ingestion-client/StartTranscriptionByServiceBus/StartTranscriptionByServiceBus.csproj
- name: Zip StartTranscriptionByServiceBus
run: cd StartTranscriptionByServiceBus && zip -r ../StartTranscriptionByServiceBus.zip *
run: cd StartTranscriptionByServiceBus && zip -r ../StartTranscriptionByServiceBus.zip .

- name: Publish FetchTranscription function
run: dotnet publish -c Release -f net8.0 --no-self-contained --output ./FetchTranscription samples/ingestion/ingestion-client/FetchTranscription/FetchTranscription.csproj
- name: Zip FetchTranscription
run: cd FetchTranscription && zip -r ../FetchTranscription.zip *
run: cd FetchTranscription && zip -r ../FetchTranscription.zip .

- name: Create Release
id: create_release
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="$(MicrosoftApplicationInsightsWorkerServicePackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="$(MicrosoftAzureFunctionsWorkerPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="$(MicrosoftAzureFunctionsWorkerApplicationInsightsPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="$(MicrosoftAzureFunctionsExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="$(MicrosoftAzureFunctionsWorkerExtensionsServiceBusPackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(MicrosoftEntityFrameworkCorePackageVersion)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(MicrosoftEntityFrameworkCoreSqlServerPackageVersion)" />
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.AI.Language.Conversations" Version="$(AzureAILanguageConversationsPackageVersion)" />
<PackageReference Include="Azure.AI.TextAnalytics" Version="$(AzureAITextAnalyticsPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="$(MicrosoftAzureFunctionsWorkerPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="$(MicrosoftAzureFunctionsExtensionsPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="$(MicrosoftAzureFunctionsWorkerSdkPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Connector\Connector.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Azure.AI.Language.Conversations" Version="$(AzureAILanguageConversationsPackageVersion)" />
<PackageReference Include="Azure.AI.TextAnalytics" Version="$(AzureAITextAnalyticsPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="$(MicrosoftAzureFunctionsWorkerPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="$(MicrosoftAzureFunctionsWorkerExtensionsServiceBusPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="$(MicrosoftAzureFunctionsWorkerSdkPackageVersion)" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Connector\Connector.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
18 changes: 13 additions & 5 deletions samples/ingestion/ingestion-client/FetchTranscription/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

namespace FetchTranscription
{
using System.Threading.Tasks;

using Connector;
using Connector.Database;

Expand All @@ -16,24 +14,34 @@ namespace FetchTranscription

public static class Program
{
public static async Task Main(string[] args)
public static void Main(string[] args)
{
var useSqlDatabase = FetchTranscriptionEnvironmentVariables.UseSqlDatabase;

var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(s =>
{
// This is a unified way to configure logging filter for all functions.
s.ConfigureIngestionClientLogging();

if (FetchTranscriptionEnvironmentVariables.UseSqlDatabase)
if (useSqlDatabase)
{
s.AddDbContext<IngestionClientDbContext>(
options => SqlServerDbContextOptionsExtensions.UseSqlServer(options, FetchTranscriptionEnvironmentVariables.DatabaseConnectionString));
}
})
.Build();

await host.RunAsync();
// apply database migrations once during startup (not with every function execution):
if (useSqlDatabase)
{
using var scope = host.Services.CreateScope();
var ingestionClientDbContext = scope.ServiceProvider.GetRequiredService<IngestionClientDbContext>();
ingestionClientDbContext.Database.Migrate();
}

host.Run();
}
}
}
12 changes: 9 additions & 3 deletions samples/ingestion/ingestion-client/Setup/ArmTemplateBatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
},
"variables":
{
"Version": "v2.1.1",
"Version": "v2.1.2",
"AudioInputContainer": "audio-input",
"AudioProcessedContainer": "audio-processed",
"ErrorFilesOutputContainer": "audio-failed",
Expand Down Expand Up @@ -895,7 +895,10 @@
"properties":
{
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('AppServicePlanName'))]",
"httpsOnly": "true"
"httpsOnly": "true",
"siteConfig": {
"netFrameworkVersion": "v8.0"
}
},
"identity":
{
Expand Down Expand Up @@ -966,7 +969,10 @@
"properties":
{
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('AppServicePlanName'))]",
"httpsOnly": "true"
"httpsOnly": "true",
"siteConfig": {
"netFrameworkVersion": "v8.0"
}
},
"identity":
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

namespace StartTranscription
{
using System.Threading.Tasks;
using Connector;
using Microsoft.Extensions.Hosting;

Expand All @@ -18,8 +17,7 @@ public static class Program
/// Main entry point of the function app.
/// </summary>
/// <param name="args"></param>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public static async Task Main(string[] args)
public static void Main(string[] args)
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
Expand All @@ -30,7 +28,7 @@ public static async Task Main(string[] args)
})
.Build();

await host.RunAsync();
host.Run();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="$(MicrosoftAzureFunctionsWorkerPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="$(MicrosoftAzureFunctionsWorkerExtensionsServiceBusPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="$(MicrosoftAzureFunctionsWorkerSdkPackageVersion)" />
Expand All @@ -26,4 +27,7 @@
<ProjectReference Include="..\Connector\Connector.csproj"/>
<ProjectReference Include="..\StartTranscriptionByTimer\StartTranscriptionByTimer.csproj"/>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@

namespace StartTranscriptionByTimer
{
using System.Threading.Tasks;
using Connector;
using Microsoft.Extensions.Hosting;

public static class Program
{
public static async Task Main(string[] args)
public static void Main(string[] args)
{
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
Expand All @@ -22,7 +21,7 @@ public static async Task Main(string[] args)
})
.Build();

await host.RunAsync();
host.Run();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="$(MicrosoftApplicationInsightsWorkerServicePackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="$(MicrosoftAzureFunctionsWorkerPackageVersion)" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="$(MicrosoftAzureFunctionsWorkerExtensionsServiceBusPackageVersion)" />
Expand All @@ -26,4 +27,7 @@
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
5 changes: 2 additions & 3 deletions samples/ingestion/ingestion-client/versions.nugets.props
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@


<MicrosoftApplicationInsightsWorkerServicePackageVersion>[2.22.0]</MicrosoftApplicationInsightsWorkerServicePackageVersion>
<MicrosoftAzureFunctionsExtensionsPackageVersion>[1.1.0]</MicrosoftAzureFunctionsExtensionsPackageVersion>
<MicrosoftAzureFunctionsWorkerPackageVersion>[1.22.0]</MicrosoftAzureFunctionsWorkerPackageVersion>
<MicrosoftAzureFunctionsWorkerExtensionsServiceBusPackageVersion>[5.20.0]</MicrosoftAzureFunctionsWorkerExtensionsServiceBusPackageVersion>
<MicrosoftAzureFunctionsWorkerExtensionsServiceBusPackageVersion>[5.13.0]</MicrosoftAzureFunctionsWorkerExtensionsServiceBusPackageVersion>
<MicrosoftAzureFunctionsWorkerExtensionsTimerPackageVersion>[4.3.1]</MicrosoftAzureFunctionsWorkerExtensionsTimerPackageVersion>
<MicrosoftAzureFunctionsWorkerApplicationInsightsPackageVersion>[1.2.0]</MicrosoftAzureFunctionsWorkerApplicationInsightsPackageVersion>
<MicrosoftAzureFunctionsWorkerSdkPackageVersion>[1.17.1]</MicrosoftAzureFunctionsWorkerSdkPackageVersion>
<MicrosoftAzureFunctionsWorkerSdkPackageVersion>[1.15.1]</MicrosoftAzureFunctionsWorkerSdkPackageVersion>

<MicrosoftEntityFrameworkCorePackageVersion>[8.0.6]</MicrosoftEntityFrameworkCorePackageVersion>
<MicrosoftEntityFrameworkCoreDesignPackageVersion>[8.0.6]</MicrosoftEntityFrameworkCoreDesignPackageVersion>
Expand Down

0 comments on commit 439ec61

Please sign in to comment.