Skip to content

Azure Storage ports changing despite using ContainerLifetime.Persistent #7058

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

Closed
1 task done
MarcinJuraszek opened this issue Jan 9, 2025 · 9 comments
Closed
1 task done
Assignees
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure-storage Issues related to azure storage integration needs-author-action An issue or pull request that requires more info or actions from the author.

Comments

@MarcinJuraszek
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

We're using Azure Storage with Emulator and configure it to stay alive between runs using c.WithLifetime(ContainerLifetime.Persistent). Despite that, every time we re-run the AppHost the ports the Emulator is exposing for the app change. This is unexpected and makes things harder than they should be. E.g. we're also using Durable Functions in our project, and use Durable Functions Monitor in VS Code to inspect the inner workings of Durable Task Framework. However, because the ports for the Storage change on every run, the Monitor breaks and we have to re-add a new connection, after getting the new set of ports from Aspire Dashboard.

Expected Behavior

I would expect the Azure Storage connection string exposed by the emulator to stay stable between re-runs of App Host if configured with WithLifetime(ContainerLifetime.Persistent)

Steps To Reproduce

  1. Create an App Host with an Azure Storage resource, configure it to use an emulator and set to be persistent between runs:
var storage = builder.AddAzureStorage("storage")
    .RunAsEmulator(c =>
    {
        c.WithDataVolume();
        c.WithLifetime(ContainerLifetime.Persistent);
    });
  1. Run the App Host, take note of the Endpoint URLs displayed in the dashboard
  2. Stop and re-start the App Host, compare the new Endpoint URLs to the one from previous run

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

No response

@davidfowl davidfowl added area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-orchestrator area-integrations Issues pertaining to Aspire Integrations packages azure-storage Issues related to azure storage integration labels Jan 10, 2025
@dbreshears dbreshears added this to the 9.1 milestone Jan 13, 2025
@dbreshears
Copy link
Contributor

Let's update to use proxyless for persistent containers.

@joperezr joperezr removed area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication area-orchestrator labels Jan 13, 2025
@davidfowl
Copy link
Member

I can't reproduce this on main, @MarcinJuraszek can you use a daily build and see if you can reproduce it https://github.com/dotnet/aspire/blob/main/docs/using-latest-daily.md?

@davidfowl davidfowl added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jan 24, 2025
@sebastienros
Copy link
Member

sebastienros commented Feb 5, 2025

Let's update to use proxyless for persistent containers.

I confirm the issue described here is that we get random exposed ports for each run:

Image

Image

Not sure if that is possible, but I'd like to see if we could persist the ones we got and then reuse them on a new run.

@sebastienros
Copy link
Member

sebastienros commented Feb 5, 2025

This problem applies to all containers. The solution for the foreseeable future is to use the new API introduced in this PR which can disable endpoint proxying. The direct effect is that the "Target Port" of an endpoint will be the one exposed directly by the container, so it will be stable. The risk is that there could be conflicts with other services, and that you can't run two instances of the same container with this mode. This is until some down-level work is done in ServiceSpec from DCP to allow for this scenario (probably 10.0 timeframe).

Note that the ports can be defined in the application host using WithQueuePort/WithTablePort/WithBlobPort.

@sebastienros
Copy link
Member

Sample usage:

var builder = DistributedApplication.CreateBuilder(args);

var storage = builder.AddAzureStorage("storage").RunAsEmulator(container =>
{
#pragma warning disable ASPIREPROXYENDPOINTS001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
    container.WithDataBindMount().WithEndpointProxySupport(false);
#pragma warning restore ASPIREPROXYENDPOINTS001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
});

@danmoseley
Copy link
Member

@sebastienros @karolz-ms it seems from above this 9.1 issue should either be closed or moved to 10.0 to track "until some down-level work is done in ServiceSpec from DCP "?

@karolz-ms
Copy link
Member

@danmoseley agreed. I will let you/@sebastienros do the move. The underlying issue #7046 spans app model and DCP and is really more of an intersection between the two.

@sebastienros
Copy link
Member

@danmoseley I marked it as blocked for this reason, not the best approach but I was not sure about the decision. I am ok with closing it if @MarcinJuraszek acknowledges the recommendation works

@dbreshears dbreshears modified the milestones: 9.1, Backlog Feb 10, 2025
Copy link

This submission has been automatically marked as stale because it has been marked as requiring author action but has not had any activity for 14 days.
It will be closed if no further activity occurs within 7 days of this comment.

@dotnet-policy-service dotnet-policy-service bot removed this from the Backlog milestone Mar 4, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-integrations Issues pertaining to Aspire Integrations packages azure-storage Issues related to azure storage integration needs-author-action An issue or pull request that requires more info or actions from the author.
Projects
None yet
Development

No branches or pull requests

8 participants