-
Notifications
You must be signed in to change notification settings - Fork 610
Make it easier to choose Azure SQL SKU #8887
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
base: main
Are you sure you want to change the base?
Conversation
@dotnet-policy-service agree company="Microsoft" |
You made a breaking API change |
I added a new optional parameter to AddDatabase, is that considered a breaking change? I guess, otherwise, you are referring to the change to the AzureSqlDatabaseResource that now requires the SKU, but this is used only in the AddDatabase method, which still allows for the same syntax as before this change. Let me know what you think should be changed |
You can’t add a new required parameters to the constructor. That’s why I suggested a WithSku method. The sku is optional |
Ok. I checked where the constructor was used and it was used only in the AddDatabase so I thought it would have been fine, as it seems more natural to me to specify which SKU do you want when you call the AddDatabase method instead of having to discover and learn that there is another method to use to set the SKU. I'll do the change in the next days it shouldn't take long |
You can do it there but it’s still optional on the database itself |
Done, it was easier that I thought :) Let me know if this is better. |
This is looking pretty good. Can you open a breaking change doc issue: New breaking-change template, since we are changing the default SKU here. We should have it in our docs that this change happened. |
Done: dotnet/docs-aspire#3144 |
/// <summary> | ||
/// Gets or Sets the database SKU name | ||
/// </summary> | ||
internal string SkuName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be public
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made the get public and kept the set internal, as we want to make sure developers use the WithSku
method to set the sku, right?
Shouldn’t we be exposing the cdk type? |
What does this mean, specifically? We have a ConfigureInfrastructure on the Sql server resource, where you can get the child cdk objects for the SqlDatabase, and manipulate them. |
Co-authored-by: David Fowler <[email protected]>
…o azuresqldb-8876
I believe the underlying Azure.Provisioning is a SqlSku type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sebastienros - any other thoughts?
Name = databaseName, | ||
}; | ||
|
||
sqlDatabase.Sku = new SqlSku() { Name = AzureSqlDatabaseResource.FREE_DB_SKU }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code that calls into this method is obsolete. I don't think we should change its behavior. We should be deleting the API when we move to a new major version. So let's leave this path using the same behavior as before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So should just I mark it as obsolete and preserve the previous behavior (which means no SKU will be explicitly specified and whatever is the default for Azure SQL at that moment will be used)?
/// <summary> | ||
/// A dictionary where the key is the resource name and the value is the Azure SQL database name. | ||
/// </summary> | ||
public IReadOnlyDictionary<string, string> Databases => _databases.ToDictionary( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eerhardt should this be obsolete too? Or just track that this should be removed in 10.0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't remove APIs without obsoleting them for a release first.
If we don't think we want this API anymore, we can obsolete it. I'd be fine with that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't remove APIs without obsoleting them for a release first.
Really? Meaning we won't remove anything in 10.0 (or at least try) if we haven't obsoleted it in 9.3 or anything before 10?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my opinion, yes. I'm sure there will be cases where we feel we have to make a API breaking change without obsoleting first. But I think we should try to obsolete for a release first, before removing APIs.
Thoughts @DamianEdwards @davidfowl @mitchdenny ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep
@eerhardt make sure we expose Sqlsku and not a string (see primitive obsession) |
Co-authored-by: Eric Erhardt <[email protected]>
Co-authored-by: Eric Erhardt <[email protected]>
Co-authored-by: Eric Erhardt <[email protected]>
Co-authored-by: Sébastien Ros <[email protected]>
Co-authored-by: Sébastien Ros <[email protected]>
If that is needed, then adding For example: var db = sql.AddDatabase("db", "dbName").WithFreeOffer();
Assert.Equal("GP_S_Gen5_2", db.Sku.Name); using Thoughts? |
What about only |
Not sure I follow. There is no "free" Sku...you can set the free offer option and then the Sku will be set automatically to "GP_S_Gen5_2"...but you can set that Sku even without benefitting from the free offer. |
var db = sql.AddDatabase("db", "dbName").WithSku(SqlSku.FreeOffer); |
But then when the SqlSku returned would be the "GP_S_Gen5_2", with no information if that is a free offer or not. So if we go that route then a |
For example:
|
@davidfowl @sebastienros |
Here is a thought after looking at it again. The free offer can't be defined by setting only a sqlDatabase.Sku = new SqlSku() { Name = "GP_S_Gen5_2" };
sqlDatabase.UseFreeLimit = true;
sqlDatabase.FreeLimitExhaustionBehavior = FreeLimitExhaustionBehavior.AutoPause; This means we can't just expose a My suggestion is to just configure databases to be free by default by setting the correct bicep properties, and if someone wants a custom Optionally, if we decide to change the default to non-Bicep defaults, I would also suggest creating a |
I agree with this. We don't expose a "WithSku" helper conveinence method on any other Azure resource.
I can see the value in having a method like this. My only comment is that I wouldn't want the method to be named Maybe if we called it |
So, to summarize:
Is that correct, and all agree that this is the way to go? |
That seems to be the best approach to me. |
I made the changes, but while doing it I realized that having a |
You can pick which database you want to alter var sql2 = builder.AddAzureSqlServer("sql2")
.ConfigureInfrastructure(c =>
{
const string FREE_DB_SKU = "GP_S_Gen5_2";
foreach (var database in c.GetProvisionableResources().OfType<SqlDatabase>())
{
database.Sku = new SqlSku() { Name = FREE_DB_SKU };
}
}); |
Description
Using the Azure SQL DB Free Offer as default deployment option. Added also the ability to specify the desired SKU.
Fixes # (issue)
#8876
Checklist
<remarks />
and<code />
elements on your triple slash comments?doc-idea
templatebreaking-change
templatediagnostic
template