Skip to content

Fixed Azure resource name through Aspire #6484

Answered by eerhardt
mip1983 asked this question in Q&A
Discussion options

You must be logged in to vote

.NET Aspire 9 added a better way to enable this. There are 2 ways to do this:

  1. Locally per resource
builder.AddAzureCosmosDB("ecoDriverCosmosDb")
    .ConfigureInfrastructure(infrastructure =>
    {
        // set the resource's Name to a fixed value
        var cosmosAccount = infrastructure.GetProvisionableResources().OfType<CosmosDBAccount>().Single();
        cosmosAccount.Name = "ecoDriverCosmosDb";
    })
  1. Globally across all resources
var builder = DistributedApplication.CreateBuilder(args);

builder.Services.Configure<AzureProvisioningOptions>(options =>
{
    options.ProvisioningBuildOptions.InfrastructureResolvers.Insert(0, new FixedNameInfrastructureResolver());
});

builder.A…

Replies: 5 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@mip1983
Comment options

Answer selected by mip1983
Comment options

You must be logged in to vote
1 reply
@davidfowl
Comment options

Comment options

You must be logged in to vote
1 reply
@eerhardt
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants