-
Notifications
You must be signed in to change notification settings - Fork 724
Add AzureFunctionsEndToEnd with prototype implementation #5418
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
0012f2b
Add AzureFunctionsEndToEnd with prototype implementation
captainsafia 39eda7e
Updat EventHub extension package to latest mirrored version
captainsafia 81c1406
Fix RandomString implementation
eerhardt b4c0adb
Hack to make the emulators work
davidfowl 9424363
More cleanup
davidfowl 35ece30
Primary constructors
davidfowl e150956
More cleanup
davidfowl b8504f9
Added Aspire.Hosting.Azure.Functions
davidfowl 866c12c
Experiment with specifying the host storage
davidfowl 67c7502
Separate host storage from the app storage
davidfowl 83901da
First cut of IResourceWithAzureFunctionsConfig and removed WithReference
davidfowl e7b4653
Tested with managed identity and worked around issues
davidfowl 3f40399
Implement the functions interface on storage as well
davidfowl 148eed8
Simulate modeling Azure Functions as project resources
captainsafia c8c5d78
Make it work
davidfowl dc0ab33
Remove the port from launch settings.
davidfowl a7b1c5b
Remove other interfaces from functions resource
davidfowl a1de969
Simplify functions sample
davidfowl 2adf2f9
Add smoke test for launching Functions app
captainsafia 4dd9540
Always run inner functions build
captainsafia bc59c5a
Wire up package version for Aspire.Hosting.Azure.Functions
captainsafia 514e11c
Fix AppHost reference for test project
captainsafia 30277e4
Move AzureFunctionsEndToEnd tests to project specific tests
captainsafia f4d06ef
Add Requires attributes to AzureFunctions tests
captainsafia 8618f28
Skip AzureFunctionsTest on Helix until core tools is installed
captainsafia 1d247cb
Merge remote-tracking branch 'origin/main' into add-azfunctions-proto…
radical 4217e1d
Add deps on azure functions cli on helix
radical 1d67dc0
fix helix payload definition
radical a7ec3ec
Fix playground tests build
radical e25eead
Fix cli payload for helix
radical 5605f41
Set destinationPath on helix payload, the default is the root directory
radical 7d36ffd
Fix typo
radical 38621d1
another round - fix path
radical 42e48bb
Merge remote-tracking branch 'origin/main' into add-azfunctions-proto…
radical 44f428f
simplify payload spec
radical 0c0d74c
Update docstrings and README for Aspire.Hosting.Azure.Functions
captainsafia 9d9e38c
Appease the linter
captainsafia 5b18b3d
Conditionally skip EventHubs emulation in CI
captainsafia 214139d
Skip AzureFunctionsTest
captainsafia 9c10de5
Use [ActiveIssue] to skip test in CI
captainsafia 95667ec
More feedback
captainsafia f464069
Update tests/helix/send-to-helix-inner.proj
captainsafia bf92b87
Disable eventhubs on codespaces which doesn't have docker desktop
radical e02a50f
Update HTTP trigger to use ASP.NET-based trigger
captainsafia 7e650e0
Merge branch 'main' into add-azfunctions-prototype
captainsafia c9a50a7
Try 1: patch extensions.json copy bug
captainsafia 080aa8a
Try 2: patch extensions.json copy bug
captainsafia 61855b0
Try 3: patch extensions.json copy bug
captainsafia 54c94ae
Try only build AzureFunctionsEndToEnd project once in CI
captainsafia 97b10ac
Bring back manual patch for extensions.json
captainsafia bf8d90a
Enable include conditionally
captainsafia 54590a3
Update README with workaround for build bug
captainsafia 33e563d
Fix markdown lint warnings
captainsafia 46952d7
Add note about lack of OTel support
captainsafia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -147,4 +147,4 @@ node_modules/ | |
| *.svclog | ||
|
|
||
| # Python virtual environments | ||
| .venv | ||
| .venv | ||
This file contains hidden or 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 hidden or 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 hidden or 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
19 changes: 19 additions & 0 deletions
19
...ctionsEndToEnd/AzureFunctionsEndToEnd.ApiService/AzureFunctionsEndToEnd.ApiService.csproj
This file contains hidden or 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,19 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <AspireProjectOrPackageReference Include="Aspire.Azure.Storage.Blobs" /> | ||
| <AspireProjectOrPackageReference Include="Aspire.Azure.Storage.Queues" /> | ||
| <AspireProjectOrPackageReference Include="Aspire.Azure.Messaging.EventHubs" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
67 changes: 67 additions & 0 deletions
67
playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.ApiService/Program.cs
This file contains hidden or 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,67 @@ | ||
| using System.Security.Cryptography; | ||
| using System.Text; | ||
| #if !SKIP_EVENTHUBS_EMULATION | ||
| using Azure.Messaging.EventHubs; | ||
| using Azure.Messaging.EventHubs.Producer; | ||
| #endif | ||
| using Azure.Storage.Blobs; | ||
| using Azure.Storage.Queues; | ||
|
|
||
| var builder = WebApplication.CreateBuilder(args); | ||
|
|
||
| // Add service defaults & Aspire components. | ||
| builder.AddServiceDefaults(); | ||
| builder.AddAzureQueueClient("queue"); | ||
| builder.AddAzureBlobClient("blob"); | ||
| #if !SKIP_EVENTHUBS_EMULATION | ||
| builder.AddAzureEventHubProducerClient("eventhubs", static settings => settings.EventHubName = "myhub"); | ||
| #endif | ||
|
|
||
| var app = builder.Build(); | ||
|
|
||
| app.MapGet("/publish/asq", async (QueueServiceClient client, CancellationToken cancellationToken) => | ||
| { | ||
| var queue = client.GetQueueClient("queue"); | ||
| await queue.CreateIfNotExistsAsync(cancellationToken: cancellationToken); | ||
| var data = Convert.ToBase64String(Encoding.UTF8.GetBytes("Hello, World!")); | ||
| await queue.SendMessageAsync(data, cancellationToken: cancellationToken); | ||
| return Results.Ok("Message sent to Azure Storage Queue."); | ||
| }); | ||
|
|
||
| static string RandomString(int length) | ||
| { | ||
| const string chars = "abcdefghijklmnopqrstuvwxyz"; | ||
| return RandomNumberGenerator.GetString(chars, length); | ||
| } | ||
|
|
||
| app.MapGet("/publish/blob", async (BlobServiceClient client, CancellationToken cancellationToken, int length = 20) => | ||
| { | ||
| var container = client.GetBlobContainerClient("blobs"); | ||
| await container.CreateIfNotExistsAsync(cancellationToken: cancellationToken); | ||
|
|
||
| var entry = new { Id = Guid.NewGuid(), Text = RandomString(length) }; | ||
| var blob = container.GetBlobClient(entry.Id.ToString()); | ||
|
|
||
| await blob.UploadAsync(new BinaryData(entry)); | ||
|
|
||
| return Results.Ok("String uploaded to Azure Storage Blobs."); | ||
| }); | ||
|
|
||
| #if !SKIP_EVENTHUBS_EMULATION | ||
| app.MapGet("/publish/eventhubs", async (EventHubProducerClient client, CancellationToken cancellationToken, int length = 20) => | ||
| { | ||
| var data = new BinaryData(Encoding.UTF8.GetBytes(RandomString(length))); | ||
| await client.SendAsync([new EventData(data)]); | ||
| return Results.Ok("Message sent to Azure EventHubs."); | ||
| }); | ||
| #endif | ||
|
|
||
| app.MapGet("/", async (HttpClient client) => | ||
| { | ||
| var stream = await client.GetStreamAsync("http://funcapp/api/weatherforecast"); | ||
| return Results.Stream(stream, "application/json"); | ||
| }); | ||
|
|
||
| app.MapDefaultEndpoints(); | ||
|
|
||
| app.Run(); | ||
25 changes: 25 additions & 0 deletions
25
...d/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.ApiService/Properties/launchSettings.json
This file contains hidden or 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,25 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/launchsettings.json", | ||
| "profiles": { | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "launchUrl": "publish/asq", | ||
| "applicationUrl": "http://localhost:5313", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| }, | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "launchUrl": "publish/asq", | ||
| "applicationUrl": "https://localhost:7314;http://localhost:5313", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development" | ||
| } | ||
| } | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
...und/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.ApiService/appsettings.Development.json
This file contains hidden or 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,8 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.ApiService/appsettings.json
This file contains hidden or 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,9 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| }, | ||
| "AllowedHosts": "*" | ||
| } |
24 changes: 24 additions & 0 deletions
24
...ureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/AzureFunctionsEndToEnd.AppHost.csproj
This file contains hidden or 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,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <OutputType>Exe</OutputType> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <IsAspireHost>true</IsAspireHost> | ||
| <UserSecretsId>d824db17-effc-4f8c-aa80-f0ae6aba93eb</UserSecretsId> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.Functions" /> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.EventHubs" /> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.Azure.Storage" /> | ||
| <AspireProjectOrPackageReference Include="Aspire.Hosting.AppHost" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\AzureFunctionsEndToEnd.ApiService\AzureFunctionsEndToEnd.ApiService.csproj" /> | ||
| <ProjectReference Include="..\AzureFunctionsEndToEnd.Functions\AzureFunctionsEndToEnd.Functions.csproj" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
29 changes: 29 additions & 0 deletions
29
playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/Program.cs
This file contains hidden or 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,29 @@ | ||
| using Aspire.Hosting.Azure; | ||
|
|
||
| var builder = DistributedApplication.CreateBuilder(args); | ||
|
|
||
| var storage = builder.AddAzureStorage("storage").RunAsEmulator(); | ||
| var queue = storage.AddQueues("queue"); | ||
| var blob = storage.AddBlobs("blob"); | ||
|
|
||
| #if !SKIP_EVENTHUBS_EMULATION | ||
| var eventHubs = builder.AddAzureEventHubs("eventhubs").RunAsEmulator().AddEventHub("myhub"); | ||
| #endif | ||
|
|
||
| var funcApp = builder.AddAzureFunctionsProject<Projects.AzureFunctionsEndToEnd_Functions>("funcapp") | ||
| .WithExternalHttpEndpoints() | ||
| #if !SKIP_EVENTHUBS_EMULATION | ||
| .WithReference(eventHubs) | ||
| #endif | ||
| .WithReference(blob) | ||
| .WithReference(queue); | ||
|
|
||
| builder.AddProject<Projects.AzureFunctionsEndToEnd_ApiService>("apiservice") | ||
| #if !SKIP_EVENTHUBS_EMULATION | ||
| .WithReference(eventHubs) | ||
| #endif | ||
| .WithReference(queue) | ||
| .WithReference(blob) | ||
| .WithReference(funcApp); | ||
|
|
||
| builder.Build().Run(); |
29 changes: 29 additions & 0 deletions
29
...ound/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/Properties/launchSettings.json
This file contains hidden or 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,29 @@ | ||
| { | ||
| "$schema": "https://json.schemastore.org/launchsettings.json", | ||
| "profiles": { | ||
| "https": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "https://localhost:17244;http://localhost:15054", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21003", | ||
| "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22110" | ||
| } | ||
| }, | ||
| "http": { | ||
| "commandName": "Project", | ||
| "dotnetRunMessages": true, | ||
| "launchBrowser": true, | ||
| "applicationUrl": "http://localhost:15054", | ||
| "environmentVariables": { | ||
| "ASPNETCORE_ENVIRONMENT": "Development", | ||
| "DOTNET_ENVIRONMENT": "Development", | ||
| "DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19010", | ||
| "DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20125" | ||
| } | ||
| } | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
...ground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/appsettings.Development.json
This file contains hidden or 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,8 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning" | ||
| } | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.AppHost/appsettings.json
This file contains hidden or 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,9 @@ | ||
| { | ||
| "Logging": { | ||
| "LogLevel": { | ||
| "Default": "Information", | ||
| "Microsoft.AspNetCore": "Warning", | ||
| "Aspire.Hosting.Dcp": "Warning" | ||
| } | ||
| } | ||
| } |
1 change: 1 addition & 0 deletions
1
playground/AzureFunctionsEndToEnd/AzureFunctionsEndToEnd.Functions/.dockerignore
This file contains hidden or 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 @@ | ||
| local.settings.json |
42 changes: 42 additions & 0 deletions
42
...unctionsEndToEnd/AzureFunctionsEndToEnd.Functions/AzureFunctionsEndToEnd.Functions.csproj
This file contains hidden or 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,42 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <TargetFramework>net8.0</TargetFramework> | ||
| <AzureFunctionsVersion>v4</AzureFunctionsVersion> | ||
| <OutputType>Exe</OutputType> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker" /> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" /> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Blobs" /> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Storage.Queues" /> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.EventHubs" /> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.OpenTelemetry" /> | ||
| <PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" /> | ||
| <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" /> | ||
| <PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" /> | ||
| <PackageReference Include="OpenTelemetry.Extensions.Hosting" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <None Update="host.json"> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
| <None Update="local.settings.json"> | ||
captainsafia marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| <CopyToPublishDirectory>Never</CopyToPublishDirectory> | ||
| </None> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ProjectReference Include="..\..\Playground.ServiceDefaults\Playground.ServiceDefaults.csproj" /> | ||
| </ItemGroup> | ||
| <!-- HACK: Simulate running the Azure Functions project via `dotnet run` by spawning the host via a run command. --> | ||
| <PropertyGroup> | ||
| <RunCommand>func</RunCommand> | ||
| <RunArguments>start --csharp --verbose</RunArguments> | ||
| </PropertyGroup> | ||
| </Project> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.