Skip to content

Instantly share code, notes, and snippets.

@Zylvian
Created March 12, 2025 21:19
Show Gist options
  • Save Zylvian/3f9050f18d49036284c8c8708c67d40e to your computer and use it in GitHub Desktop.
Save Zylvian/3f9050f18d49036284c8c8708c67d40e to your computer and use it in GitHub Desktop.
Zylvian Example AppHost
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