Skip to content
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

Dapr azure hosting ext #371

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
"ghcr.io/azure/azure-dev/azd:latest": {},
"ghcr.io/devcontainers/features/dotnet:latest": {
"version": "8.0",
"additionalVersions": [
"9.0"
]
"additionalVersions": ["9.0"]
},
"ghcr.io/devcontainers/features/github-cli:latest": {},
"ghcr.io/devcontainers/features/java:1": {
Expand All @@ -20,7 +18,8 @@
"ghcr.io/devcontainers-community/features/deno": {},
"ghcr.io/devcontainers/features/go:latest": {},
"ghcr.io/devcontainers/features/rust:latest": {},
"ghcr.io/devcontainers/features/python:1": {}
"ghcr.io/devcontainers/features/python:1": {},
"ghcr.io/dapr/cli/dapr-cli:0": {}
},
"customizations": {
"vscode": {
Expand Down Expand Up @@ -51,4 +50,4 @@
"onAutoForward": "notify"
}
}
}
}
45 changes: 45 additions & 0 deletions CommunityToolkit.Aspire.sln
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,20 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Mas
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.ActiveMQ", "src\CommunityToolkit.Aspire.Hosting.ActiveMQ\CommunityToolkit.Aspire.Hosting.ActiveMQ.csproj", "{0761C6CF-28E8-FC0F-6AF3-213E4B312DD0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Dapr.AzureExtensions", "src\CommunityToolkit.Aspire.Hosting.Dapr.AzureExtensions\CommunityToolkit.Aspire.Hosting.Dapr.AzureExtensions.csproj", "{CCA702F6-9399-49DE-85DE-326251BDBEB5}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dapr-ext", "dapr-ext", "{914A2506-9587-4DFF-ADC0-1D97798ABC8F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.AppHost", "examples\dapr-ext\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.AppHost\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.AppHost.csproj", "{022998DB-98FE-45EB-A145-DB0B1C12EEE5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis", "src\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.csproj", "{8575F535-5E8A-49AB-BC2E-2A0417FB636B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.ApiService", "examples\dapr-ext\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.ApiService\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.ApiService.csproj", "{995804A3-7D89-4E0A-952E-A5A4161734F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Dapr.AzureExtensions.Tests", "tests\CommunityToolkit.Aspire.Hosting.Dapr.AzureExtensions.Tests\CommunityToolkit.Aspire.Hosting.Dapr.AzureExtensions.Tests.csproj", "{EC41302D-7E37-4703-A053-BF4097FF6B26}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.Tests", "tests\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.Tests\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.Tests.csproj", "{ADF36205-629B-4822-99F3-88544F6B79CA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -491,6 +505,30 @@ Global
{0761C6CF-28E8-FC0F-6AF3-213E4B312DD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0761C6CF-28E8-FC0F-6AF3-213E4B312DD0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0761C6CF-28E8-FC0F-6AF3-213E4B312DD0}.Release|Any CPU.Build.0 = Release|Any CPU
{CCA702F6-9399-49DE-85DE-326251BDBEB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CCA702F6-9399-49DE-85DE-326251BDBEB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CCA702F6-9399-49DE-85DE-326251BDBEB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CCA702F6-9399-49DE-85DE-326251BDBEB5}.Release|Any CPU.Build.0 = Release|Any CPU
{022998DB-98FE-45EB-A145-DB0B1C12EEE5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{022998DB-98FE-45EB-A145-DB0B1C12EEE5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{022998DB-98FE-45EB-A145-DB0B1C12EEE5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{022998DB-98FE-45EB-A145-DB0B1C12EEE5}.Release|Any CPU.Build.0 = Release|Any CPU
{8575F535-5E8A-49AB-BC2E-2A0417FB636B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8575F535-5E8A-49AB-BC2E-2A0417FB636B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8575F535-5E8A-49AB-BC2E-2A0417FB636B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8575F535-5E8A-49AB-BC2E-2A0417FB636B}.Release|Any CPU.Build.0 = Release|Any CPU
{995804A3-7D89-4E0A-952E-A5A4161734F5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{995804A3-7D89-4E0A-952E-A5A4161734F5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{995804A3-7D89-4E0A-952E-A5A4161734F5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{995804A3-7D89-4E0A-952E-A5A4161734F5}.Release|Any CPU.Build.0 = Release|Any CPU
{EC41302D-7E37-4703-A053-BF4097FF6B26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EC41302D-7E37-4703-A053-BF4097FF6B26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC41302D-7E37-4703-A053-BF4097FF6B26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC41302D-7E37-4703-A053-BF4097FF6B26}.Release|Any CPU.Build.0 = Release|Any CPU
{ADF36205-629B-4822-99F3-88544F6B79CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADF36205-629B-4822-99F3-88544F6B79CA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADF36205-629B-4822-99F3-88544F6B79CA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADF36205-629B-4822-99F3-88544F6B79CA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -586,6 +624,13 @@ Global
{1200FB2E-F476-4151-BDFD-1DAEE3E99FF5} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{DE596B1A-B923-4D19-89B6-A361FA4EB5BF} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{0761C6CF-28E8-FC0F-6AF3-213E4B312DD0} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
{CCA702F6-9399-49DE-85DE-326251BDBEB5} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
{914A2506-9587-4DFF-ADC0-1D97798ABC8F} = {8519CC01-1370-47C8-AD94-B0F326B1563F}
{022998DB-98FE-45EB-A145-DB0B1C12EEE5} = {914A2506-9587-4DFF-ADC0-1D97798ABC8F}
{8575F535-5E8A-49AB-BC2E-2A0417FB636B} = {414151D4-7009-4E78-A5C6-D99EBD1E67D1}
{995804A3-7D89-4E0A-952E-A5A4161734F5} = {914A2506-9587-4DFF-ADC0-1D97798ABC8F}
{EC41302D-7E37-4703-A053-BF4097FF6B26} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
{ADF36205-629B-4822-99F3-88544F6B79CA} = {899F0713-7FC6-4750-BAFC-AC650B35B453}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {08B1D4B8-D2C5-4A64-BB8B-E1A2B29525F0}
Expand Down
3 changes: 3 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
<!-- Aspire packages -->
<PackageVersion Include="Aspire.Hosting" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.AppHost" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Dapr" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Azure.Redis" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.NodeJS" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Python" Version="$(AspireVersion)" />
<PackageVersion Include="Aspire.Hosting.Rabbitmq" Version="$(AspireVersion)" />
Expand Down Expand Up @@ -42,6 +44,7 @@
<PackageVersion Include="xunit.extensibility.execution" Version="2.9.2" />
<PackageVersion Include="Microsoft.DotNet.XUnitExtensions" Version=" 9.0.0-beta.24568.1" />
<!-- External packages -->
<PackageVersion Include="Azure.Provisioning.AppContainers" Version="1.0.0" />
<PackageVersion Include="JsonSchema.Net" Version="7.3.0" />
<PackageVersion Include="OllamaSharp" Version="4.0.11" />
<PackageVersion Include="MassTransit" Version="8.3.4" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.ExampleAPI_HostAddress = http://localhost:5156

GET {{CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.ExampleAPI_HostAddress}}/weatherforecast/
Accept: application/json

###
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

var app = builder.Build();

app.UseHttpsRedirection();

var summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

app.MapGet("/weatherforecast", () =>
{
var forecast = Enumerable.Range(1, 5).Select(index =>
new WeatherForecast
(
DateOnly.FromDateTime(DateTime.Now.AddDays(index)),
Random.Shared.Next(-20, 55),
summaries[Random.Shared.Next(summaries.Length)]
))
.ToArray();
return forecast;
})
.WithName("GetWeatherForecast");

app.Run();

record WeatherForecast(DateOnly Date, int TemperatureC, string? Summary)
{
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "https://json.schemastore.org/launchsettings.json",
"profiles": {
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "http://localhost:5156",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"https": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": false,
"applicationUrl": "https://localhost:7275;http://localhost:5156",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">

<Sdk Name="Aspire.AppHost.Sdk" Version="$(AspireAppHostSdkVersion)" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsAspireHost>true</IsAspireHost>
<UserSecretsId>068ca29f-dd8a-4898-9ba1-5839fd6a13db</UserSecretsId>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Aspire.Hosting.AppHost" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="../CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.ApiService/CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.ApiService.csproj" />
<ProjectReference Include="..\..\..\src\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis\CommunityToolkit.Aspire.Hosting.Dapr.AzureRedis.csproj" IsAspireProjectResource="false" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var builder = DistributedApplication.CreateBuilder(args);


var redisState = builder.AddAzureRedis("redisState").RunAsContainer();

// This currently only effects publishing
// local development still uses dapr redis state container
var daprState = builder.AddDaprStateStore("daprState")
.WithReference(redisState);

// API does not provide any functional example of Dapr - it simply demonstrates referencing the dapr state
var api = builder.AddProject<Projects.CommunityToolkit_Aspire_Hosting_Dapr_AzureRedis_ApiService>("example-api")
.WithReference(daprState)
.WithDaprSidecar();

builder.Build().Run();
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:17028;http://localhost:15086",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "https://localhost:21092",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "https://localhost:22240"
}
},
"http": {
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"applicationUrl": "http://localhost:15086",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development",
"DOTNET_ENVIRONMENT": "Development",
"DOTNET_DASHBOARD_OTLP_ENDPOINT_URL": "http://localhost:19004",
"DOTNET_RESOURCE_SERVICE_ENDPOINT_URL": "http://localhost:20299"
}
}
}
}
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"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Aspire.Hosting.Azure;

namespace Aspire.Hosting.ApplicationModel;

/// <summary>
/// Represents an Azure Dapr component resource.
/// </summary>
/// <remarks>
/// Initializes a new instance of the <see cref="AzureDaprComponentResource"/> class.
/// </remarks>
/// <param name="bicepIdentifier">The Bicep identifier.</param>
/// <param name="configureInfrastructure">The action to configure the Azure resource infrastructure.</param>
public class AzureDaprComponentResource(string bicepIdentifier, Action<AzureResourceInfrastructure> configureInfrastructure) : AzureProvisioningResource(bicepIdentifier, configureInfrastructure);
Loading