Skip to content

Instantly share code, notes, and snippets.

@alaye-ms
Created September 13, 2024 17:43
Show Gist options
  • Save alaye-ms/f8963137ff62bb882c0ed45f5f655fe3 to your computer and use it in GitHub Desktop.
Save alaye-ms/f8963137ff62bb882c0ed45f5f655fe3 to your computer and use it in GitHub Desktop.
Using a different image for Aspire CosmosDB emulator
The RunAsEmulator function mostly serves as a wrapper around adding the container image and port with a specific "emulator" name
so it can be replaced by that call and whatever emulator is being used.
It'll be important to run `docker pull` on the image you use, and also I needed to run `dotnet dev-certs https --trust`
var builder = DistributedApplication.CreateBuilder(args);
var database = builder.AddAzureCosmosDB("cosmos").AddDatabase("iotdb")
//.RunAsEmulator()
.WithEndpoint(name: "emulator", targetPort: 8080)
.WithAnnotation(new ContainerImageAnnotation
{
Registry = "<registry name>",
Image = "<image name>",
Tag = "<tag>"
});
var apiService = builder.AddProject<Projects.AspireWithCosmos_ApiService>("apiservice")
.WithReference(database);
builder.AddProject<Projects.AspireWithCosmos_Web>("webfrontend")
.WithExternalHttpEndpoints()
.WithReference(apiService);
builder.Build().Run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment