azure-cosmos-db-emulator-docker icon indicating copy to clipboard operation
azure-cosmos-db-emulator-docker copied to clipboard

vNext Emulator Issue with GitHub Actions & .NET Aspire

Open jeastham1993 opened this issue 7 months ago • 6 comments

Describe the bug When starting up the CosmosDB preview emulator with .NET Aspire inside GitHub Actions my application fails to start. Looking at the logs, it looks like there is some kind of issue with a CosmosDB schema called cosmos_api, not sure where that comes from. Apologies if this issue should be directed at the Aspire repo, let me know if so.

Running locally on my M3 Mac it works ok, this only happens inside GitHub Actions.

To Reproduce Aspire code to run Emulator

var cosmos = builder
    .AddAzureCosmosDB("database")
    .RunAsPreviewEmulator(options =>
    {
        options.WithLifetime(ContainerLifetime.Persistent);
    });

var database = cosmos.AddCosmosDatabase("MyDb");
var container = database.AddContainer("Users", "/emailAddress");

Test code to startup the application using the test builder

// Run all local resources with Asipre for testing
var builder = DistributedApplicationTestingBuilder
    .CreateAsync<Projects.Stickerlandia_UserManagement_Aspire>().GetAwaiter().GetResult();
builder.Services.ConfigureHttpClientDefaults(clientBuilder =>
{
    clientBuilder.AddStandardResilienceHandler();
});

App = builder.BuildAsync().GetAwaiter().GetResult();

App.StartAsync().GetAwaiter().GetResult();

Expected behavior CosmosDB startsup and can be accessed successfully.

Screenshots

This is the error message from my GitHub Action

fail: MyApp.UserManagement.Aspire.Resources.api[0]
      8: 2025-05-02T01:58:22.6576606Z Failed to create resource api
      Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: InternalServerError (500); Substatus: 0; ActivityId: e0f876e9-2cc2-4821-bf2a-4f7aed5bdd1c; Reason: ({"code":"InternalServerError","message":"schema \u0022cosmos_api\u0022 does not exist"}
      RequestUri: http://localhost:35007/dbs/MyDb;
      RequestMethod: GET;
      Header: Authorization Length: 80;
      Header: x-ms-date Length: 29;
      Header: x-ms-cosmos-sdk-supportedcapabilities Length: 1;
      Header: x-ms-activity-id Length: 36;
      Header: Cache-Control Length: 8;
      Header: User-Agent Length: 69;
      Header: x-ms-version Length: 10;
      Header: Accept Length: 16;
      ActivityId: e0f876e9-2cc2-4821-bf2a-4f7aed5bdd1c, Request URI: /dbs/MyDb, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Linux/24.04 cosmos-netstandard-sdk/3.37.10);
         at Microsoft.Azure.Cosmos.GatewayStoreClient.ParseResponseAsync(HttpResponseMessage responseMessage, JsonSerializerSettings serializerSettings, DocumentServiceRequest request)
         at Microsoft.Azure.Cosmos.GatewayStoreClient.InvokeAsync(DocumentServiceRequest request, ResourceType resourceType, Uri physicalAddress, CancellationToken cancellationToken)
         at Microsoft.Azure.Cosmos.GatewayStoreModel.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
         at Microsoft.Azure.Cosmos.GatewayStoreModel.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken)
         at Microsoft.Azure.Cosmos.Handlers.TransportHandler.ProcessMessageAsync(RequestMessage request, CancellationToken cancellationToken)
         at Microsoft.Azure.Cosmos.Handlers.TransportHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)
      --- Cosmos Diagnostics ---{"Summary":{"GatewayCalls":{"(0, 0)":1,"(500, 0)":1}},"name":"CreateDatabaseIfNotExistsAsync","start datetime":"2025-05-02T01:58:08.887Z","duration in milliseconds":874.5703,"data":{"Client Configuration":{"Client Created Time Utc":"2025-05-02T01:57:29.3761357Z","MachineId":"vmId:2ab7b94f-81e2-40f0-9bca-959072b4d5a9","VM Region":"westus","NumberOfClientsCreated":1,"NumberOfActiveClients":1,"ConnectionMode":"Gateway","User Agent":"cosmos-netstandard-sdk/3.47.2|1|X64|Ubuntu 24.04.2 LTS|.NET 9.0.4|DN|","ConnectionConfig":{"gw":"(cps:50, urto:6, p:False, httpf: False)","rntbd":"(cto: 5, icto: -1, mrpc: 30, mcpe: 65535, erd: True, pr: ReuseUnicastPort)","other":"(ed:True, be:False)"},"ConsistencyConfig":"(consistency: NotSet, prgns:[], apprgn: )","ProcessorCount":2}},"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.RequestInvokerHandler","duration in milliseconds":866.8327,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.DiagnosticsHandler","duration in milliseconds":858.142,"data":{"System Info":{"systemHistory":[{"dateUtc":"2025-05-02T01:57:34.3823302Z","cpu":0.000,"memory":5992496.000,"threadInfo":{"isThreadStarving":"no info","availableThreads":32762,"minThreads":2,"maxThreads":32767},"numberOfOpenTcpConnection":0},{"dateUtc":"2025-05-02T01:57:44.4015979Z","cpu":98.791,"memory":6072956.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":1.4743,"availableThreads":32763,"minThreads":2,"maxThreads":32767},"numberOfOpenTcpConnection":0},{"dateUtc":"2025-05-02T01:57:54.4025137Z","cpu":98.293,"memory":6021964.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0484,"availableThreads":32763,"minThreads":2,"maxThreads":32767},"numberOfOpenTcpConnection":0},{"dateUtc":"2025-05-02T01:58:04.4041763Z","cpu":76.219,"memory":5886624.000,"threadInfo":{"isThreadStarving":"False","threadWaitIntervalInMs":0.0485,"availableThreads":32763,"minThreads":2,"maxThreads":32767},"numberOfOpenTcpConnection":0}]}},"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.TelemetryHandler","duration in milliseconds":856.9387,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.RetryHandler","duration in milliseconds":855.371,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.RouterHandler","duration in milliseconds":847.1548,"children":[{"name":"Microsoft.Azure.Cosmos.Handlers.TransportHandler","duration in milliseconds":846.1425,"children":[{"name":"Microsoft.Azure.Cosmos.GatewayStoreModel Transport Request","duration in milliseconds":828.7012,"data":{"Client Side Request Stats":{"Id":"AggregatedClientSideRequestStatistics","ContactedReplicas":[],"RegionsContacted":[],"FailedReplicas":[],"AddressResolutionStatistics":[],"StoreResponseStatistics":[],"HttpResponseStats":[{"StartTimeUTC":"2025-05-02T01:58:08.9233997Z","DurationInMs":500.1373,"RequestUri":"http://localhost:35007/dbs/MyDb","ResourceType":"Database","HttpMethod":"GET","ActivityId":"e0f876e9-2cc2-4821-bf2a-4f7aed5bdd1c","ExceptionType":"System.Threading.Tasks.TaskCanceledException","ExceptionMessage":"The operation was canceled."},{"StartTimeUTC":"2025-05-02T01:58:09.4237807Z","DurationInMs":315.0939,"RequestUri":"http://localhost:35007/dbs/MyDb","ResourceType":"Database","HttpMethod":"GET","ActivityId":"e0f876e9-2cc2-4821-bf2a-4f7aed5bdd1c","StatusCode":"InternalServerError","ReasonPhrase":"Internal Server Error"}]},"Point Operation Statistics":{"Id":"PointOperationStatistics","ActivityId":"e0f876e9-2cc2-4821-bf2a-4f7aed5bdd1c","ResponseTimeUtc":"2025-05-02T01:58:09.7504706Z","StatusCode":500,"SubStatusCode":0,"RequestCharge":0,"RequestUri":"dbs/MyDb","ErrorMessage":"Microsoft.Azure.Documents.DocumentClientException: {\"code\":\"InternalServerError\",\"message\":\"schema \\u0022cosmos_api\\u0022 does not exist\"}\nRequestUri: http://localhost:35007/dbs/MyDb;\nRequestMethod: GET;\nHeader: Authorization Length: 80;\nHeader: x-ms-date Length: 29;\nHeader: x-ms-cosmos-sdk-supportedcapabilities Length: 1;\nHeader: x-ms-activity-id Length: 36;\nHeader: Cache-Control Length: 8;\nHeader: User-Agent Length: 69;\nHeader: x-ms-version Length: 10;\nHeader: Accept Length: 16;\n\nActivityId: e0f876e9-2cc2-4821-bf2a-4f7aed5bdd1c, Request URI: /dbs/MyDb, RequestStats: Microsoft.Azure.Cosmos.Tracing.TraceData.ClientSideRequestStatisticsTraceDatum, SDK: Linux/24.04 cosmos-netstandard-sdk/3.37.10\n   at Microsoft.Azure.Cosmos.GatewayStoreClient.ParseResponseAsync(HttpResponseMessage responseMessage, JsonSerializerSettings serializerSettings, DocumentServiceRequest request)\n   at Microsoft.Azure.Cosmos.GatewayStoreClient.InvokeAsync(DocumentServiceRequest request, ResourceType resourceType, Uri physicalAddress, CancellationToken cancellationToken)\n   at Microsoft.Azure.Cosmos.GatewayStoreModel.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken)\n   at Microsoft.Azure.Cosmos.GatewayStoreModel.ProcessMessageAsync(DocumentServiceRequest request, CancellationToken cancellationToken)\n   at Microsoft.Azure.Cosmos.Handlers.TransportHandler.ProcessMessageAsync(RequestMessage request, CancellationToken cancellationToken)\n   at Microsoft.Azure.Cosmos.Handlers.TransportHandler.SendAsync(RequestMessage request, CancellationToken cancellationToken)","RequestSessionToken":null,"ResponseSessionToken":"0:-1#1","BELatencyInMs":null}}}]}]}]}]}]}]}]}

Desktop (please complete the following information):

  • Ubuntu latest in GitHub Actions
  • .NET 9 SDK

Additional context Add any other context about the problem here.

jeastham1993 avatar May 02 '25 02:05 jeastham1993

I have the same here. Works on Windows 11 but fails with the same error in Github Actions on Ubuntu.

thimobuchheister avatar Jun 02 '25 09:06 thimobuchheister

Same issue on MacOS M2

NapalmCodes avatar Jun 06 '25 14:06 NapalmCodes

Same issue in 9.3.1 running on Windows

Zeitgeist64 avatar Jun 26 '25 19:06 Zeitgeist64

I have the same issue in version 9.3.1 on Windows. It occasionally works, but most of the time it fails with the error described by OP.

joachimdekker avatar Jun 27 '25 19:06 joachimdekker

@sajeetharan - what more information is needed here? @adityamandaleeka mentioned running into this to me yesterday, so if you need a repro, we should be able to put one together.

Pilchie avatar Jul 23 '25 15:07 Pilchie

We need to enable a readiness probe - so Aspire waits until the emulator is evailable.

xgerman avatar Jul 23 '25 16:07 xgerman