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

Add Cosmos database resource. #1583

Merged
merged 5 commits into from
Jan 10, 2024
Merged

Conversation

mitchdenny
Copy link
Member

@mitchdenny mitchdenny commented Jan 8, 2024

This PR adds support for AddDatabase(...) on Cosmos database resources.

Microsoft Reviewers: Open in CodeFlow

Usage:

var builder = DistributedApplication.CreateBuilder(args)
var account = builder.AddCosmosDB("myaccount");
var db = account.AddDatabase("imports");

The manifest will look like this:

{
  "resources": {
    "myaccount": {
      "type": "azure.cosmosdb.account.v0"
    },
    "imports": {
      "type": "azure.cosmosdb.database.v0",
      "parent": "myaccount"
    }
  }
}

The expectation is that a deployment tool that supports these resource types would create the database as well.

@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 8, 2024
@davidfowl
Copy link
Member

Can you update the provisioner as well?

Copy link
Member

@Pilchie Pilchie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is essentially exactly what I had in one of the iterations of my PR ;)

@mitchdenny
Copy link
Member Author

Yeah at the time I didn't quite realize just how painful it is to create a database when using managed identity with the data plane SDK.

@Pilchie
Copy link
Member

Pilchie commented Jan 8, 2024

Note that I think in the long term we're going to loosen that up and support it in the data plane SDK, but that's probably a next semester work item.

@mitchdenny
Copy link
Member Author

Can you update the provisioner as well?

Provisioner updated.

@mitchdenny mitchdenny self-assigned this Jan 10, 2024

await foreach (var existingDatabase in existingDatabases)
{
if (!resource.Databases.Any(d => d.Name == existingDatabase.Data.Name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could do a single pass over the set of databases but I'm not concerned about performance 😄

@mitchdenny mitchdenny merged commit 5ee685e into main Jan 10, 2024
8 checks passed
@mitchdenny mitchdenny deleted the mitchdenny/cosmos-database-resource branch January 10, 2024 19:52
@github-actions github-actions bot locked and limited conversation to collaborators Apr 26, 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

Successfully merging this pull request may close these issues.

4 participants