Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Cosmos with UseEmulator breaks manifest publishing: #1664

Closed
mitchdenny opened this issue Jan 16, 2024 · 2 comments
Closed

Using Cosmos with UseEmulator breaks manifest publishing: #1664

mitchdenny opened this issue Jan 16, 2024 · 2 comments
Assignees
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Comments

@mitchdenny
Copy link
Member

Code:

var builder = DistributedApplication.CreateBuilder(args);

var cache = builder.AddRedis("cache");
var cosmos = builder.AddAzureCosmosDB("mycosmos").UseEmulator().AddDatabase("mydb");

var apiService = builder.AddProject<Projects.AspireApp1_ApiService>("apiservice");

builder.AddProject<Projects.AspireApp1_Web>("webfrontend")
    .WithReference(cache)
    .WithReference(apiService)
    .WithReference(cosmos);

builder.Build().Run();

Logs:

PS C:\Code\dotnet\aspire-dogfood\dev\AspireApp1> dotnet run --project .\AspireApp1.AppHost\AspireApp1.AppHost.csproj -- --publisher manifest --output-path manifest.json
Building...
fail: Microsoft.Extensions.Hosting.Internal.Host[11]
      Hosting failed to start
      Aspire.Hosting.DistributedApplicationException: Azure Cosmos DB resource does not have endpoint annotation with name 'emulator'.
         at Aspire.Hosting.Azure.Data.Cosmos.AzureCosmosDBResource.GetEmulatorPort(String endpointName) in C:\Code\dotnet\aspire\src\Aspire.Hosting.Azure\AzureCosmosDBResource.cs:line 43
         at Aspire.Hosting.Azure.Data.Cosmos.AzureCosmosDBResource.GetConnectionString() in C:\Code\dotnet\aspire\src\Aspire.Hosting.Azure\AzureCosmosDBResource.cs:line 28
         at Aspire.Hosting.AzureCosmosDBCloudApplicationBuilderExtensions.WriteCosmosDBToManifest(ManifestPublishingContext context, AzureCosmosDBResource cosmosDb) in C:\Code\dotnet\aspire\src\Aspire.Hosting.Azure\AzureCosmosDBCloudApplicationBuilderExtensions.cs:line 53
         at Aspire.Hosting.AzureCosmosDBCloudApplicationBuilderExtensions.<>c__DisplayClass0_0.<AddAzureCosmosDB>b__0(ManifestPublishingContext context) in C:\Code\dotnet\aspire\src\Aspire.Hosting.Azure\AzureCosmosDBCloudApplicationBuilderExtensions.cs:line 29
         at Aspire.Hosting.Publishing.ManifestPublisher.<>c__DisplayClass12_0.<WriteResource>b__0() in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 76
         at Aspire.Hosting.Publishing.ManifestPublisher.<>c__DisplayClass12_0.<WriteResource>g__WriteResourceObject|1[T](T resource, Action action) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 99
         at Aspire.Hosting.Publishing.ManifestPublisher.WriteResource(IResource resource, ManifestPublishingContext context) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 76
         at Aspire.Hosting.Publishing.ManifestPublisher.WriteResources(DistributedApplicationModel model, ManifestPublishingContext context) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 63
         at Aspire.Hosting.Publishing.ManifestPublisher.WriteManifestAsync(DistributedApplicationModel model, Utf8JsonWriter jsonWriter, CancellationToken cancellationToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 52
         at Aspire.Hosting.Publishing.ManifestPublisher.PublishInternalAsync(DistributedApplicationModel model, CancellationToken cancellationToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 40
         at Aspire.Hosting.Publishing.ManifestPublisher.PublishAsync(DistributedApplicationModel model, CancellationToken cancellationToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 24
         at Aspire.Hosting.DistributedApplicationRunner.ExecuteAsync(CancellationToken stoppingToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\DistributedApplicationRunner.cs:line 25
         at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
         at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
Unhandled exception. System.AggregateException: One or more errors occurred. (Azure Cosmos DB resource does not have endpoint annotation with name 'emulator'.) 
 ---> Aspire.Hosting.DistributedApplicationException: Azure Cosmos DB resource does not have endpoint annotation with name 'emulator'.
   at Aspire.Hosting.Azure.Data.Cosmos.AzureCosmosDBResource.GetEmulatorPort(String endpointName) in C:\Code\dotnet\aspire\src\Aspire.Hosting.Azure\AzureCosmosDBResource.cs:line 43
   at Aspire.Hosting.Azure.Data.Cosmos.AzureCosmosDBResource.GetConnectionString() in C:\Code\dotnet\aspire\src\Aspire.Hosting.Azure\AzureCosmosDBResource.cs:line 28
   at Aspire.Hosting.AzureCosmosDBCloudApplicationBuilderExtensions.WriteCosmosDBToManifest(ManifestPublishingContext context, AzureCosmosDBResource cosmosDb) in C:\Code\dotnet\aspire\src\Aspire.Hosting.Azure\AzureCosmosDBCloudApplicationBuilderExtensions.cs:line 53
   at Aspire.Hosting.AzureCosmosDBCloudApplicationBuilderExtensions.<>c__DisplayClass0_0.<AddAzureCosmosDB>b__0(ManifestPublishingContext context) in C:\Code\dotnet\aspire\src\Aspire.Hosting.Azure\AzureCosmosDBCloudApplicationBuilderExtensions.cs:line 29
   at Aspire.Hosting.Publishing.ManifestPublisher.<>c__DisplayClass12_0.<WriteResource>b__0() in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 76
   at Aspire.Hosting.Publishing.ManifestPublisher.<>c__DisplayClass12_0.<WriteResource>g__WriteResourceObject|1[T](T resource, Action action) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 99
   at Aspire.Hosting.Publishing.ManifestPublisher.WriteResource(IResource resource, ManifestPublishingContext context) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 76
   at Aspire.Hosting.Publishing.ManifestPublisher.WriteResources(DistributedApplicationModel model, ManifestPublishingContext context) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 63
   at Aspire.Hosting.Publishing.ManifestPublisher.WriteManifestAsync(DistributedApplicationModel model, Utf8JsonWriter jsonWriter, CancellationToken cancellationToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 52
   at Aspire.Hosting.Publishing.ManifestPublisher.PublishInternalAsync(DistributedApplicationModel model, CancellationToken cancellationToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 40
   at Aspire.Hosting.Publishing.ManifestPublisher.PublishAsync(DistributedApplicationModel model, CancellationToken cancellationToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\Publishing\ManifestPublisher.cs:line 24
   at Aspire.Hosting.DistributedApplicationRunner.ExecuteAsync(CancellationToken stoppingToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\DistributedApplicationRunner.cs:line 25
   at Microsoft.Extensions.Hosting.Internal.Host.<StartAsync>b__15_1(IHostedService service, CancellationToken token)
   at Microsoft.Extensions.Hosting.Internal.Host.ForeachService[T](IEnumerable`1 services, CancellationToken token, Boolean concurrent, Boolean abortOnFirstException, List`1 exceptions, Func`3 operation)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Aspire.Hosting.DistributedApplication.RunAsync(CancellationToken cancellationToken) in C:\Code\dotnet\aspire\src\Aspire.Hosting\DistributedApplication.cs:line 147
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at Aspire.Hosting.DistributedApplication.Run() in C:\Code\dotnet\aspire\src\Aspire.Hosting\DistributedApplication.cs:line 155
   at Program.<Main>$(String[] args) in C:\Code\dotnet\aspire-dogfood\dev\AspireApp1\AspireApp1.AppHost\Program.cs:line 13
PS C:\Code\dotnet\aspire-dogfood\dev\AspireApp1>
@mitchdenny mitchdenny self-assigned this Jan 16, 2024
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jan 16, 2024
@mitchdenny mitchdenny added this to the preview 3 (Feb) milestone Jan 16, 2024
@davidfowl
Copy link
Member

@mitchdenny is this fixed?

@mitchdenny
Copy link
Member Author

Yes

@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication
Projects
None yet
Development

No branches or pull requests

2 participants