Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 13 additions & 4 deletions src/apphost/Aspire.Dev.AppHost/AppHost.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
var builder = DistributedApplication.CreateBuilder(args);

// For deployment: We want to pick AppService as the environment to publish to.
builder.AddAzureAppServiceEnvironment("production");
builder.AddAzureAppServiceEnvironment("production")
.WithDashboard(false);
Comment thread
eerhardt marked this conversation as resolved.

var cache = builder.AddAzureManagedRedis("cache")
.RunAsContainer();

var staticHostWebsite = builder.AddProject<Projects.StaticHost>("aspiredev")
.WithReference(cache)
.WithExternalHttpEndpoints();
.WithExternalHttpEndpoints()
.PublishAsAzureAppServiceWebsite((infra, website) =>
{
website.IsEndToEndEncryptionEnabled = true;
});

var frontDoor = builder.AddAzureFrontDoor(staticHostWebsite);

if (builder.ExecutionContext.IsRunMode)
{
Expand All @@ -28,8 +35,10 @@
{
var secrets = builder.AddAzureKeyVault("secrets");
staticHostWebsite.WithProductionLiveStatus(builder, secrets);
}

builder.AddAzureFrontDoor(staticHostWebsite);
var logsWorkspace = builder.AddAzureLogAnalyticsWorkspace("workspace-logs");
frontDoor.WithDiagnostics(logsWorkspace);
cache.WithDiagnostics(logsWorkspace);
}

builder.Build().Run();
1 change: 1 addition & 0 deletions src/apphost/Aspire.Dev.AppHost/Aspire.Dev.AppHost.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<PackageReference Include="Aspire.Hosting.Azure.KeyVault" Version="13.6.0" />
<PackageReference Include="Aspire.Hosting.Azure.Redis" Version="13.6.0" />
<PackageReference Include="Aspire.Hosting.JavaScript" Version="13.6.0" />
<PackageReference Include="Azure.Provisioning.Monitor" Version="1.0.0-beta.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Aspire.Hosting.Azure;
using Azure.Provisioning.Cdn;
using Azure.Provisioning.Monitor;
using Azure.Provisioning.RedisEnterprise;

internal static class DeploymentExtensions
{
Expand Down Expand Up @@ -37,4 +39,65 @@ public static IResourceBuilder<AzureFrontDoorResource> AddAzureFrontDoor(
};
});
}

public static IResourceBuilder<AzureFrontDoorResource> WithDiagnostics(
this IResourceBuilder<AzureFrontDoorResource> builder,
IResourceBuilder<AzureLogAnalyticsWorkspaceResource> workspace)
{
return builder.ConfigureInfrastructure(infra =>
{
var profile = infra.GetProvisionableResources().OfType<CdnProfile>().Single();

infra.Add(new DiagnosticSettingsResource("diagnostics")
{
Name = "security-logs",
Scope = profile,
Properties = new DiagnosticSettings
{
WorkspaceId = workspace.Resource.Id.AsProvisioningParameter(infra),
Logs =
{
new DiagnosticsLogSettings
{
Category = "FrontDoorAccessLog",
Enabled = true
},
new DiagnosticsLogSettings
{
Category = "FrontDoorWebApplicationFirewallLog",
Enabled = true
}
}
}
});
});
}

public static IResourceBuilder<AzureManagedRedisResource> WithDiagnostics(
this IResourceBuilder<AzureManagedRedisResource> builder,
IResourceBuilder<AzureLogAnalyticsWorkspaceResource> workspace)
{
return builder.ConfigureInfrastructure(infra =>
{
var database = infra.GetProvisionableResources().OfType<RedisEnterpriseDatabase>().Single();

infra.Add(new DiagnosticSettingsResource("redisConnectionLogs")
{
Name = "redis-connection-logs",
Scope = database,
Properties = new DiagnosticSettings
{
WorkspaceId = workspace.Resource.Id.AsProvisioningParameter(infra),
Logs =
{
new DiagnosticsLogSettings
{
Category = "ConnectionEvents",
Enabled = true
}
}
}
});
});
}
}
Loading