Created
March 12, 2025 21:19
-
-
Save Zylvian/3f9050f18d49036284c8c8708c67d40e to your computer and use it in GitHub Desktop.
Zylvian Example AppHost
This file contains 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 Azure.Identity; | |
using Microsoft.Extensions.Configuration; | |
using Projects; | |
var builder = DistributedApplication.CreateBuilder(args); | |
// Add access token to private registry | |
builder.Configuration.AddAzureAppConfiguration(options => | |
{ | |
var azureAppConfig = builder.Configuration["AzureAppConfiguration"] ?? ""; | |
options.Connect(new Uri(azureAppConfig), new DefaultAzureCredential()); | |
}); | |
var imrAccessToken = builder.Configuration["FishProject:DockerRegistryRead"] ?? throw new Exception("Access to token on Azure required."); | |
DockerHelper.DockerLogin("registry.imr.no", imrAccessToken); | |
// Register services | |
var pythonApi = builder | |
.AddDockerfile("pythonapi", "PythonApi") | |
.WithHttpEndpoint(targetPort: 5000) | |
.WithOtlpExporter(); | |
builder.AddProject<ApiHandler>("apihandler") | |
.WithExternalHttpEndpoints() | |
.WithEnvironment("PythonApiEndpoint", pythonApi.GetEndpoint("http")) | |
.WaitFor(pythonApi); | |
builder.Build().Run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment