Created
May 21, 2025 20:18
-
-
Save dimenus/abbf0ac9c09dfd9594a6b5615e75f292 to your computer and use it in GitHub Desktop.
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
using Aspire.Hosting; | |
using Projects; | |
namespace EspiContentAnalyzer.AppHost; | |
internal static class Prograpm | |
{ | |
public static void Main(string[] args) | |
{ | |
var builder = DistributedApplication.CreateBuilder(args); | |
//The existence of this resource breaks core_api | |
var blob_storage = builder.AddAzureStorage("storage") | |
.AddBlobs("ContentAnalyzerStorage"); | |
var db_admin_user = builder.AddParameter("DbSchemaManagerUser", "ca_admin"); | |
var db_admin_password = builder.AddParameter("DbSchemaManagerPassword", secret: true); | |
var db_api_password = builder.AddParameter("DbApiUserPassword", secret: true); | |
var az_cogservices_endpoint = builder.AddParameterFromConfiguration("AzureCognitiveServices-Endpoint", "AzureCognitiveServices__Endpoint"); | |
var az_cogservices_apikey = builder.AddParameterFromConfiguration("AzureCognitiveServices-ApiKey", "AzureCognitiveServices__ApiKey", secret: true); | |
var db = builder.AddPostgres("db", db_admin_user, db_admin_password) | |
.AddDatabase("ContentAnalyzerDb", "content_analyzer"); | |
var db_manager = builder.AddProject<EsiContentAnalyzer_DbManager>("DbSchemaManager") | |
.WithEnvironment("IS_ASPIRE_HOST", "true") | |
.WithEnvironment("ApiDbUserConfig__Password", db_api_password) | |
.WithReference(db) | |
.WaitFor(db); | |
var core_api = builder.AddProject<EsiContentAnalyzer_API>("CoreAPI") | |
.WaitForCompletion(db_manager) | |
.WithEnvironment("IS_ASPIRE_HOST", "true") | |
.WithEnvironment("ConnectionStrings__ContentAnalyzerDb", () => { | |
var ep = db.Resource.Parent.PrimaryEndpoint; | |
var conn_string = | |
$"Host={ep.Host};Port={ep.Port};Database={db.Resource.DatabaseName};Username=ca_api;Password={db_api_password.Resource.Value}"; | |
return conn_string; | |
}) | |
.WithEnvironment("AzureCognitiveServices__Endpoint", az_cogservices_endpoint) | |
.WithEnvironment("AzureCognitiveServices__ApiKey", az_cogservices_apikey); | |
builder.Build().Run(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment