Replies: 1 comment
-
Build a nuget package and share it across your projects? We're not at the point where we're ready to bake in convince methods at this level just yet, feel free to build this and ship a nuget package. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With Aspire 9 enabling control over resource names (#6484), it's been a real positive change and enabler for a bunch of things:
It's easier to create centralized development resources, i.e. if I want one development database for the team to share and I wanted a fixed database, before, I would need to provision it initially, have an 'IsPublishMode' switch in aspire to use a connection string, and then have that connection string in user secrets shared around the team (and drop down into bicep to give it a friendly name). This removes all of that, I can just add CosmosDb in Aspire and as long as the resolver is configured, everyone gets the same database.
Where resources are used between different repo's, I don't need to copy/share connection strings between those.
It would nice if there was a short-hand out of the box option with Aspire, if anything just so it's clear when you declare something like a database, you know if you're going to get a single instance or something unique to the provisioning context of your local machine.
So where you can do this for a unique name now (and set it however you want):
Perhaps you could have something more automatic that gives you some options for behavior:
The NameUniqueTo enum could be
NameUniqueTo.ProvisioningContext would be the same behavior as you get now so essentially does nothing apart from make it explicit to whoever is reading the code of how this resource will be named and it's uniqueness. The only difference is it could include pre/postfix in the name.
NameUniqueTo.SubcriptionAndResourceGroup would take the subscription ID and resource group name from config (and throw a meaningful exception if not defined), and create a short deterministic hash of those two things. It would really just be an extension method/shortcut to 'ConfigureInfrastructure' where you could do the same thing manually now. Prefix and postfix gives some things you can add to the name for a bit more control.
So for:
appsettings.json
You get a resource called 'mycompany-cosmos-[HashOfSubscriptionIdAndResourceGroup]-dev'
I think it would make it clear/easy when you declare this kind of resource, what you're going to get, and gives all the benefits described earlier. Whether you'd want to have baked in validation or leave it to the user to ensure it's not too long/has valid chars for the resource type is optional, they'd just need to be aware that it's on them to ensure the resulting name is unique within that scope.
Beta Was this translation helpful? Give feedback.
All reactions