TyngeOfTheGinge
TyngeOfTheGinge

Reputation: 544

SQL DB Hyperscale ServiceObjectiveName/Cores

I am using the azure libraries for .net SDK and ran into a question.

What are the available options for the ServiceObjectiveName if the DatabaseEdition is Hyperscale?

When I create a Hyperscale DB, the ServiceObjectiveName default is Gen4 I believe. Is there a way to specify Gen5 and the amount of cores?

I found the list of ServiceObjectiveNames, but none of them seem to correlate to Hyperscale values. https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.sql.models.serviceobjectivename?view=azure-dotnet

Upvotes: 0

Views: 431

Answers (1)

Jim Xu
Jim Xu

Reputation: 23111

According to my test, if we use Azure Management Libraries for .NET to create Hyperscale Gen5 database, we can use method ServiceObjectiveName.Parse("") to specify Gen5 and the amount of cores.

for example

If we use ServiceObjectiveName.Parse("HS_Gen5_2"), it means that thh databse is Hyperscale: Gen5, 2 vCores.

The detailed stesps are as below:

  1. Create a service principal and assign role to the sp
az ad sp create-for-rbac --name ServicePrincipalName --role contributor
  1. Code:
var tenantId = "<your tenant id>";
            var clientId = "<your sp app id>";
            var clientSecret = <your sp password>;

            var SubscriptionId = "<your subscription id>";

            var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(
                                    clientId,
                                    clientSecret,
                                    tenantId,
                                    AzureEnvironment.AzureGlobalCloud);
            var azure = Microsoft.Azure.Management.Fluent.Azure.Configure()
                        .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
                        .Authenticate(credentials)
                        .WithSubscription(SubscriptionId);

            var sqlServer = azure.SqlServers.GetByResourceGroup("test", "testsql07");
            Console.WriteLine(sqlServer.Name);

            var database = await sqlServer.Databases.Define("test1")
                                                   .WithEdition(DatabaseEdition.Hyperscale)
                                                   .WithServiceObjective(ServiceObjectiveName.Parse("HS_Gen5_2"))
                                                   .CreateAsync();
            Console.WriteLine(database.Edition.Value);
            Console.WriteLine(database.RequestedServiceObjectiveName.Value);

enter image description here enter image description here

Upvotes: 1

Related Questions